\\An array is a set of similar data types having contagious memory location.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr(); \\To clear previous output
int arr[10]; \\declaration of array of data type int
int a,sum=0;
cout<<"Enter 10 numbers to print the sum";
for(a=0;a<10;a++)
{
cin>>arr[a];
sum=sum+arr[a];
}
cout<<sum;
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr(); \\To clear previous output
int arr[10]; \\declaration of array of data type int
int a,sum=0;
cout<<"Enter 10 numbers to print the sum";
for(a=0;a<10;a++)
{
cin>>arr[a];
sum=sum+arr[a];
}
cout<<sum;
getch();
}
No comments:
Post a Comment