Difference between two numbers
Title
Question
#include <stdio.h>
int main()
{
int a,b;
int diff;
printf("Enter first number: ");
scanf("%d",&a);
printf("Enter second number: ");
scanf("%d",&b);
if( a>b)
diff=a-b;
else
diff=b-a;
printf("\nDifference between %d and %d
is = %d", a,b,diff);
return 0;
}
By
M. Bala priyadharshini
ECE department
IRTT
C-and-Cpp Scope-Of-Variables 04-05 min 50-60 sec
Answers:
Assignments are only for self-assessment. If you have any specific question related to this tutorial please post here.
#include <stdio.h>
int main()
{
int a,b;
int diff;
printf("Enter first number: ");
scanf("%d",&a);
printf("Enter second number: ");
scanf("%d",&b);
if( a>b)
diff=a-b;
else
diff=b-a;
printf("\nDifference between %d and %d is = %d", a,b,diff);
return 0;
}
#include <stdio.h>
int main()
{
int a,b;
int diff;
printf("Enter first number: ");
scanf("%d",&a);
printf("Enter second number: ");
scanf("%d",&b);
if( a>b)
diff=a-b;
else
diff=b-a;
printf("\nDifference between %d and %d is = %d", a,b,diff);
return 0;
}
#include <stdio.h>
int main()
{
int a,b;
int diff;
printf("Enter first number: ");
scanf("%d",&a);
printf("Enter second number: ");
scanf("%d",&b);
if( a>b)
diff=a-b;
else
diff=b-a;
printf("\nDifference between %d and %d is = %d", a,b,diff);
return 0;
}
Login to add comment