Q. Write a C program using structure to find student grades in a class. Make necessary assumption.
Ans.
Before writing program we make some assumption as following :
Maximum total marks is 500.
Student_percentage Grades
>=80 A
>=60 B
>=50 C
>=40 D
<40 F
/*C program to find students grades in a class through structure */
#include<stdio.h>
#include<conio.h>
struct stud
{
char nam[20];
char nam[20];
int obtain_mark;
int per;
char grad[5];
};
struct stud s[5];
int i;
int main()
{
for(i=1; i<=5; i++)
{
printf("Enter %d student name : ",i);
scanf("%s",&s[i].nam);
printf("Enter %d student obtained marks = ",i);
scanf("%d",&s[i].obtain_mark);
fflush(stdin);
s[i].per=s[i].obtain_mark/5;
for(i=1; i<=5; i++)
{
printf("Enter %d student obtained marks = ",i);
scanf("%d",&s[i].obtain_mark);
fflush(stdin);
}
for(i=1; i<=5; i++)s[i].per=s[i].obtain_mark/5;
for(i=1; i<=5; i++)
{
if(s[i].per>=80)
strcpy(s[i].grad,"A");
else if(s[i].per>=60)
strcpy(s[i].grad,"B");
else if(s[i].per>=50)
strcpy(s[i].grad,"C");
else if(s[i].per>=40)
strcpy(s[i].grad,"D");
else
strcpy(s[i].grad,"F");
}
}
for(i=1; i<=5; i++)
printf("\n%d student %s has obtained grade %s ",i,s[i].nam,s[i].grad);
getch();
getch();
return 0;
}
Output of above programe :
Enter 1 student name : John
Enter 1 student obtained marks : 250
Enter 2 student name : Robert
Enter 2 student obtained marks : 410
Enter 1 student obtained marks : 250
Enter 2 student obtained marks : 410
Enter 3 student obtained marks : 386
Enter 4 student obtained marks :197
Enter 5 student obtained marks : 490
1 student Jhon has obtained grade C
2 student Robert has obtained grade A
2 student Robert has obtained grade A
3 student Isabell has obtained grade B
4 student Adem has obtained grade F
5 student Harry has obtained grade A
Figure: Screen-shot of find student grades through structure C program |
Related programs:
show how to write a program to convert kg to pounds
ReplyDeleteplz tell how to construct a program o convert wieght from kg to pound where 1 pound=.4536kg
ReplyDeleteplz tell how to construct a program o convert wieght from kg to pound where 1 pound=.4536kg
ReplyDeleteplz tell how to construct a program o convert wieght from kg to pound where 1 pound=.4536kg
ReplyDeleteplz tell how to construct a program o convert wieght from kg to pound where 1 pound=.4536kg
ReplyDeleteI write your C conversion program, with example and how to done the conversion process at:
Deletehttp://cprogrammingcodes.blogspot.in/2012/03/kg-to-pound-convert.html
gud one
ReplyDeleteyou forgot the
ReplyDeleteyou for got the < string . h >
ReplyDeletethis ish just dont work!!!
ReplyDelete@Anonyumous(plz login and then comment for easily reply).
DeleteIn above program there are not required string header file.
And all programs in this site work, run and execute in genuine right way.
(I also mention screen shot of above program).
Note:what u find error?
how i make a flow chat of polynomial multiplied by monomial can u help mee plzzz
ReplyDeletehow i make a flow chat of polynomial multiplied by monomial can u help mee plzzz
ReplyDeletehow to make flow chart for this structure programme
ReplyDeletecreate a structure employee and insert the details such as employee id,name,age,employ...
ReplyDeletegive the source code of this
plz give me the algorithm&flow chart for this program
ReplyDeleteUmm Sorry this has no mistake but, after compiling when it's running...
ReplyDeleteThe result can't be displayed and not responding in Dev C++
please help.. for c program to accept the names and marks of 10 students in 5 subjects. print in descending order the rank list based on the average of the 5 subjects.
ReplyDeleteplease help me in making student and teacher console in c using structures
ReplyDelete