Saturday 1 November 2014
Write a program to accept 10 numbers and display its sum using pointer.
Write a program to accept 10 numbers and display its sum using pointer.
PRO-20:
#include<stdio.h>
#include<conio.h>
void main()
{ int
i,n,j,sum=0;
int
*ptr;
clrscr();
printf("\nEnter
Limit : ");
scanf("%d",&n);
printf(“\nEnter elements :\n”)
for(i=0;i<n;i++)
{ scanf("%d",ptr);
sum+=*ptr;
ptr++;
}
printf("\n
Sum = %d",sum);
getch();
}
OUTPUT:
Enter Limit : 3
Enter elements :
15
12
15
Sum = 42
|
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment