# Input the marks of ten students and display their average. Use for loop for this purpose

answered Oct 5, 2019 by paraboy
int arr;double sum=0;

for(int i=0;i<10;i++)

{

cin>>arr[i];

sum=sum+arr[i];

}

sum=sum/10;

cout<<"Average of 10 students is "<<sum<<endl;
answered Oct 9, 2019 by anonymous
#include <stdio.h>

/**
* Code to work out average of results from 10 students entered
*/

int main(){

/*
result and sum can be float etc for more precision since
if results can be .25 and sum could be a decimal result as a result
*/

int counter, result, sum;
double avg;     // double for precision

//For loop to enter scores for 10 students, and work out sum on each pass
for(counter = 0; counter < 10; counter++){
printf("Please enter result for student %d: ", counter+1);
scanf("%d", &result[counter+1]);

//sum = current sum value + value in array
sum +=result[counter+1];
}

avg = (double)sum / (double)10;         //typecast for precision. Not required necessarily

printf("Average result is %f", avg);

return 0;
}
answered Oct 12, 2019 by anonymous
#include <stdio.h>
#include<conio.h>

#include <stdio.h>

main()
{
char arr;
double avg=0;
int sum=0;

for(int i=1;i<=10;i++)

{

scanf("%s",&arr[i]);

sum=sum+arr[i];

}

avg=sum/10;

printf("Average of 10 students is %g\n",avg);
}
answered Oct 12, 2019 by anonymous
#include <stdio.h>
#include<conio.h>
main()
{
char arr;
double avg=0;
int sum=0;
for(int i=1;i<=10;i++)

{
scanf("%s",&arr[i]);
sum=sum+arr[i];
}
avg=sum/10;
printf("Average of 10 students is %g\n",avg);
}
answered Oct 15, 2019 by (270 points)

#include <stdio.h>

int main()
{
int a,i,sum=0;
for(i=1;i<=10;i++)
{
printf("enter marks of student %d\n",i);
scanf("%d",&a[i]);
sum=sum+a[i];
}
float average =sum/10.0;

printf("avgerage marks of 10 students =%.2f\n",average);

return 0;
}

answered Oct 16, 2019 by (140 points)
import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int n, d = 0;

int avg = 0;

Scanner s = new Scanner(System.in);

n = s.nextInt();

int Array[] = new int[n];

for (int i=0; i<n; i++)

{

Array[i] = s.nextInt();

d = d + Array[i];

}

avg = d / n;

System.out.println("Average:"+avg);

}

}
answered Oct 17, 2019 by (140 points)
#include <stdio.h>

int main()
{
int array,i,sum;
printf("enter the 10 students marks\n");
for(i=0;i<10;i++)
scanf("%d",&array[i]);
for(i=0;i<10;i++)
{
sum+=array[i];
}
printf("the average is %d.%d",sum/10,sum%10);
return 0;
}