Wednesday, May 20, 2020

If statement in C++


  • Syntax :

    
      if (condition)
        {
        // block of code to be executed if the condition is true
        }


  • Program :

#include <iostream>
using namespace std;

int main() {
  cout <<"\n----------------IF STATEMENT----------------\n";
  int a;
  cout<<"\nEnter your age :";
  cin>>a;
  if (a >= 18) {
    cout << "Major";
  } 
  return 0;
}




  • Output :


No comments:

Post a Comment

Function Overloading in C++

https://monitechvenkat1620.blogspot.com Program : #include <iostream> using namespace std; int c(int x, int y) {   return...