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
what is bit rate & baud rate? plz give wave forms
What is the value of uninitialized variable in c?
What is malloc and calloc?
printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions
What is || operator and how does it function in a program?
List some basic data types in c?
What is logical error?
What is the difference between abs() and fabs() functions?
Is there a way to compare two structure variables?
What is the purpose of realloc()?
What is the difference between declaring a variable and defining a variable?
what is use of malloc and calloc?
Suggesting that there can be 62 seconds in a minute?
What is meant by 'bit masking'?
Explain what are multibyte characters?