dynamically allocate memory for linear array of n
integers,store some elements in it and find some of them
Answer / 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 |
Explain high-order and low-order bytes.
Why is #define used?
Why does everyone say not to use gets?
What is a memory leak in structures? How can we rectify that?
Who is the founder of c language?
What are the average number of comparisons required to sort 3 elements?
What is double pointer in c?
What is the significance of c program algorithms?
Explain what are global variables and explain how do you declare them?
wat are the two methods for swapping two numbers without using temp variable??
Can you write the function prototype, definition and mention the other requirements.
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }