Q1) write
a C program to demonstrate the relational operator.
Ans :-
#include <stdio.h>
int main()
{
int a,b,c;
printf("Enter the three digits :)");
scanf("\n%d %d %d",&a,&b,&c);
printf("\n%d==%d",a,b,a == b);
printf("\n%d==%d is %d",c,b,c == b);
printf("\n%d>%d is %d",a,b,a > b);
printf("\n%d>%d is %d",c,b,c > b);
printf("\n%d<%d is %d",a,b,a < b);
printf("\n%d<%d is %d",c,b,c < b);
printf("\n%d!=%d is %d",a,b,a != b);
printf("\n%d!=%d is %d",c,b,c != b);
printf("\n%>=%d is %d",a,b,a >= b);
printf("\n%d>=%d is %d",c,b,c >= b);
printf ("\n%d<=%d is %d",a,b,a <= b);
printf("\n%d<=%d is %d",c,a,c <=b);
return 0;
}
input :
Q2)write
A C PROGRAM TO DEMONSTRATE THE LOGICAL OPERATOR.
Ans :
#include<stdio.h>
int main()
{
int a,b,c,result;
printf("enter the three numbers :) -: ");
scanf("%d %d %d",&a,&b,&c);
result= (a == b) && (c > b);
printf("(a == b) && (c > b) is %d \n",result);
result= ( a == b) && (c < b);
printf(" (a == b) && (c < b) is %d \n",result);
result= (a == b) || (c < b);
printf(" (a == b) || (c < b) is %d \n",result);
result= (a != b) || (c < b);
printf(" (a != b) || (c < b) is %d \n",result);
result= !(a != b);
printf(" !(a != b) is %d \n",result);
result= !(a == b);
printf(" !(a == b) is %d \n",result);
return 0;
}
input :
output :
Comments
Post a Comment