Write a program in C for showing working of different
logical operator in C.
Your program should guide users with proper message/menu on
the console.

Answer Posted / gajendra patil

# include <stdio.h>
int main(){
int ch,n1,n2;
t: printf("\nUSE OF LOGICAL OPERATORS");
printf("\n--------------------------");
printf("\n\tMENU");
printf("\n--------------------------");
printf("\n1. OR(||)\n2. AND(&&)\n0. EXIT");
printf("\n--------------------------");
printf("\nEnter your Choice: ");
scanf("%d",&ch);
switch(ch){
case 1:
printf("\nUSE OF OR\ne.g. [ if A>0 or B>0 ]");
printf("\n======================");
printf("\nEnter value for A: ");
scanf("%d",&n1);
printf("\nEnter value for B: ");
scanf("%d",&n2);
if(n1>0 || n2>0){
printf("\nAt least one/both has value(s)\n");
}else
printf("\nBoth are empty\n");
break;

case 2:
printf("\nUSE OF AND\ne.g [ if A>0 and B>0 ]");
printf("\n======================");
printf("\nEnter value for A: ");
scanf("%d",&n1);
printf("\nEnter value for B: ");
scanf("%d",&n2);
if(n1>0 && n2>0){
printf("\nBoth has values\n");
}else
printf("\nNo value(s) for any one/both\n");
break;
default:
printf("\nInvalid choice! try again");
printf("\n===========================");
goto t;
}

return 0;
}

Is This Answer Correct ?    16 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How reliable are floating-point comparisons?

628


how can f be used for both float and double arguments in printf? Are not they different types?

608


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

673


What is modifier & how many types of modifiers available in c?

612


while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above

740






Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent

1651


What is 'bus error'?

647


Do you know the use of 'auto' keyword?

662


define string ?

669


why wipro wase

1829


given post order,in order construct the corresponding binary tree

2323


How will you delete a node in DLL?

684


What is the use of c language in real life?

530


how to write a c program to print list of fruits in alpabetical order?

1789


What is an identifier?

626