dynamically allocate memory for linear array of n
integers,store some elements in it and find some of them
Answer Posted / vignesh1988i
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
void main()
{
int *pointer,m,sum=0;
printf("enter the no. of elemrnts going to be entered :");
scanf("%d",&m);
pointer=(int*)malloc(m*sizeof(int));
for(int i=0;i<m;i++)
scanf("%d",(pointer+i));
for(i=0;i<m;i++)
sum=sum+(*(pointer+i));
for(i=0;i<m;i++)
printf("\n%d",sum);
getch();
}
thank u
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
The file stdio.h, what does it contain?
Explain what are binary trees?
Why main is used in c?
How can I find the modification date of a file?
What is a list in c?
What are the uses of a pointer?
What type of function is main ()?
What is assert and when would I use it?
What is pointer to pointer in c language?
When should the register modifier be used? Does it really help?
In C language, a variable name cannot contain?
What is character constants?
What is a double c?
What is static volatile in c?
What are c identifiers?