KEMBAR78
Experiment 3 | PDF | Teaching Methods & Materials | Computers
0% found this document useful (0 votes)
23 views2 pages

Experiment 3

Uploaded by

sayyedzuber5anas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

Experiment 3

Uploaded by

sayyedzuber5anas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment -3

Aim: Basic Examples for performing different c operations using operator with scanf
function.

Program :
/**
* C program to perform all arithmetic operations
*/

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

void main()
{
int num1, num2;
int sum, sub, mult, mod;
float div;

/*
* Input two numbers from user
*/
printf("Enter any two numbers: ");
scanf("%d%d", &num1, &num2);

/*
* Perform all arithmetic operations
*/
sum = num1 + num2;
sub = num1 - num2;
mult = num1 * num2;
div = (float)num1 / num2; //typecasting
mod = num1 % num2;

/*
* Print result of all arithmetic operations
*/
printf("SUM = %d\n", sum);
printf("DIFFERENCE = %d\n", sub);
printf("PRODUCT = %d\n", mult);
printf("QUOTIENT = %f\n", div);
printf("MODULUS = %d", mod);

getch();
}
Output:

Enter any two numbers : 20 10

SUM = 30

DIFFERENCE = 10

PRODUCT = 200

QUOTIENT = 2.000000

MODULUS = 0

Conclusion: Hence We have studied basic operations on two numbers using scanf
function .

You might also like