C program to print sum of N numbers in an array
In this tutorial we will solve a problem that find or print the sum of N numbers in an array.
Here we will write a c program source code to print sum of N numbers.
This program will accept the range or size of an array that entered by user through the keyboard.
After it we will enter the elements of this array.
After these steps compiler check and execute the conditions and print the sum.
C PROGRAM CODE
#include<stdio.h>
#include<conio.h>
void main()
{
int x,sum=0,size;
int array[50];
clrscr();
printf("\n ENTER THE SIZE OF THIS ARRAY:\n ");
scanf("%d",&size);
printf("\n ENTER THE ELEMENTS OF THIS ARRAY:\n ");
for(x=0;x<size;x++)
{
scanf("%d",&array[x]);
sum=sum+array[x];
}
printf("\n SUM OF ALL ELEMENTS IN THIS ARRAY:\n %d\n",sum);
getch();
}
OUTPUT:
Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com
Created by-- HARSH CHAUHAN
No comments:
Post a Comment