Number of meatballs ate in last 5 days and average of total meatballs ate!! (for loop,string,array)
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i;
int meatballs[5];
int totalballs = 0;
for(i=0;i<5;i++){
printf("meatballs consumed on day %d?\n",i+1);
scanf("%d",&meatballs[i]);
}
for(i=0;i<5;i++){
totalballs = totalballs + meatballs[i];
}
int avg = totalballs / 5;
printf("You ate %d meatballs in total,%d meatballs in average",totalballs,avg);
return 0;
}
Comments
Post a Comment