Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a 'c' program to sum the number of integer values

Answer Posted / vignesh1988i

here the program uses dynamic memory allocation concept instead of arraya......


#include<stdio.h>
#include<conio.h>
void main()
{
int *pointer,n,sum=0;
clrscr();
printf("enter no. of elements :");
scanf("%d",&n);
pointer=(int*)malloc(n*sizeof(int));
for(int i=0;i<n;i++)
{
scanf("%d",(pointer+i));
sum=sum+(*(pointer+i));
}
printf("the sum is :%d",sum);
getch();
}


thank u

Is This Answer Correct ?    11 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I recover the file name given an open stream or file descriptor?

1030


What are volatile variables in c?

889


Explain what does the format %10.2 mean when included in a printf statement?

1290


hi any body pls give me company name interview conduct "c" language only

2231


write a c program in such a way that if we enter the today date the output should be next day's date.

2137


What does void main () mean?

1179


what is a constant pointer in C

1095


Tell me what are bitwise shift operators?

1091


What is the best way of making my program efficient?

962


What are the advantages of using new operator as compared to the function malloc ()?

1269


Explain how can I right-justify a string?

992


Explain what is the benefit of using enum to declare a constant?

1020


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

2276


How can I open a file so that other programs can update it at the same time?

1132


List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.

2688