Q. – Write a C program to find the subtraction of given two numbers.
Ans:- Two numbers, says a and b, are given (input) and the result sub = a-b of two numbers are to be calculated.
/* Arithmetic Operators Subtraction */
#include <stdio.h>
main()
{
int a, b, sub;
scanf("%d %d", &a, &b);
sub = a-b;
printf("%d", sub);
return 0;
}
User Friendly Program
/* Arithmetic Operators Subtraction – User friendly program */
#include<stdio.h>
main()
{
int a, b, sub;
printf("\n Enter Value to A: ");
scanf("%d", &a);
printf("\n Enter Value to B: ");
scanf("%d", &b);
sub = a-b;
printf("\n Subtract = %d", sub);
return 0;
}
No comments