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

Answers were Sorted based on User's Feedback



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

Answer / durga bhavani

void main()
{
int a[25],n,i,sum=0;
printf("enter n value");
scanf("%d",&n);
printf("\n Enter the numbers");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
sum+=a[i];
printf("\nSum of the given numbers is %d",sum);
}

Is This Answer Correct ?    39 Yes 18 No

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

Answer / chandra

#include<stdio.h>
#include<conio.h>
main()
{
int a[25],n,i,sum=0;
printf("enter n value");
scanf("%d",&n);
printf("\n Enter the numbers");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
sum+=a[i];
printf("\nSum of the given numbers is %d",sum);
}

Is This Answer Correct ?    11 Yes 5 No

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

Answer / prince rafi

void main()
{
int sum,a=6,b=3;
clrscr();
sum=a+b;
printf("%d",sum);
}
getch();
}

Is This Answer Correct ?    3 Yes 0 No

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

Answer / koushik sarkar

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter a integer no:-"); scanf("%d",&a);
printf("Enter a Integer no:-"); scanf("%d",&b);
printf("Sum= %d",a+b);
getch();
}

Is This Answer Correct ?    13 Yes 12 No

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

Answer / arunkumar

#include<stdio.h>
#include<conio.h>

fun(int n);
int main()
{
int n=10;
printf("%d",fun(10));
}
fun(int n)
{
if(n<1)
return n;
else
return (n+fun(n-1));
}

Is This Answer Correct ?    5 Yes 7 No

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

Answer / neha shree

void main()
{
int a,n,i,sum=0;
printf("enter n value");
scanf("%d",&n);
printf("\n Enter the numbers");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
sum+=a[i];
printf("\nSum of the given numbers is %d",sum);
}

Is This Answer Correct ?    9 Yes 12 No

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

Answer / 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

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

Answer / ruchi

#include<stdio.h>
#include<conio.h>
int main()
{
int n,m,m1,s=0,d,sum;
printf("\nEnter the number ");
scanf("%d",&n);
m=n%10;
d=n/10;
while(d>=10)
{
m1=d%10;
d=d/10;
s =s+m1;
}
sum=s+m+d;
printf("\nSum is %d",sum);
getch();
}

Is This Answer Correct ?    4 Yes 15 No

Post New Answer

More C Interview Questions

what do you mean by defining a variable in our c code?

2 Answers  


what is the difference between malloc() and calloc() function?

1 Answers  


Differentiate between full, complete & perfect binary trees.

0 Answers  


What is the size of a union variable?

0 Answers  


progrem to generate the following series 1 12 123 1234 12345

6 Answers   HCL, Wipro,


what is data structure?

5 Answers   CBSE,


stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.

0 Answers  


what is the difference between c and java?

1 Answers  


what is the height of tree if leaf node is at level 3. please explain

0 Answers  


#include <stdio.h> int main() { if ("X" <"x") printf("X smaller than x "); } my question is whats the mistake in this program? find it and please tell me..

3 Answers  


Is there any restriction in how many arguments printf or scanf function can take? in which file in my c++ compiler i can see the code for implementation of these two functions??

4 Answers  


In which category does main function belong??

5 Answers  


Categories