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
Keerthi vennila S
Ece department
Irtt


C-and-Cpp Scope-Of-Variables 05-06 min 40-50 sec 06-12-21, 11:09 p.m. Keerthi19

Answers:

Enter first number:5
Enter second number:10
Difference between 5 and 10 is=5

10-12-21, 11:31 a.m. hariharan110702@gmail.com


<font size="4">Program in c to print the difference of two numbers:</font>

#include <stdio.h>

int a=7;
int b=5;
void difference()
{
    int sub;
    sub = a - b;
    printf("Difference of a and b is %d\n",sub);
}
int main()
{
    difference();
    return 0;
}

Output:

Difference of a and b is 2

Program in cpp to print the difference of two numbers:

#include <iostream>
using namespace std;
int a=7;
int b=5;
void difference()
{
    int sub;
    sub = a - b;
    cout<<"Difference of a and b is "<<sub <<"\n";
}
int main()
{
    difference();
    return 0;
}

Output:

Difference of a and b is 2
24-01-24, 1:15 p.m. Vaishnavi2885


Log-in to answer to this question.