ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
   
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther 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
Answer
# 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 ?    38 Yes 17 No
Durga Bhavani
 
  Re: write a 'c' program to sum the number of integer values
Answer
# 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 ?    10 Yes 17 No
Vignesh1988i
 
 
 
  Re: write a 'c' program to sum the number of integer values
Answer
# 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 ?    3 Yes 15 No
Ruchi
 
  Re: write a 'c' program to sum the number of integer values
Answer
# 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 ?    12 Yes 12 No
Koushik Sarkar
 
  Re: write a 'c' program to sum the number of integer values
Answer
# 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 ?    8 Yes 12 No
Neha Shree
 
  Re: write a 'c' program to sum the number of integer values
Answer
# 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 ?    4 Yes 7 No
Arunkumar
 
  Re: write a 'c' program to sum the number of integer values
Answer
# 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 ?    10 Yes 5 No
Chandra
 
  Re: write a 'c' program to sum the number of integer values
Answer
# 8
void main()
{
int sum,a=6,b=3;
clrscr();
sum=a+b;
printf("%d",sum);
}
getch();
}
 
Is This Answer Correct ?    2 Yes 0 No
Prince Rafi
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
What is diffrance between declaration and defination of a variable or function  4
What are bit fields? What is their use? Adobe2
define function Assurgent4
What is 'makefile' in C langauage? How it be useful? How to write a makefile to a particular program?  2
program to find which character is occured more times in a string and how many times it has occured? for example in the sentence "i love india" the output should be i & 3.  3
main() { int a=5; printf(?%d,%d,%d\n?,a,a< <2,a>>2); } Answer: 5,20,1 please explain this code in detail TCS6
convert 0.9375 to binary CTS2
what is c programming? TCS3
SIR PLS TELL ME THE CODE IN C LANGUAGE TO PRINT THE FOLLOWING SERIES 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 1 2 3 2 1 1 2 1 1  4
what are the stages of compilation Bosch1
Derive the complexity expression for AVL tree?  1
what is a far pointer TCS12
 
For more C Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2012  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com