Monday 13 January 2014

Program of single dimension ARRAY in c.

     /* program to print the sum of element store in array*/
#include<stdio.h>
void main()
{
int x[5],i,s=0;
for(i=0; i<5; ++i)
{
printf("enter the five number");
scanf("%d",x[i]);
s=s+x[i];
}
printf("sum =%d",s);
}



     /* program to print the greater number among the array*/
#include<stdio.h>
main()
{
int n[10],i,g=0;
for(i=0;i<10;++i)
{
printf("enter the ten number in th array");
scanf("%d",&n[i]);
if(g<n[i])
g=n[i];
}
printf("greater number is =%d",g);
}

No comments:

Post a Comment