Write a program to add,subtract,multiply and divide two integer using user-defined type function with return type


Answer:

#include <stdio.h>
//function declaration
int add(int a,int b);
int subtract(int a,int b);
int multiply(int a,int b);
int divide(int a,int b);
//main function
int main()
{
int a,b;
printf("Enter integer a\n");
scanf("%d",&a);
printf("Enter integer b\n");
scanf("%d",&b);
printf("add is %d\n",add(a,b));
printf("subtract is %d\n",subtract(a,b));
printf("multiply is %d\n",multiply(a,b));
printf("divide is %d\n",divide(a,b));
return 0;
}
//function call to add
int add(int a,int b)
{
int result;
result=( a+ b);
return result;
}
//function call to subtract
int subtract(int a,int b)
{
int result;
result=(a-b);
return result;
}
//function to multily
int multiply(int a,int b)
{
int result;
result=(a*b);
return result;
}
//function to divide
int divide(int a,int b)
{
int result;
result=(a/b);
return result;
}


Share To Friends Via:
        






More Questions For Programming in C:



  What are the types of errors that occur in C program? (Answered)
What are the types of errors that occur in C program? .
Posted On:Sat 13, March 2021 10:32:24 am
  Which level is C language belonging to? (Answered)
Which level is C language belonging to? .
Posted On:Sat 13, March 2021 10:35:35 am
  What is the difference between C and C++? (Answered)
What is the difference between C and C++? .
Posted On:Sat 13, March 2021 10:36:55 am
  Who developed C language? (Answered)
Who developed C language? .
Posted On:Sat 13, March 2021 10:38:43 am
  C language has been developed in which language? (Answered)
C language has been developed in which language? .
Posted On:Sat 13, March 2021 10:40:38 am
  Is C a structured programming language? (Answered)
Is C a structured programming language? .
Posted On:Sat 13, March 2021 10:42:58 am
  What is structured programming? (Answered)
What is structured programming? .
Posted On:Sat 13, March 2021 10:43:41 am
  What is meant by programming language? (Answered)
What is meant by programming language? .
Posted On:Sat 13, March 2021 10:45:05 am
  What is the difference between C and Java? (Answered)
What is the difference between C and Java? .
Posted On:Sat 13, March 2021 10:48:01 am
  State Whether C language is low level language, or middle level language? (Answered)
State Whether C language is low level language, or middle level language? .
Posted On:Sat 13, March 2021 10:49:17 am
  What is modular programming? (Answered)
What is modular programming? .
Posted On:Sat 13, March 2021 10:51:49 am
  Is C language case sensitive? (Answered)
Is C language case sensitive? .
Posted On:Sat 13, March 2021 10:52:38 am
  What is data type in C? (Answered)
What is data type in C? .
Posted On:Sat 13, March 2021 10:53:51 am
  What is the difference between interpreter and compiler? (Answered)
What is the difference between interpreter and compiler? .
Posted On:Sat 13, March 2021 10:56:44 am
  What is the difference between declaration and definition of a variable? (Answered)
What is the difference between declaration and definition of a variable? .
Posted On:Sat 13, March 2021 10:57:38 am
  What is a program flowchart? (Answered)
What is a program flowchart? .
Posted On:Sat 13, March 2021 11:00:32 am
  What is the syntax for comments in C? (Answered)
What is the syntax for comments in C? .
Posted On:Sat 13, March 2021 11:03:14 am
  List out some of C compilers? (Answered)
List out some of C compilers? .
Posted On:Sat 13, March 2021 11:04:10 am
  What is the difference between exit() and return() in C? (Answered)
What is the difference between exit() and return() in C? .
Posted On:Sat 13, March 2021 11:05:18 am
  What is the difference between calloc and malloc? (Answered)
What is the difference between calloc and malloc? .
Posted On:Sat 13, March 2021 11:07:06 am
  What are the different types of modifiers in C? (Answered)
What are the different types of modifiers in C? .
Posted On:Sat 13, March 2021 11:09:20 am
  What is a constant in C? (Answered)
What is a constant in C? .
Posted On:Sat 13, March 2021 11:10:14 am
  What are the types of constants in C? (Answered)
What are the types of constants in C? .
Posted On:Sat 13, March 2021 11:11:03 am
  What are dangling pointers in C? (Answered)
What are dangling pointers in C? .
Posted On:Sat 13, March 2021 11:11:51 am
  What is the difference between rand(), random(), and randomize()? (Answered)
What is the difference between rand(), random(), and randomize()? .
Posted On:Sat 13, March 2021 11:14:32 am
  What is bebugging? (Answered)
What is bebugging? .
Posted On:Sat 13, March 2021 11:15:50 am
  What is a compiler? (Answered)
What is a compiler? .
Posted On:Sat 13, March 2021 11:18:24 am
  What are all decisions control statements in C? (Answered)
What are all decisions control statements in C? .
Posted On:Sat 13, March 2021 11:20:02 am
  What is mean by debugging? (Answered)
What is mean by debugging? .
Posted On:Sat 13, March 2021 11:22:17 am
  What is static function in C? (Answered)
What is static function in C? .
Posted On:Sat 13, March 2021 11:25:27 am

More Questions Categories:


About Us

Contact us

Terms of use | Privacy policy

Follow Us:               

All Rights Reserved © 2024; pscustudies.com