Programming Examples

Cpp program to input 10 integer numbers and find their sum and average


Write a cpp program to input 10 integer numbers and find their sum and average

Solution

#include<iostream>
using namespace std;
int main(){
     int num[10],a,sum=0;
     float avg;
     cout<<"Enter 10 integer numbers"<<endl;
     for(a=0;a<10;a++)
     {
          cin>>num[a];
     }
     cout<<"List of elements :";
     for(a=0;a<10;a++)
     {
          sum+=num[a];
          cout<<num[a]<<"\t";
     }
     avg=float(sum/10);
     cout<<"\nSum is "<<sum<<endl;
     cout<<"Average is "<<avg;
     return 0;
}
Output

List of elements : 2     3       2       3       2       3       2       3       2       3

Sum is 25

Average is 2

Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2024 Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz