Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


How to add two numbers with using function?

Answers were Sorted based on User's Feedback



How to add two numbers with using function? ..

Answer / anandi

#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 ?    42 Yes 14 No

How to add two numbers with using function? ..

Answer / balaji

/*this program is used to add two numbers using functions */
#include<stdio.h>
#include<conio.h>
void add(int,int);
void main()
{
int x,y;
printf("enter the two digits/numbers which you want to add");
scanf("%d%d",&x,&y);
add(x,y);
getch();
}
void add(int a,int b)
{
int c;
c=a+b;
printf("the sum of %d and %d is %d",a,b,c);
}

Is This Answer Correct ?    5 Yes 3 No

How to add two numbers with using function? ..

Answer / sathish kumar .k

#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 ?    18 Yes 26 No

How to add two numbers with using function? ..

Answer / vignesh1988i

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 ?    13 Yes 24 No

Post New Answer



More C Interview Questions

1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

3 Answers  


sum of two integers values only other then integer it should print invalid input.

1 Answers  


WHAT IS ABSTRACT DATA TYPE

4 Answers   Wipro,


a program that performs some preliminary processing in C, it acts upon certain directives that will affect how the compiler does its work a) compiler b) loader c) directive d) preprocessor

0 Answers  


why we shiuld use main keyword in C

5 Answers  






What is the purpose of ftell?

0 Answers  


control 50 devices which has 2 states on and off.using bitwise operator.plz answer it its urgent

1 Answers  


please explain every phase in the "SDLC" in the dotnet.

0 Answers  


What are the advantages of using new operator as compared to the function malloc ()?

0 Answers   NIIT,


How many header files are in c?

0 Answers  


What is the difference between malloc() and calloc()?

0 Answers  


Why calloc is better than malloc?

0 Answers  






Categories