EmbLogic's Blog

a simple program to add ‘n’ numbers…

1 #include<stdio.h>
2 int main()
3 {
4  int num[100],sum=0,n,i,ret;
5  printf(“enter the number of values u want 2 add\n”);
6  scanf(“%d”,&n);
7  printf(“enter the values\n”);
8  for(i=0;i<n;i++)
9   {
0   scanf(“%d”,&num[i]);
1   sum=sum+num[i];
2   }
3   printf(“sum=%d\n”,sum);
4   ret = printf(“sum=%d\n”,sum);
5   printf(“ret=%d\n”,ret);
6   return 0;
7
8  }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>