Mistakes:-
1. Difference b/w || and &&
||
(Logical OR)
||(OR)
operator checks whether one of condition is true or not..- It returns:
- True (1): If either or both conditions are true.
- False (0): If both conditions are false.
&&
(Logical AND)
- &&(AND) operator Checks whether both conditions are true or not.
- It returns:
- True (1): If both conditions are true.
- False (0): If either one or both conditions are false.
// Check if the triangle is equilateral , Isoceles, scalene.
#include <stdio.h>
int main() {
int a,b,c;
printf("Enter a side of Triangle: ");
scanf("%d", &a);
printf("Enter b side of Triangle: ");
scanf("%d", &b);
printf("Enter c side of Triangle: ");
scanf("%d", &c);
// || is OR operator it checks whether one of the condition is true or not
// && is AND operator it checks whether both conditions are true or not.
if(a==b && b==c){
printf("Triangle is Equilateral");
} else if(a==b || b==c || a==c) {
printf("Triangle is Isoceles");
} else {
printf("Triangle is Scalene.");
}
return 0;
}
No comments:
Post a Comment