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
What is a stream?
What are the two types of functions in c?
What is bash c?
How can I change the size of the dynamically allocated array?
Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
Explain the use of #pragma exit?
What are formal parameters?
How can this be legal c?
Differentiate Source Codes from Object Codes
Can a file other than a .h file be included with #include?
What is a program flowchart and how does it help in writing a program?
What is c language in simple words?
What is a buffer in c?
What is 2 d array in c?
Tell me when is a void pointer used?