Friday 8 February 2019

Filled Under:

Program To Find The Sum Of The Given n Integers Using An Array[c programming examples with output]

Write A Program To Find The Sum Of The Given n Integers Using An Array

/*Program To Find Sum Of n Integers*/
#include<stdio.h>
#include<conio.h>
main()
{
    int x[50],n,i,sum;
    clrscr();
    printf("\n How many integers??");
    scanf("%d",&n);
        /*loop to read N integers*/
         f or(i=0;i<n;i++)
   {
       printf("\n Enter the %dth value: ",i+1);
       scanf("%d",&x[i]);
   }
   sum=0;
      /*loop to find sum of all integers*/
         for(i=0;i<n;i++)
       sum=sum=sum+x[i];
       printf("\nSum of all integers=%d",sum);
       getch();
}

OutPut:
How many integers??5
Enter the 1th value: 36
Enter the 2th value: 45
Enter the 3th value: 52
Enter the 4th value: 40
Enter the 5th value: 61
Sum of all integers=234

                                                   
                                         Best Budget Laptop For Web Developers 2019
Best Budget For Programmers: https://amzn.to/32GkrqC

0 komentar:

Post a Comment