‹ back to Programming C++

NotesProgramming C++ · 3 December 2015

Conditional Statements

As already discussed we have many operators which help to take decision. They execute a particular output or another command depending if the full fill has been full filled (true) or not (false)

IF Else Execution

We will here try to understand however

Example

To be eligible for Benazir Youth fund, a person must full fill any one requirement .

1. Age: Ages should be less than 28 Years

2. Nationality : Pakistani

3. Monthly income : Less than 5000 per month

Observations

For storing nationality we will be needing char type variable . Remember that variable uses ‘ ’ around them when operations are performed on them

We will use logical or for this question

 

#include<iostream>

using namespace std;

main()

{

int age=0;

int income=0;

char pakistani;

bool bif=0;

cout<<“Enter your age in years”<<endl;

cin>>age;

cout<<“Are you Pakistan y/n”<<endl;

cin>>pakistani;

cout<<“Enter your income”<<endl;

cin>>income;

bif=(pakistani==’y’)||((age<28)||(income<5000));

if(bif==1)

{

cout<<“You are eligible “;

}

Else

{

cout<<”u are not eligible”;

}

First published on fatsup.wordpress.com ↗