In the previous blog we saw whether two numbers are equal. Now we will see whether two numbers are not equal.
To check whether two numbers are equal or not
#include <stdio.h>
int main()
{
int number1,number2,temp;
printf("Enter two numbers ");
scanf("%d %d",&number1,&number2);
printf("%d",number1!=number2);
}
Algorithm:-
1.Start
2.Use the int datatype for the variables number1 and number 2.
3.Use the printf statement to display the text "Enter two numbers".
4.Use the scanf statement to get the two numbers number1 and number2.
Explanation :-We use two format specifiers "%d" "%d" as we are using two integer type variables number1 and number2.
5.In the printf statement we use a not equality operator and check whether both the numbers are not equal .
Explanation:-We here use not equality operator != which will have two equal signs .It's used for checking whether two numbers are equal .
6.It will then display the value.
Explanation:- It will return 1 if two numbers are not equal .Or else it will return 0 if two numbers are equal. It displays 1 or 0 since we are using the "%d" format specifier
7.Stop
Screenshot:-
1.Code Screenshot:-
2.Output Screenshot:-
In next blog, we will see how to how to get average of numbers in C.
0 Comments