ALLInterview.com :: Home Page KalAajKal.com
 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                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   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
How to add two numbers with using function?
 Question Submitted By :: Tahir.faridi
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How to add two numbers with using function?
Answer
# 1
this has been demonstrated by a simple program.......

in C we ourselves can write a function for addition and
include wherver we want to add numbers.....

1) first write the function definition for the function u
are gonna write for addition....in a new file

int addition_arthmetic(int a, int b)
{
return(a+b);
}
2) dont run or compile this , directly save this file in .c
extension.. let us say "add.c".

3) then open a new file and write the program for addition
by getting the 2 i/p from the user...

#inclue<stdio.h>
#include<conio.h>
#include "add.c"  // we are including tthe file add.c"

void main()
{
int a,b,c;
printf("enter the values for a&b");
scanf("%d%d",&a,&b);
c=addition_arthmetic(a,b);// we call the function defined in
add.c
printf("\n\n the added value of a&b is :%d",c);
getch();
}

thank u
 
Is This Answer Correct ?    5 Yes 0 No
Vignesh1988i
 
  Re: How to add two numbers with using function?
Answer
# 2
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,i;
int sum=0;
clrscr();
printf("Enter Two Nos");
scanf("%d%d",&a,&b);
for(i=0;i<a;i++)
sum=sum+1;
for(i=0;i<b;i++)
sum=sum+1;
printf("Sum:%d",sum);
getch();
}
 
Is This Answer Correct ?    0 Yes 5 No
Sathish Kumar .k
 
 
 
  Re: How to add two numbers with using function?
Answer
# 3
#include<stdio.h>
#include<conio.h>
void main()
{
 int add(int,int);
 int a,b;
 clrscr();
 printf("Enter two numbers: ");
 scanf("%d %d",&a,&b);
 printf("The Sum is: %d",add(a,b));
 getch();
}
int add(int x,int y)
{
 return(x+y);
}
 
Is This Answer Correct ?    0 Yes 0 No
Anandi
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
what are the general concepts of c and c++  1
what is the difference between declaration ,defenetion and initialization of a variable? LG-Soft5
how to print a statement in c without use of console statement ,with the help of if statement it should print Satyam2
HOW TO FIND OUT THE RREVERS OF A GIVEN DIGIT NUMBER IF IT IS INPUT THROUGH THE KEYBORD BY USING C LANGUAGE  2
enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); } ME3
Write code for finding depth of tree Adobe1
program to find the ASCII value of a number  5
CopyBits(x,p,n,y) copy n LSBs from y to x starting LSB at 'p'th position. Adobe4
What is the most efficient way to count the number of bits which are set in a value?  3
Which is not valid in C? 1) class aClass{public:int x;} 2) /* A comment */ 3) char x=12;  5
what is memory leak?  3
Print the foll in C...eg when n=5 the o/p must b + + + + + + + + + + + + + + + + +  1
Difference between Class and Struct. Motorola6
what does exit() do? Cadence3
AMMONG THE 4 STROAGE CLASSES IN C, WHICH ONE FASTEST? HCL12
which one is highest Priority in c? a)=,b)+,c)++,d)==  3
read the folllowing code # define MAX 100 # define MIN 100 .... .... if(x>MAX) x=1; else if(x<MIN) x=-1; x=50; if the initial value of x=200,what is the vlaue after executing this code? a.200 b.1 c.-1 d.50 TCS2
pgm to reverse string using arrays i.e god is love becomes love is god) (assumption:only space is used for seperation of words) no addtional memory used.i.e no temporary arrays can used. Persistent4
what is y value of the code if input x=10 y=5; if (x==10) else if(x==9) elae y=8; a.9 b.8 c.6 d.7 TCS2
what is the advantage of function pointer TCS10
 
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 © 2007  ALLInterview.com.  All Rights Reserved.

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