Wednesday, 11 January 2012

Write a c program to find sum of N integers

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

void main()
{
    int a[10],i,n,sum=0;
    clrscr();
    printf("How many you want to insert ?\n");
    scanf("%d",&n);
    printf("Enter the numbers::\n");
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        sum=sum+a[i];
    }
    printf("The Sum is=%d",sum);
    getch();
}

No comments:

Post a Comment