Technology has advanced to the point where programming has become an essential part of our lives. We use software and applications for communication, entertainment, education, and work, and these are all built on programming languages.

Program 3: Show addition, Subtraction, Multiplication, Division and Remainder of any two numbers

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a=6;
int b=5;
int c,d,e,f;
c=a+b;
d=a-b;
e=a*b;
f=a/b;
g=a%b;
printf("addition=%d",c);
printf("\nsubtraction=%d",d);
printf("\nmultiplication=%d",e);
printf("\ndivision=%d",f);
printf("\nremainder=%d",g);
getch();
}

Output
addition=11
subtraction=1
multiplication=30
division=1
remainder=1

Explanation
Here two numbers are assigned in varriable a and b and other varriables c,d,e,f and g are declared for storing the results of addition, subtraction, multiplication, division and remainder respectively. "%" is used to find remainder. "%d" is a specifier of integer.
Here "\n" is a specifier that is used to print the text in new line.


Exercise: 
Find out  simple interest where principal is 2000, time is 3 years and rate is 2% using a C program.

Share:

No comments:

Post a Comment

If you have any doubt, let me know...

Translate

Wikipedia

Search results