Write a program for the following problem. An instructor needs a program that accepts a student identification number and three test scores, test1, test2, and final_test as input, and determines and outputs for each student the semester average and the final letter grade according to the following scheme:

SEMESTER AVERAGE FINAL LETTER GRADE
90 – 100 A
80 – 89 B
70 – 79 C
60 – 69 D
0 – 59 F

The semester average for students is computed using the formula
semester_average = 0.20 * test1 + 0.30 * test2 + 0.50 * final_test

Student identification numbers are four-digits integer. Input should terminate when the instructor types 0 for the student identification number. The instructor also wants a distribution of letter grades and a class average. Class average is computed using the following formula:

class_average = (4 * number_of_A_grades + 3 * number_of_B_grades + 2 * number_of_C_grades + 1 * number_of_D_grades)/number_of_students

Believe me nobody is gonna help you unless you show some progress in your assignment.

Believe me nobody is gonna help you unless you show some progress in your assignment.

Then u noe hw 2 use do-while loop mar?

Then u noe hw 2 use do-while loop mar?

Something like

do {

/* your code here */
} while (condition)
commented: good example +3
commented: Missing a semi-colon after the while bit. -4
commented: Negate "i am a weener's" pedantry +36

I think you should start with a basic C book. You can not learn each and every language construct by communities.

Something like

do {

/* your code here */
} while (condition)

You forgot the semicolon after the while.:icon_smile:

Could u gv me the website tat can download c programing the notes n the example? Thx^^

Could u gv me the website tat can download c programing the notes n the example? Thx^^

Google C programming tutorials and you will find more than a ton.

I am too very new in C... I ll try to solve ur prob.....

Rily?
Then thx ya...hehe

<rant>
For crying out loud, is this a forum on how to shortcut the English language? Sometimes it feels like it's a tutorial on how to read friggin' SMS messages.

Then u noe hw 2 use do-while loop mar?

u=you, noe=know,hw=how, 2=to, mar=anyone's guess

Could u gv me the website tat can download c programing the notes n the example? Thx^^

u=you, gv=give, tat=that, n=and, thx=thanks

I am too very new in C... I ll try to solve ur prob.....

ur=your,prob=problem

Here's the deal; in the examples I quoted, there is a difference of 19 characters between the crapshoot spelling and the correct spelling (not counting whatever the hell "mar" means).

Get on board and at least try to use proper English.
</rant>

commented: Layin' down the law! +36

Im to 100% sure.. I ll try my best...

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();

}

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.

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.......

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

Whats the difference between void main() and int main()?

#include <stdio.h>

int main(){   
    int id_no, test1, test2, final_test, semester_average, count;

    printf("\t\t* * * * * * * * * * * * * * * * * * * * * * * * * *\n");
    printf("\t\t*_________________________________________________*\n");
    printf("\t\t*|               Welcome to My Programe          |*\n");
    printf("\t\t*|_______________________________________________|*\n");
    printf("\t\t*|____SEMESTER  AVERAGE______FINAL LETTER GRADE__|*\n");
    printf("\t\t*|                        |                      |*\n");
    printf("\t\t*|         90 – 100       |           A          |*\n");
    printf("\t\t*|         80 – 89        |           B          |*\n");
    printf("\t\t*|         70 – 79        |           C          |*\n");
    printf("\t\t*|         60 – 69        |           D          |*\n");
    printf("\t\t*|          0 – 59        |           F          |*\n");
    printf("\t\t*|________________________|______________________|*\n");
    printf("\t\t* * * * * * * * * * * * * * * * * * * * * * * * * *\n");

    do{
    printf("Enter the student ID no[4 digit]: \n");
    scanf("%d", &id_no);
        if(id_no < 1000 || id_no > 10000){
            do{
            printf("Invalid!!! The ID no must in 4 digit number.\n");
            printf("Please enter the student ID no again: \n");
            scanf("%d", &id_no);    
            }while(id_no < 1000 || id_no > 10000);

        }

    printf("Enter test score 1: \n");
    scanf("%d", &test1);
        if(test1 <= -1 || test1 > 101)
        {
            do{
                printf("Invalid!!!\n");
                printf("Please enter the test for score 1 again: \n");
                scanf("%d", &test1);
            }while(test1 <= -1 || test1 > 101);
        }

    printf("Enter test score 2: \n");
    scanf("%d", &test2);
        if(test2 <= -1 || test2 > 101)
        {
            do{
                printf("Invalid!!!\n");
                printf("Please enter the test for score 2 again: \n");
                scanf("%d", &test2);
            }while(test2 <= -1 || test2 > 101);
        }

    printf("Enter test final score: \n");
    scanf("%d", &final_test);
        if(final_test <= -1 || final_test > 101)
        {
            do{
                printf("Invalid!!!\n");
                printf("Please enter the test for final again: \n");
                scanf("%d", &final_test);
            }while(final_test <= -1 || final_test > 101);
        }

    semester_average = 0.20 * test1 + 0.30 * test2 + 0.50 * final_test;

    printf("Semester average for student %d: %d\n", id_no, semester_average);
    printf("Press 1 to continue or press 0 to exit the programe.\n");
    scanf("%d", &count);
    }while(count != 0);

    printf("Thanks 4 using.\n");

    return 0;

}

I try 2 cr8 a program to my assignment, bt din fin yet...
Please have a look at my program n gv sm advise...Thx^^

Please use proper English, didn't you read above posts by yellowSnow?

commented: It appears they haven't read anything yet +36

ok, sory for my broken english...

If any one wnt hlp in c .......post any assignment..i will solve it ....anu projet

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.