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
Explain main function in c?
Why main function is special give two reasons?
the question is that what you have been doing all these periods (one year gap)
What is equivalent to ++i+++j?
How do you search data in a data file using random access method?
How can I call a function with an argument list built up at run time?
Write a C program to help a HiFi’s Restaurant automate its breakfast billing system. Your assignment should implement the following items: a. Show the customer the different breakfast items offered by the HiFi’s Restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill to the customer. d. Produce a report to present your complete program and show more sample output. Assume that the HiFi’s Restaurant offers the following breakfast menu: Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast $2.95 Fruit Basket $3.45 Cereal $0.70 Coffee $1.50 Tea $1.80
What library is sizeof in c?
What are the 32 keywords in c?
What are the three constants used in c?
What are the different types of pointers used in c language?
How do we declare variables in c?
How to compare array with pointer in c?
Explain what is the most efficient way to store flag values?
I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...