dynamically allocate memory for linear array of n
integers,store some elements in it and find some of them



dynamically allocate memory for linear array of n integers,store some elements in it and find some ..

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

Post New Answer

More C Interview Questions

What's the difference between a linked list and an array?

14 Answers  


How can I insert or delete a line (or record) in the middle of a file?

0 Answers  


How does #define work?

0 Answers  


Is array name a pointer?

0 Answers  


difference of two no's with out using - operator

7 Answers  


What is header file definition?

0 Answers  


Read N characters in to an array . Use functions to do all problems and pass the address of array to function. 1. Print only the alphabets . If in upper case print in lower case vice versa.

1 Answers  


where are auto variables stored? What are the characteristics of an auto variable?

0 Answers  


Why the below program throughs error during compilation? #include<stdio.h> #include<conio.h> enum { ZERO, ONE, TWO, }; main() { printf("%d",&TWO); getch(); }

2 Answers  


output for following code??? main() { int x=2,y,z; x*=3+2; printf("1.%d\n",x); x*=y=z=4; printf("2.%d %d %d\n",x,y,z); x=y==z; printf("3.%d\n",x); x==(y=z); printf("%d",x); }

2 Answers   Elysium,


What is the use of bit field?

0 Answers  


what is the similarities between. system call and library function?

1 Answers   Wipro,


Categories