write a 'c' program to sum the number of integer values

Answer Posted / vignesh1988i

here the program uses dynamic memory allocation concept instead of arraya......


#include<stdio.h>
#include<conio.h>
void main()
{
int *pointer,n,sum=0;
clrscr();
printf("enter no. of elements :");
scanf("%d",&n);
pointer=(int*)malloc(n*sizeof(int));
for(int i=0;i<n;i++)
{
scanf("%d",(pointer+i));
sum=sum+(*(pointer+i));
}
printf("the sum is :%d",sum);
getch();
}


thank u

Is This Answer Correct ?    11 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between exit() and _exit() function?

779


Explain how to reverse singly link list.

801


How do c compilers work?

787


Explain what is the difference between far and near ?

842


What is New modifiers?

871


How can I trap or ignore keyboard interrupts like control-c?

806


Why do we use static in c?

809


Can you apply link and association interchangeably?

883


Do variables need to be initialized?

800


Can we use visual studio for c?

757


write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a

1645


What is the difference between declaring a variable by constant keyword and #define ing that variable?

2991


What is a lookup table in c?

810


List some applications of c programming language?

726


what are the facialities provided by you after the selection of the student.

1909