Write a program to take 10numbers as input and print their average
Answers
Program in c :
#include<stdio.h>
int main(){
printf("Enter 10 number");
int num,sum = 0;
for( int i = 0 ; i < 10 i ++){
scanf('%d',num);
sum = num + sum;
}
printf("The average is &d",(sum/10));
}
Output:
Enter 10 number 10 20 30 40 50 60 70 80 90 100
The average is 55
Program in c++ :
#include<iostream>
int main(){
cout<<"Enter 10 number";
int num,sum = 0;
for( int i = 0 ; i < 10 i ++){
cin>>num;
sum = num + sum;
}
cout<<"The average is "<<(sum/10);
}
Output:
Enter 10 number 10 20 30 40 50 60 70 80 90 100
The average is 55
Program in java :
import java.util.*;
public class Main{
public class void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.println("Enter 10 number");
int num,sum = 0;
for( int i = 0 ; i < 10 i ++){
num = sc.nextInt();
sum = num + sum;
}
System.out.println("The Average of 10 numbers is "+(sum/10));
}
}
Output:
Enter 10 number 10 20 30 40 50 60 70 80 90 100
The average is 55
Program in python :
print("enter 10 numbers : ")
sum = 0
for i in range (1,10):
num = int(input())
sum = num + sum
print("The average is ",sum)
Output:
Enter 10 number 10 20 30 40 50 60 70 80 90 100
The average is 55
---- you did not mentioned language so i wrote it in 4 different languages so that you can choose any one of those, if you liked my programs feel free to mark my answer as brainliest, i would really help me :)