C++ program which takes 3 numbers from user and display whether they are equal or not
instead of two I want a program which takes three numbers
Answers
Answered by
3
Answer:
#include <iostream>
using namespace std;
int main(){
//program which takes 3 numbers from user and display whether they are equal or not
int a,b,c;
cout<<"Enter 3 numbers: ";
cin>>a>>b>>c;
if(a==b && b==c)
cout<<"All numbers are equal";
else
cout<<"All numbers are not equal";
return 0;
}
Explanation:
- First we will define header and tell compiler to use namespace std.
- Then we will declare 3 variables and take 3 inputs from the user.
- Now, as mentioned in the question, display whether they are equal or not. We will apply a condition that all 3 numbers should be equal (a==b && b==c)
- if the condition is true, it displays "equal" message otherwise not,
Similar questions
English,
2 days ago
Computer Science,
4 days ago
Math,
4 days ago
Physics,
8 months ago
English,
8 months ago