Computer Concept & Programming In C - Unit IV - 22

Q.31. Create an array to store the marks of 500 student in a subject. maximum mark in the subject is 100. Write a program in C language to convert the marks into grades as follows : marks <20 is ‘E’ grade; 20> = marks <40 is ‘D’ grade; 40> = marks <60 is ‘D’ grade; 60> = marks <80 is ‘B’ grade; 80> = marks < = 100 is a grade. Calculate the percentage of marks of each student. Also give the total number of students Who have secured ‘E’ grades.                                                 (AKTU. 2012 - 13)
Ans.
#  include <stdio.h>
#  include <conio.h>
#  define n 500
void main ( )
{
int marks [n], i, e = 0;
clrscr ( );
printf (“\ n Enter marks of studenrts”);
for (i = 0; i < n; i++)
{
printf (“\n Enter marks of student %d, (i+1)”);
scanf (“%d”, & mark [i]);
}
printf (“\n The grades of student is as follows”);
for (i = 0; i < n; i++)
{
printf (“\n Grade of student No. %d”, (i + 1));
if (marks [i] < 20)
{
printf (“Is E”);
e ++;
}
if ((marks[i] >= 20) && (marks [i] < 40 ))
printf (“is D”);
if ((marks [i] > = 40) && (marks [i] < 60))
printf(“is C”);
if ((marks [i] >= 60) && (marks [i] < 80))
printf (“is B”);
if ((marks [i] >= 80) && (marks [i] <= 100))
printf (“is A”);
if ((marks [i] < 0) | | (marks [i] <= 100))
printf (“\n Invalid marks”);
}
printf (“\n Total Number of students with E grades”);
printf (“are %d”, e);
getch ( );
}
Since marks are out of 100. The percentage marks securerd by any student will be the same as individual marks.

Q.32. Write a program in C to create an array of integers using pointers. Also give the count of the positive and negative integers in that array.                               (AKTU. 2012 - 13)
Ans. The program is as follows
#  include <stdio.h>
#  include <conio.h>
#  define size 100
void main ( )
{
int i, j, t;
int list [size];
clrscr ( );
printf (“\n Enter elements”);
for (i = 0; i < size; i++)
{
printf (“\n Enter number - %d”, i+1);
scanf (“%d”, & list [i]);
}
for (i = 0; i < size; i++)
{
for (j = 1; j < size; j++)
{
if (list [j - 1] < list[j])
{
t = list[j - 1];
list [j - 1] = list [j];
list [j] = t;
}
}
}
printf (“\n List in descending order is \n”);
for (i = 0; i < size; i++)
printf (“\ n % d”, list [i]);
getch ( );
}