if/else

C++ Program to convert a lowercase alphabet to uppercase or vice-versa

#include<iostream.h> #include<conio.h> void main() { clrscr(); char ch; cout<<“Enter any Alphabet:”; cin>>ch; if(ch>=’a’&&ch<=’z’) { cout<<“ntYou have entered a lowercase alphabet”; ch=ch-32; cout<<“nnThe uppercase alphabet is “<<ch; } else { cout<<“ntYou have entered an Uppercase alphabet”; ch=ch+32; cout<<“nnThe lowercase alphabet is “<<ch; } getch(); }

C++ Program to print three numbers in descending order

#include<iostream.h>#include<conio.h> void main(){ clrscr(); int a,b,c,big1,big2,big3; cout<<“Enter three numbers:”; cin>>a>>b>>c;  big1=a; if(b>big1) big1=b; else if(c>big1) big1=c; if(big1==a) { if(b>c) { big2=b; big3=c; } else { big2=c; big3=b; } } else { if(big1==b) if(a>c) { big2=a; big3=c; } else { big2=c; big3=a; } else { if(a>b) { big2=a; big3=b; } else { big2=b; big3=a; } } …

C++ Program to print three numbers in descending order Read More »

C++ Program to Check Leap Year

Here is C++ program to check whether a year is a leap year or not. A leap year consists of 366 days instead of 365 days. In a leap year, February month consists of 29 days. Output: Enter Year(ex:1900):2000 Leap Year

C++ Program to Find LCM and HCF of two numbers

#include<iostream.h> #include<conio.h> void main() { clrscr(); int a,b,hcf,lcm,max,min,r; cout<<“Enter two numbers:”; cin>>a>>b; if(a>b) { max=a; min=b; } else if(b>a) { max=b; min=a; } if(a==b) hcf=a; else { do { r=max%min; max=min; min=r; }while(r!=0); hcf=max; } lcm=(a*b)/hcf; cout<<“nLCM=”<<lcm<<“nHCF=”<<hcf; getch(); }

C++ Program to Check Character is Uppercase, Lowercase, Digit, or Special Character

Below I have shared a C++ program to check whether a given character is an uppercase or lowercase alphabet, a digit, or a special character. First of all, I read a character and then compare it with the ASCII values given below. If the ASCII value of the character is other than the values mentioned …

C++ Program to Check Character is Uppercase, Lowercase, Digit, or Special Character Read More »