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

main() { char p[] = "hello world!"; p = "vector"; printf("%s",p); }

2 Answers   Vector, Vector India,


What is the size of enum in c?

0 Answers  


What is C language Terminator?

15 Answers   TCS,


What is realloc in c?

0 Answers  


how memory store byte

4 Answers   Huawei,


main() { enum _tag{ left=10, right, front=100, back}; printf("%d, %d, %d, %d", left, right, front, back); }

1 Answers   Accenture, Vector,


write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)

26 Answers   ADITI, iFlex, Infosys, Oracle, TCS, Unicops, Wipro,


program to find a smallest number in an array

15 Answers   Microsoft, Sony,


What are high level languages like C and FORTRAN also known as?

0 Answers  


Write a program to check whether a number is prime or not using c?

0 Answers  


Explain the importance and use of each component of this string: Foo.Bar, Version=2.0.205.0, Culture=neutral, PublicKeyToken=593777ae2d274679d

1 Answers   TCS,


Write a C program to convert an integer into a binary string?

1 Answers  


Categories