Read OnLine C- Program Example

05_ARRAY
PRAC 9 PRAC 10
//wap to print addition element
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,ans=0;
clrscr();
a[0]=123;
a[1]=43;
a[2]=77;
a[3]=34;
a[4]=67;
for (i=0;i<=4;i++)
{
ans=ans+a[i];
}
printf("%d",ans);
getch();
}
------output-------
344
//wap to print addition element
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,ans=0;
clrscr();
printf("Enter array element:");
for (i=0;i<=4;i++)
{
printf("\n Enter element%d:",i);
scanf("%d",&a[i]);
}
for (i=0;i<=4;i++)
{
ans=ans+a[i];
}
printf("%d",ans);
getch();
}
------output------
Enter array element:
Enter element0:34
Enter element1:54
Enter element2:44
Enter element3:55
Enter element4:45
232
Previous Next
Download Download