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
How can I recover the file name given an open stream or file descriptor?
What are volatile variables in c?
Explain what does the format %10.2 mean when included in a printf statement?
hi any body pls give me company name interview conduct "c" language only
write a c program in such a way that if we enter the today date the output should be next day's date.
What does void main () mean?
what is a constant pointer in C
Tell me what are bitwise shift operators?
What is the best way of making my program efficient?
What are the advantages of using new operator as compared to the function malloc ()?
Explain how can I right-justify a string?
Explain what is the benefit of using enum to declare a constant?
i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical
How can I open a file so that other programs can update it at the same time?
List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.