Saturday, 28 April 2012

Add n numbers

                         
                                  This c system add n statistics which will be joined by the individual. First of all individual will get into a variety showing how many statistics individual desires to add and then individual will get into n statistics. In our c system to add statistics we are not using an array, if you wish you can use an array.


#include<stdio.h>
#include<conio.h>

void main()
{
   int n, sum = 0, c, var;

   printf("Enter the number of integers you want to add\n");
   scanf("%d",&n);

   printf("Enter %d numbers\n",n);

   for ( c = 1 ; c <= n ; c++ )
   {
      scanf("%d",&var);
      sum = sum + var;
   }

   printf("Sum of Enter number = %d\n",sum);

   getch();
}

No comments:

Post a Comment