hi
how are you ?
i have project in loop but i dont know how to solve it ?
Write a C program to read results of class of 20 students. Each student has 4 results, distributed as follow:
• Test 1 25 %
• Test 2 25 %
• Test 3 25 %
• Final 50 %
can you help me ,plz?

Post your code here showing your effort towards solving this program.

Test 1 25 %
Test 2 25 %
Test 3 25 %
Final 50 %

adds up to 125%. I think one of your numbers is off.

adds up to 125%. I think one of your numbers is off.

no in program i should take 2 test only

Post your code here showing your effort towards solving this program.

#include<stdio.h>
int main()
{
    int student_num;
    double test1;
    printf("enter student number");
    scanf("%d",&student_num);
    while (student_num<20)
    {
        printf("\n enter test1");
        scanf("%lf",&test1);
        printf("sudent number test1");
        printf("     %d       %.2lf",student_num,test1);
        student_num++;
    }
    return 0;
}

this code for read test1 only
but dont work

can you describe your program little more, exactly what are you trying to do??

and always embed your program code between code-tags.

I see it says if the number entered for the student is less than 20, it will print out what I assume is data on this fictional student regarding test info, and other stuff.

If you are supposed to simulate 20 individual students however, wouldn't it be better to use an array or an array with a structure?

If you have to read numbers of all 20 students thr is no need of scanning student_num. So remove that line and initialise student_num to 0.

student_num = 0;

and better to read all numbers in one loop than use another loop to print them all at once..

And if you have knowledge of how to use structs it will be easier for you to scan four numbers and later on you can do anything you want them with.

You know anything about structures in C???

I see it says if the number entered for the student is less than 20, it will print out what I assume is data on this fictional student regarding test info, and other stuff.

If you are supposed to simulate 20 individual students however, wouldn't it be better to use an array or an array with a structure?

how i can use array ?!
:'( help me,plz

Array of doubles,
4 subjects and 20 students so total number of elements will be 80..

double Marks[80];

And for scanning use another loop inside while

while(student_num < 20)
{
     for(int i=0; i<4; i++)
     {
        // Scan "students_num"th students "i"th marks ..
      }
}

hi i done my code but sir want me use calling function:
4- The total of each student is determined by a user-defined function named as calculate_total; which receives the four results and returns the total of the - final and the highest two tests only- (drop the lowest test).
5- Create a new array Grades; which contains the equivalent grade letter for each student. (see point 6)
6- The grade letter must be determined by a user-defined function named as grade_letter that receives the total of each student and returns the corresponding letter based on the following categories.

my code is
for 4:

doble avg(double test1,double test2,double test3,double final)
{
	if(test1<=test2)
	test1=0;
	else if (test2<=test3)
	 test2=0;
	else (test3<=test1)
		test3=0;
	return test1[i]+test2[i]+test3[i]+final[i];

how h can calling function in array ????

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.