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 #include conio h?
Explain low-order bytes.
What is the difference between #include and #include 'file' ?
int i=10; printf("%d %d %d", i, i=20, i);
Explain how to reverse singly link list.
What is a far pointer in c?
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
What is table lookup in c?
Under what circumstances does a name clash occur?
Can we change the value of #define in c?
Why void main is used in c?
FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above
1) write a program to generate 1st n fibonacci prime numbers using Nested if 2) write a program to generate twin prime numbers from m to n using nested if 3) write a program to check whether a given integer is a strong number or not using nested if 4) Write a program to generate prime factors of a given integer using nested if 5)write a program to generate prime numbers from m to n using nested if 6)write a program to generate perfect numbers from m to n using nested if 7)write a program to generate the pallindromes from m to n using neste if 8)write a program to generate armstrong numbers from m to n using nested if 9)write a program to generate strong numbers from m to n using nested if
Which is better malloc or calloc?
How to Throw some light on the splay trees?