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


Please Help Members By Posting Answers For Below Questions

write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?

1672


int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer

649


Write a program to print “hello world” without using semicolon?

669


show how link list can be used to repersent the following polynomial i) 5x+2

1676


write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.

14956






List the difference between a 'copy constructor' and a 'assignment operator' in C?

637


Write a progarm to find the length of string using switch case?

1607


What is ambagious result in C? explain with an example.

2052


What is signed and unsigned?

638


Explain what are compound statements?

602


Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.

699


A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor

620


Differentiate between calloc and malloc.

752


What is array within structure?

581


What is the basic structure of c?

553