Problem
Write a program that asks the user to input marks in five different subjects. Then find the sum and average of those marks and print them.Note: Solve the above problem by using array
Solution - Code
#include<stdio.h>#include<conio.h>
#include<stdlib.h>
main()
{
int i,x,sum=0,avg;
int num[5];
for (i=0;i<5;i++)
{
printf("Enter numbers: ");
scanf("%d",&num[i]);
}
for (i=0;i<5;i++)
{
sum = sum + num [i];
}
avg =(sum/5);
printf ("sum = %d\n",sum);
printf ("average = %d\n",avg);
system("pause");
}
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.