saving . . . saved Difference between two Numbers has been deleted. Difference between two Numbers has been hidden .
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("\n Difference between %d and %d is = %d", a, b, diff);
    return 0;
}
BY
Shamraj Babu.T
ECE Department
IRTT 


C-and-Cpp Scope-Of-Variables 03-04 min 0-10 sec 06-12-21, 10:58 p.m. Sham_raj

Answers:

Dear User,

Please add semicolon(;) at the end of each scanf statement in this code.
10-01-22, 2:19 p.m. hbammkanti


#include <stdio.h>
int main(){
     int a,b,diff;
     printf("Enter first number: ");
     scanf("%d",&a);
     printf("Enter second number: ");
     scanf("%d",&b);
     if( a>=b ){
     printf("%d \n", diff=a-b);
}else{
printf("%d \n", diff=b-a);
}
    return 0;
}
04-03-23, 9:37 p.m. ni_t_ul8


#include <stdio.h>
int main(){
     int a,b,diff;
     printf("Enter first number: ");
     scanf("%d",&a);
     printf("Enter second number: ");
     scanf("%d",&b);
     if( a>=b ){
     printf("%d \n", diff=a-b);
}else{
printf("%d \n", diff=b-a);
}
    return 0;
}
12-08-24, 2:52 p.m. 238T1A05D3


#include <stdio.h>
int main(){
     int a,b,diff;
     printf("Enter first number: ");
     scanf("%d",&a);
     printf("Enter second number: ");
     scanf("%d",&b);
     if( a>=b ){
     printf("%d \n", diff=a-b);
}else{
printf("%d \n", diff=b-a);
}
    return 0;
}
16-08-24, 4:40 p.m. 238T1A05F5


#include <stdio.h>
int main(){
     int a,b,diff;
     printf("Enter first number: ");
     scanf("%d",&a);
     printf("Enter second number: ");
     scanf("%d",&b);
     if( a>=b ){
     printf("%d \n", diff=a-b);
}else{
printf("%d \n", diff=b-a);
}
    return 0;
}
19-08-24, 2:44 p.m. nasreensk2005@gmail.com


Log-in to answer to this question.