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 ?    4 Yes 0 No



Post New Answer



More C Interview Questions

main() { int x=10,y=15; x=x++; y=++y; printf("%d %d\n",x,y); } output??

19 Answers   TCS, EBS, Ramco, Sangwin,


why ordinary variable store the later value not the initial

1 Answers  


what is Structural oriented language? give some example of this language.....?

1 Answers  


What is a class?

3 Answers  


WAP to accept first name,middle name & last name of a student display its initials?

5 Answers   NIIT, AITH,






What is Function Pointer? Explain with example?

3 Answers  


what is difference between strcmp & palindrome?

3 Answers  


Which of the following data structures is on average the fastest for retrieving data: 1) Binary Tree 2) Hash Table 3) Stack

3 Answers  


What is the difference between char a[] = "string"; and char *p = "string"; ?

14 Answers   Adobe, TCS, Honeywell,


How can I access memory located at a certain address?

3 Answers   Verizon,


Explain the importance and use of each component of this string: Foo.Bar, Version=2.0.205.0, Culture=neutral, PublicKeyToken=593777ae2d274679d

1 Answers   TCS,


what's the o/p int main(int n, char *argv[]) { char *s= *++argv; puts(s); exit(0); }

1 Answers   Motorola,






Categories