Friday, July 26, 2019

To sum n different number using array.

#include<stdio.h>
#include<conio.h>
Void main()
     {
         int a[20] n,  s=0,i;
         printf("Enter the number of values you want to insert in an array (max. 20);
         scanf("%d",&n);
         for(i=0;i<n;i++)
         {
   printf("\n Enter the %d value /t");
   scanf("%d",&a[i]);
   }
         for(i=0;i<n;i++)
       {
          s=s+a[i];
   }
          printf("\n the sum of the entered value is %d",s);
   }
      getch();
}

No comments:

Post a Comment

To sum n different number using array.

#include<stdio.h> #include<conio.h> Void main()      {          int a[20] n,  s=0,i;          printf("Enter the numbe...