In this program user will find out the average of students scores. To perform this action the required info and variables are essentials. Like user declare array type variable and float type that will contain the value to be declared. After that user ask to enter the value like subject marks in the end process user add all the scores and divide them all with total subjects to find out the average of students. And to use printing method shown out the result on the screen.
Problem Statement:
- Declaring variables.
- Collecting info about scores.
- Using average finding method.
- Display result on the screen.
Here is C source code for finding average of students. The output of this program shown below.
#include <stdio.h>
void main( )
{
char name[20];
float score1 , score2, score3, avg;
clrscr();
printf("Please Enter your name : " ) ;
scanf("%s" , name);
printf("P1ease Enter the First Score : " ) ;
scanf("%f",&score1);
printf("P1ease Enter the Second Score : " ) ;
scanf ( "%f",&score2);
printf("P1ease Enter the Third Score : " ) ;
scanf ("%f" , &score3);
avg = (score1+score2+score3)/3;
printf ("\n\nName: %-s\n\n", name);
printf("Score 1: %-5.1f\n" , score1 ) ;
printf("Score 2: %-5.1f\n" , score2);
printf("Score 3: %-5.1f\n" , score3);
printf("Average: %-5.1f\n\n", avg);
getch();
}