Nested C++ Programs
Nested C++ Programs
ROLL N0:EE-1426
DISCIPLINE:EE
COURSE: F.O.P.
return 0;
}
WALEED IJAZ 1
NESTED FOR LOOP
Program to make triangle using numbers :
#include <iostream>
using namespace std;
int main()
{
int rows;
cout << "Enter number of rows: ";
cin >> rows;
for(int i=rows; i>=1; i--)
{
for(int j=1; j<=i; j++)
{
cout << j << " ";
}
cout << endl;
}
return 0;
}
WALEED IJAZ 2
}
return 0;
}
NESTED IF ELSE
Program to tell “stage of life” by age:
#include <iostream>
using namespace std;
int main()
{
int age;
cout<<"enter the age \n";
cin>>age;
if(age>=14)
{
if(age>=18)
{
cout<<"Adult \n";
}
else
{
cout<<"Teenager \n";
}
}
else
{
if (age >5 && age<14)
{
cout<<"Kid \n";
}
else
{
cout << "child \n";
}
}
return 0;
}
WALEED IJAZ 3
SWITCH PROGRAM
Program to tell vowels:
#include <iostream>
using namespace std;
int main()
{
char alphabet;
cout<<"Enter the Alphabet(In Capital Letter): ";
cin>>alphabet;
switch (alphabet)
{
case 'A': cout << “Your Character Is A. This alphabet is
Vowel\n";
break;
return 0;
}
WALEED IJAZ 4
NESTED IF
Program to tell ‘passed’ or ‘failed’ in the exam:
#include <iostream>
using namespace std;
int main()
{
int mark = 100;
return 0;
}
WALEED IJAZ 5
WALEED IJAZ 6