So, we saw division of two numbers in our previous blog .Now we will see about remainder of two numbers.
Basic Data Type:- int, char, float, double
int Datatype:- Its an integer datatype .Its of 2 bytes .Its range is −32,768 to 32,767.
char Datatype:-Its an character datatype. Its of 1 byte. Its range is -128 to 127 .
float Datatype:-Its for floating point numbers. Its of 4 byte.
double Datatype :-Its for large floating point numbers .Its of 8 byte
1.Remainder of two numbers using the keyword int
#include <stdio.h>
int main()
{
int number1,number2,number3;
printf("Enter two numbers ");
scanf("%d %d",&number1,&number2);
number3=number1%number2;
printf("The remainder of the number is %d ",number3);
return 0;
}
Algorithm:-
1.Start
2.Declare the header file #include<stdio.h>
3.Inside the main function declare the keyword int for the variables number1 ,number2,number3.
4.Use scanf and get the first number and second number .For integer variable we have to use a format specifier "%d" .
scanf:-Its used to get the user input from the user .
Since we are using two integer variable we are using two format specifiers which is of integer type i.e,"%d".
5.Use the number3 variable and use % to get remainder of number.
6.Finally print the number3 variable .
7.Stop
Screenshot:-
1.Code Screenshot :-
2.Output Screenshot:-
In the next blog we will see how to get ASCII value of character.
0 Comments