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
Can the “if” function be used in comparing strings?
What does double pointer mean in c?
hi any body pls give me company name interview conduct "c" language only
Is c# a good language?
What are the types of unary operators?
What is the use of putchar function?
Explain union.
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
What does nil mean in c?
Explain what is the use of a semicolon (;) at the end of every program statement?
Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)
Can a variable be both constant and volatile?
Write a program to swap two numbers without using third variable in c?
What is queue in c?
Explain do array subscripts always start with zero?