In this we are going to see the Functions that have no Arguments and no Return Value, in this program we will perform Arithmetic Operations using C programming language.
// Program to perform Arithmetic Operations using functions - Type 1
#include <stdio.h>
void add()
{
int a, b;
printf("Enter two numbers:\n");
scanf("%d\n %d", &a, &b);
printf("Additon is: %d", a + b);
}
void sub()
{
int a, b;
printf("Enter two numbers: \n");
scanf("%d\n %d", &a, &b);
printf("subtraction is: %d", a - b);
}
void mul()
{
float a, b;
printf("Enter two numbers: \n");
scanf("%f\n %f", &a, &b);
printf("Multiplication is: %f", a * b);
}
void div()
{
float a, b;
printf("Enter 2 numbers: \n");
scanf("%f\n%f", &a, &b);
printf("Division is: %f", a / b);
}
void main()
{
int operation;
printf("-----Select the Operation------\n");
printf("1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n");
printf("Enter the corresponding number of Operation: ");
scanf("%d", &operation);
switch (operation)
{
case 1:
add();
break;
case 2:
sub();
break;
case 3:
mul();
break;
case 4:
div();
break;
default:
printf("Wrong input");
}
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP