C++ Program for Logical and Conditional Operators
Master C++ with Real-time Projects and Kickstart Your Career Start Now!!
Program 1
// Demo of Logical and Conditional operator
#include<iostream>
#define clrscr() system("cls")
using namespace std;
int main()
{
int a,b,c;
clrscr();
// cout<<"Enter two no";
// cin>>a>>b;
c=! 50;
cout<<c;
// a=90;
// b=5;
// c=(++a>50) || (++b<8); //Short Circuit
// cout<<a<<" "<<b<<" "<<c;
return 0;
}Program 2
// Demo for conditional operator ? :
#include<iostream>
#define clrscr() system("cls")
using namespace std;
int main()
{
//int a,b,c;
int n;
clrscr();
// cout<<"Enter a number";
// cin>>n;
// n%2?cout<<"No is odd":cout<<"No is even";
'A' ?cout<<"Hello":cout<<"Bye";
// cout<<"Enter two Number";
// cin>>a>>b;
//0?cout<<"Hello":cout<<"Bye";
return 0;
}Program 3
// Program for Grater 4 Number:
#include<iostream>
using namespace std;
int main()
{
char ch;
cout<<"Enter a character";
cin>>ch;
system("cls");
ch=='a' ||ch=='e'|| ch=='i'||ch=='o' ||ch=='u' || ch=='A' ||ch=='E'|| ch=='I'||ch=='O' ||ch=='U'? cout<<"Vowel":cout<<"Consonent";
// int a,b,c,d,x,y,z;
// system("cls");
// cout<<"Enter Four Number";
// cin>>a>>b>>c>>d;
// x=a>b?a:b;
// y=c>d?c:d;
// z=x>y?x:y;
// cout<<"Grater No is :"<<z;
} Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

