Pages

Subtract two integer value entered by user

//Subtract two integer value entered by user


#include<stdio.h>
#include<conio.h>

void main()
{
  int num1,num2,subtract;   //declare a integer varaiable
  clrscr();   //clear the screen
  printf("Enter the first number of an integer:");  //Show the message to user
  scanf("%d",&num1);  //Store the value entered by user in variable num1.
  printf("Enter the second number of an integer:");  //Show the message to user
  scanf("%d",&num2);   //Store the value entered by user in variable num2.
  subtract=num1-num2;
  printf("Subraction:%d",subtract);   //Subtraction of two numbers
  printf("\nAlso show subtraction of two integer numbers in other way:");
  printf("\n%d - %d = %d",num1,num2,subtract);
  getch();   //Hold the screen for output
}

Output:

Enter the first number of an integer:56
Enter the second number of an integer:42
Subtraction:14
Also show subtraction of two integer numbers in other way:
56 - 42 = 14

No comments:

Post a Comment