{18.10.05} Mim-sem1-l09-21-add_sub_mul_div Using Function.pdf

  • Uploaded by: Saurabh
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View {18.10.05} Mim-sem1-l09-21-add_sub_mul_div Using Function.pdf as PDF for free.

More details

  • Words: 229
  • Pages: 3
P02: PROGRAM TO PRINT SUM OF TWO FUNCTIONS USING FUNCTIONS

#include <stdio.h> // Function Definition void add() { int i,j; printf("Enter 2 Numbers\n"); scanf("%d%d",&i,&j); printf("The sum of %d and %d is %d.",i,j,i+j); } void sub() { int i,j; printf("Enter 2 Numbers\n"); scanf("%d%d",&i,&j); printf("The sum of %d and %d is %d.",i,j,i-j); } void mul() { int i,j; printf("Enter 2 Numbers\n"); scanf("%d%d",&i,&j); printf("The sum of %d and %d is %d.",i,j,i*j); } int main() { int i; printf("Enter \nOption 1: Addition\nOption 2: Subtraction\nOption 3: Multiplication\n"); scanf("%d",&i); switch(i) { case 1: add();break; case 2: sub();break; case 3: mul();break; } return 0; }

P03: PROGRAM TO DO OPERATION ON TWO NUMBERS USING FUNCTIONS

#include <stdio.h> // Function Definition // Parameters : i,j int add(int i, int j) { // Return Variable return (i+j); } int sub(int i, int j) { return (i-j); } int mul(int i, int j) { return (i*j); } int division(int i, int j) { return (i/j); } int main() { int a,b,o,r; printf("Enter Two Numbers:\n"); scanf("%d%d",&a,&b); printf("Enter \nOption 1: Addition\nOption 2: Subtraction\nOption 3: Multiplication\nOption 4: Division\n"); scanf("%d",&o); switch(o) { case 1: r=add(a,b); printf("Sum of %d and %d = %d",a,b,r); break; case 2: r=sub(a,b);

printf("Difference of %d and %d = %d",a,b,r); break; case 3: r=mul(a,b); printf("Multiplication of %d and %d = %d",a,b,r); break; case 4: r=division(a,b); printf("Division of %d and %d = %d",a,b,r); break; default: printf("Invalid Option."); } return 0; }

Related Documents

Using Emergence
December 2019 31
Using Brochures
June 2020 11
Using Cmm
May 2020 17
Using Suffixes
October 2019 27
Rtpcr Using
July 2020 13

More Documents from ""