#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define MAX 15
void main()
{
int arr[MAX];
int i , num;
int sum=0;
clrscr();
printf("\nEnter no. of element that you want to insert :- ");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
printf("\nEnter value: ");
scanf("%d",&arr[i]);
}
for(i=0;i<num;i++)
{
sum=sum+arr[i];
}
printf("\n\nSum of your elements :- %d",sum);
getch();
}
#include<stdio.h>
#include<conio.h>
#define MAX 15
void main()
{
int arr[MAX];
int i , num;
int sum=0;
clrscr();
printf("\nEnter no. of element that you want to insert :- ");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
printf("\nEnter value: ");
scanf("%d",&arr[i]);
}
for(i=0;i<num;i++)
{
sum=sum+arr[i];
}
printf("\n\nSum of your elements :- %d",sum);
getch();
}
No comments:
Post a Comment