Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Then u noe hw 2 use do-while loop mar?
Something like
do {
/* your code here */
} while (condition)
ithelp
Nearly a Posting Maven
2,230 posts since May 2006
Reputation Points: 769
Solved Threads: 128
I am too very new in C... I ll try to solve ur prob.....
alvalany
Junior Poster in Training
61 posts since Jul 2009
Reputation Points: 8
Solved Threads: 2
Im to 100% sure.. I ll try my best...
alvalany
Junior Poster in Training
61 posts since Jul 2009
Reputation Points: 8
Solved Threads: 2
I could do only this.......
Rest is left upto you....
Reply if this was useful..
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,a=0,b=0,c=0,dg=0,f=0;float ca=0,x;
struct data
{
int sin; //student id no
int t1; //test 1
int t2; //test 2
int tf;//final test
float sa ;//sem average
char grad;
};
struct data d[100];
clrscr();
for(i=0;i<=99;)
{
printf("Enter the student identification number:");
scanf("%d",&d[i].sin);
if(d[i].sin==0)
break;
printf("Enter the test marks of TEST 1,TEST 2,TEST 3 respectively\n");
scanf("%d%d%d",&d[i].t1,&d[i].t2,&d[i].tf);
d[i].sa=0.20*d[i].t1 +0.30*d[i].t2+0.50*d[i].tf;
printf("SEMESTER AVERAGE= %f\n",d[i].sa);
x=d[i].sa;
if((x<=100.00) && (x>=90.0))
{
d[i].grad='A';
printf("The grade of student is A\n");
a++;
}
if((x<=89.0) && (x>=80.0))
{
d[i].grad='B';
printf("The grade of student is B\n");
b++;
}
if((x<=79.0) && (x>=70.0))
{
d[i].grad='C';
printf("The grade of student is C\n");
c++;
}
if((x<=69.0) && (x>=60.0))
{
d[i].grad='D';
printf("The grade of student is D\n");
dg++;
}
if((x<=59.0) && (x>=0.0))
{
d[i].grad='F';
printf("The grade of student is F\n");
f++;
}
i++;
}
printf("The number of students having A grade : %d\n",a);
printf("The number of students having B grade : %d\n",b);
printf("The number of students having C grade : %d\n",c);
printf("The number of students having D grade : %d\n",dg);
printf("The number of students having F grade : %d\n",f);
ca= (4*a+3*b+2*c+1*dg)/i;
printf("Class Average is %f",ca);
getch();
}
alvalany
Junior Poster in Training
61 posts since Jul 2009
Reputation Points: 8
Solved Threads: 2
Since the OP seems to be happy (quote - "hehe") for someone to do his (or her) homework, all I'll say about your code is DO NOT USE void main().
And I'm sure the OP is 'rily' happy for you to do this.
The main function should be declared as:
- int main(), or
- int main(void), or
- int main(int argc, char *argv[]), or
- int main(int argc, char **argv)
Just shoot the void as the return type.
thanks for your correction.......
alvalany
Junior Poster in Training
61 posts since Jul 2009
Reputation Points: 8
Solved Threads: 2
One correction has to be done in the code..
No rank will be reported when sa is b/w 69 and 70.. and other similar cases..
hope you can correct it yourself
alvalany
Junior Poster in Training
61 posts since Jul 2009
Reputation Points: 8
Solved Threads: 2