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

Difference between Class and Struct.

13 Answers   Ericsson, Motorola, Wipro,


Explain why c is faster than c++?

0 Answers  


How can you tell whether a program was compiled using c versus c++?

0 Answers  


What is the difference between macros and inline functions?

5 Answers   Global Edge, L&T,


What is advantage of pointer in c?

0 Answers  






What is the use of gets and puts?

0 Answers  


What is the best way to store flag values in a program?

0 Answers  


Where is volatile variable stored?

0 Answers  


write a program of palindrome(madam=madam) using pointer?

5 Answers   L&T,


How to receive strings with spaces in scanf()

7 Answers  


What is difference between stdio h and conio h?

0 Answers  


sum of two integers values only other then integer it should print invalid input.

1 Answers  


Categories