Sharp Tutorial
input output in c++

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

introduction to c++

  • C++ Home
  • Introduction to C++
  • History features
  • Sample Programs
  • cout , cin , endl
  • Data type and Operators
  • if else in c++
  • loop in c++

Oops in C++

  • Object / Class
  • Constructor
  • Function & Constructor Overloading
  • Inheritance
  • Overriding

Advanced C++

  • Strings in C++
  • Exception Handling
  • Special Functions
  • C++ Programs

if else in c++

The if statement verifies the given condition and decides whether a block of statements are executed or not based on the condition’s result. In C++, the if statement is classified into four types as follows …

  1. Simple if statement
  2. if – else statement
  3. Multiple if statement
  4. Nested if statement
  5. if-else-if statement (if-else ladder)

Syntax for if condition

   //Syntax for if statement
if(condition) 
{
/*statement to be executed for true condition*/
}

 

Syntax for if else

  if(condition) 
{
/*statement to be executed for true condition*/
}
else
{ 
/*statement to be executed for false condition */
}

C++ program to check given mumber is even or odd

#include<iostream>
using namespace std;
int main()
{
int n=0; cout<<" enter the number to check"; cin>>n;
if(n%2==0)
{ cout<<"no is even "<<n;
}
else
{
cout<<"no is odd "<<n;
} return 0;
}

Above program displays the following output

Click for Complete understanding of if else.

Enquiry about Course

Ask your Question

Click Here

Sharp (2) Tutorials

Video/ C Introduction

Watch video in full size

Video tutorial

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial