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

do u print this format '(((())))'. This brackets is based on user input like 4 or 5 or 6,without using any loop's?

1 Answers   Oracle,


Why pointers are used?

0 Answers  


in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above

0 Answers  


What is a double c?

0 Answers  


How we can set and clear bit in a byte using macro function?

2 Answers   L&T, Samsung,






What is the output of the following progarm? #include<stdio.h> main( ) { int x,y=10; x=4; y=fact(x); printf(ā€œ%d\nā€,y); } unsigned int fact(int x) { return(x*fact(x-1)); } A. 24 B. 10 C. 4 D. none

2 Answers  


Do you know what is a programing language ?

0 Answers  


Is it possible to have a function as a parameter in another function?

0 Answers  


1.write a program to merge the arrays 2.write efficient code for extracting unique elements from a sorted list of array?

3 Answers   Qualcomm,


write a program that print itself even if the source file is deleted?

2 Answers  


What is a loop?

0 Answers  


Can true be a variable name in c?

0 Answers  


Categories