Friday, May 15, 2020

Maximum No

//Find the Maximum No between Three Nos'

int i=10,o=20,k=30;
if(i>o &&i>k)
{
cout<<"1st is g\n";
}
else if(o>i &&o>k)
{
cout<<"2nd is G\n";
}
else
{
cout<<"3rd is G\n";
}

Check small and Capital letter

//Check whether the Character is small Or capital Alphabet

char ch='A';
if(ch>='A'&&ch<='Z')
{
cout<<"Capital\n";
}
else
{
cout<<"Not Capital\n";
}

Leap year

//Check whether is year is leap or not

int year=2020;
if(year%4==0)
{
cout<<"leap\n";
}
else
{
cout<<"Not leap\n";
}

C++ program to check whether the No is Even Or Odd

//Check whether the No is Even Or Odd

int m=6;

if(m%2==0) { cout<<"Even\n"; } else { cout<<"Odd\n"; }

C++ program that checks whether the No is Positive Negative and Zero

//Check No is negative,positive Or Zero


int n=10;
if(n<0)
{
cout<<"Negative\n";
}
else if(n>0)
{
cout<<"Positive\n";
}
else
{
cout<<"Zero\n";
}

This code is firsts checking the condition that whether our No is negative if it is negative then It will executes first part.You can use any no instead of 'n' or assign any value to 'n'. if first Condition is not true then our second part is going to check if our No is greater then zero then our second part is executed and print "positive" and If No is neither Positive Nor negative then our no is definitely zero so our Else part is going to executes and prints "Zero". 

Friday, May 1, 2020

Example of if statement

So here is the example :

How if statement works



THIS IS THE OUTPUT OF ABOVE PROGRAM


If and If else statement


Syntax of If and If-Else Statement:

if statement is used to decide whether the body is going to execute or not.



If our condition of if statement is false then our else part is going to execute. 
One block must be execute whether if or else.

Maximum No

//Find the Maximum No between Three Nos' int i=10,o=20,k=30; if(i>o &&i>k) { cout<<"1st is g\n";...