Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new

 Categories  >>  Software  >>  Programming Languages  >>  C

 C Interview Questions C++ Interview Questions VC++ Interview Questions Delphi Interview Questions Programming Languages AllOther Interview Questions
Question
`write a 'c' program to sum the number of integer values`
Question Submitted By :: Abhi
I also faced this Question!!     Rank Answer Posted By

Re: write a 'c' program to sum the number of integer values
# 1
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 17 No
Durga Bhavani

Re: write a 'c' program to sum the number of integer values
# 2
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
Vignesh1988i

Re: write a 'c' program to sum the number of integer values
# 3
#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
Ruchi

Re: write a 'c' program to sum the number of integer values
# 4
#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
Koushik Sarkar

Re: write a 'c' program to sum the number of integer values
# 5
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
Neha Shree

Re: write a 'c' program to sum the number of integer values
# 6
#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
Arunkumar

Re: write a 'c' program to sum the number of integer values
# 7
#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
Chandra

Re: write a 'c' program to sum the number of integer values
# 8
void main()
{
int sum,a=6,b=3;
clrscr();
sum=a+b;
printf("%d",sum);
}
getch();
}

 Is This Answer Correct ? 3 Yes 0 No
Prince Rafi

  Question Asked @ Answers Other C Interview Questions input may any number except 1,output will always 1.. conditions only one variable should be declare,don't use operators,expressions,array,structure IBM 4 write a statement to display all the elements array M(in reverse order? int M[8]={20,21,22,23,24,25,26,27}; 5 To what value do nonglobal variables default? 1) auto 2) register 3) static 4 main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); } ME 3 what does ‘Bus Error’ mean? ABC 1 to get a line of text and count the number of vowels in it Satyam 2 in which language c language is written? 2 typedef struct { int i:8; char c:9; float f:20; }st_temp; int getdata(st_temp *stptr) { stptr->i = 99; return stptr->i; } main() { st_temp local; int i; local.c = 'v'; local.i = 9; local.f = 23.65; printf(" %d %c %f",local.i,local.c,local.f); i = getdata(&local); printf("\n %d",i); getch(); } why there there is an error during compiling the above program? 1 whenever a question is posted in a particular category in allinterview.com, Is there any facility to receive an indication mail. For eg: I need to receive an indication email, whenever a question is posted under the category “C Langauage”. 1 what is foreign key in c language? ADP 1 write a program which counts a product of array elements lower than 10. 1 void main() { for(; 0 ;) ... { printf("hello"); ... } getch(); } 1 For more C Interview Questions Click Here