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 are the 4 types of functions?
Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)
What is pass by reference in functions?
What is getch?
Is main is user defined function?
What is the stack in c?
What is adt in c programming?
What is the auto keyword good for?
When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.
What is the use of c language in real life?
Write a Program to find whether the given number or string is palindrome.
Write a program to print factorial of given number using recursion?
show how link list can be used to repersent the following polynomial i) 5x+2
How can you increase the size of a dynamically allocated array?
How is null defined in c?