Subtraction of Two Integers in C Language

 Subtraction of Two Integers in C Language



// C program to perform subtraction of two integers
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
// clrscr();
printf("Enter two numbers:\n");
scanf("%d%d",&a,&b);
c=a-b;
printf("Output\n");
printf("The subtraction of two numbers is:%d\n",c);
printf("End of program");
}

Enter two numbers:

20 20

Output

The subtraction of two numbers is:0

End of program





// C program to perform subtraction of two integers

#include<stdio.h>

void main()

{

    int a;

    int b;

    int sub;

    printf("\t\t\t\t** INPUT **\n");

    printf("Enter first number\n");

    scanf("%d", &a);

    printf("Enter second number\n");

    scanf("%d",&b);

    sub=a-b;

    printf("\t\t\t\t\t\t*** OUTPUT of Program ***\n");

    printf("The subtraction of two integers is:%d\t",sub);

    printf("\nEnd of program");

}

 

** INPUT **

Enter first number

100

Enter second number

200

*** OUTPUT of Program ***

The subtraction of two integers is:- 100    

End of program

 


// C program to perform subtraction of two integers
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
// clrscr();
printf("Enter two numbers:\n");
scanf("%d%d",&a,&b);
printf("Output\n");
printf("The subtraction of two numbers is:%d\n", a-b);
printf("End of program");
}

Enter two numbers:

20 20

Output

The subtraction of two numbers is:0

End of program


In above program the subtraction operation is performed on a and b variables. The subtraction result is not stored in any other variable. The subtraction operation is directly performed in printf() function and result is displayed.

टिप्पणी पोस्ट करा

0 टिप्पण्या