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.

Answers were Sorted based on User's Feedback



Write a program in C for showing working of different logical operator in C. Your program should..

Answer / rajiv

int a,b,c,d,m,t;
float x,y,j,k;
scanf("%d\n%d\n%d\n%d\n%d\n%d\n",&a,&b,&c,&d,&m,&t);
scanf("%f\n%f\n%f\n%f\n",&x,&y,&j,&k);
if((a>b && c<d)||(x>y && j<k)||(m!=t))
printf("its demo of logical operator");
else
printf("logical error is there in program");

Is This Answer Correct ?    42 Yes 16 No

Write a program in C for showing working of different logical operator in C. Your program should..

Answer / 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

Write a program in C for showing working of different logical operator in C. Your program should..

Answer / chauhan varsha

#include<stdio.h>
void main()
{
int a=5,b=8,c=9,d=2;
clrscr();
if((a==b)&&(a==c))
{
printf("value is same. check 3 values using logical
operator..");
}
else if((a!>b) || (a!>c))
{
printf("value of a is not grater from b & c check
using logical operator or & not...");
}
getch();
}

Is This Answer Correct ?    5 Yes 0 No

Post New Answer

More C Interview Questions

Are pointers really faster than arrays?

0 Answers  


What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

0 Answers  


What does != Mean in c?

0 Answers  


consider the following C code main() { int i=3,x; while(i>0) { x=func(i); i--; } int func(int n) { static sum=0; sum=sum+n; return(sum); } the final value of x is

4 Answers   TCS,


array of pointer pointer to array pointer to pointer

1 Answers   MAHINDRA,






What is a c token and types of c tokens?

0 Answers  


in one file global variable int i; is declared as static. In another file it is extern int i=100; Is this valid ?

2 Answers   NetApp,


Explain the difference between call by value and call by reference in c language?

0 Answers  


what is meant by c

9 Answers   INiTS,


Stimulate calculator using Switch-case-default statement for two numbers

0 Answers   Wipro,


give one ip, find out which contry

4 Answers   Google,


Do you have any idea about the use of "auto" keyword?

0 Answers  


Categories