Chapter 4 (Exercise) => Programming in C++ IT SERIES
Exercise Program
PROGRAM 1
#include<iostream>
using namespace std;
Int main(){
int n=10;
float a=10.22;
char ch='A';
cout<<"The value of int is ::> "<<n<<endl;
cout<<"The value of float is ::> "<<a<<endl;
cout<<"The value of char is ::> "<<ch<<endl;
cout<<"End Of program ::> ";
return 0;}
PROGRAM 2
#include<iostream>
#include<cmath>
using namespace std;
Int main(){
float radius,Area,circum;
cout<<"Enter the Radius :: ";
cin>>radius;
Area=4*M_PI*(radius*radius);
circum=4.0/3*M_PI*pow(radius,3);
cout<<"Area of the sphere is :: "<<Area<<endl;
cout<<"Circumference is :: "<<circum<<endl;
return 0;}
Program 3
1
Rana Wasif Rana Masroor
Chapter 4 (Exercise) => Programming in C++ IT SERIES
#include<iostream>
#include<cmath>
using namespace std;
Int main(){
int a,b,c;
cout<<"Enter the value of A :: ";
cin>>a;
cout<<"Enter the value of B :: ";
cin>>b;
cout<<"Enter the value of C :: ";
cin>>c;
float s=(a+b+c)/2.0;
float Area=sqrt(s*(s-a)*(s-b)*(s-c));
cout<<"The Area of the triangle is :: "<<Area;
return 0;}
Program 4
#include<iostream>
using namespace std;
Int main(){
float mile;
cout<<"Enter the miles :: ";
cin>>mile;
float kilometer=mile*1.609;
cout<<"Kilometer is == "<<kilometer;
return 0;}
Program 5
#include<iostream>
using namespace std;
Int main(){
2
Rana Wasif Rana Masroor
Chapter 4 (Exercise) => Programming in C++ IT SERIES
int age,m,d;
cout<<"Enter your age in years :: ";
cin>>age;
m=age*12;
d=age*365;
cout<<"The months your age is ::> "<<m<<endl<<"The days your life is ==> "<<d;
return 0;}
Program 6
#include<iostream>
using namespace std;
Int main(){
int n;
cout<<"Enter the number :: ";
cin>>n;
cout<<"The square of the number is ::> "<<pow(n,2)<<endl;
cout<<"The cube of the number is ::> "<<pow(n,3);
return 0;}
Program 7
#include<iostream>
using namespace std;
Int main(){
int n,a,b,c;
cout<<"Enter the total pages of the book :: ";
cin>>n;
cout<<"Enter the number of pages a person read in one day :: ";
cin>>a;
cout<<"Enter the number of day a persson read :: ";
cin>>b;
int l=b*a;
3
Rana Wasif Rana Masroor
Chapter 4 (Exercise) => Programming in C++ IT SERIES
c=n-l;
cout<<"The pages a person read :: "<<l<<endl;
cout<<"The number of pages remain::>"<<c;
return 0;}
Program 8
#include<iostream>
using namespace std;
Int main(){
int petrol;
cout<<"Enter the Petrol in Liter :: ";
cin>>petrol;
float travel=(float)petrol*5.3;
cout<<endl;
cout<<"A car can travel "<<travel<<" Miles in "<<petrol<<" Liters ";
return 0;}
Program 9
#include<iostream>
using namespace std;
Int main(){
int student,fee_per_student;
cout<<"Enter the total number of students in class ";
cin>>student;
cout<<"Enter the fee of the student :: ";
cin>>fee_per_student;
int total_fee=student*fee_per_student;
cout<<"Total fee collected from the student ==> "<<total_fee<<endl;
return 0;}
Program 10
4
Rana Wasif Rana Masroor
Chapter 4 (Exercise) => Programming in C++ IT SERIES
#include<iostream>
using namespace std;
Int main(){
float F,C;
cout<<"Enter the Temperature in Farahan Height ::> ";
cin>>F;
C=5.0/9*(F-32);
cout<<C<<endl;
return 0;}
Program 11
#include<iostream>
using namespace std;
Int main(){
string n;
cout<<"Enter the digits ::> ";
cin>>n;
cout<<n[0]<<endl;
cout<<n[1]<<endl;
cout<<n[2]<<endl;
cout<<n[3]<<endl;
cout<<n[4]<<endl;
Program 12
#include<iostream>
using namespace std;
Int main(){
cout<<"1\t2\t3\t4\t5"<<endl<<"6\t7\t8\t9\t10";
return 0;
Program 13
5
Rana Wasif Rana Masroor
Chapter 4 (Exercise) => Programming in C++ IT SERIES
#include<iostream>
using namespace std;
Int main(){
int lenght,width,height;
cout<<"Enter the Lenght ::> ";
cin>>lenght;
cout<<"Enter the width of the cude ::> ";
cin>>width;
cout<<"Enter the Height of the cube ::> ";
cin>>height;
int v=lenght*width*height;
cout<<"The Volume of the cube is ::> "<<v;
return 0;}
Program 14
#include<iostream>
using namespace std;
Int main(){
int x1, y1, x2, y2;
cout << "Enter the X coordinate of first point: ";
cin >> x1;
cout << "Enter the Y coordinate of first point: ";
cin >> y1;
cout << "Enter the X coordinate of second point: ";
cin >> x2;
cout << "Enter the Y coordinate of second point: ";
cin >> y2;
float distance = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
cout << "Distance between two points: " << distance << endl;
return 0;
6
Rana Wasif Rana Masroor
Chapter 4 (Exercise) => Programming in C++ IT SERIES
Program 15
#include<iostream>
using namespace std;
Int main(){
int a,b,c,temp;
cout<<"Enter the number ::> ";
cin>>a;
cout<<"Enter the secound number ::> ";
cin>>b;
cout<<"Enter the third number ::>";
cin>>c;
temp=a;
a=b;
b=c;
c=a;
c=temp;
cout<<a<<endl<<b<<endl<<c;
return 0;}
Program 16
#include<iostream>
using namespace std;
Int main(){
float radius,angle;
cout<<"Enter the radius of the arc ::> ";
cin>>radius;
cout<<"Enter the Angle of the arc ::> ";
cin>>angle;
float lenght=radius*angle;
cout<<lenght<<endl;
7
Rana Wasif Rana Masroor
Chapter 4 (Exercise) => Programming in C++ IT SERIES
return 0;}
Programm 17
#include<iostream>
using namespace std;
Int main(){
float pound;
cout<<"Enter the pounds ::> ";
cin>>pound;
float kilogram=pound*0.453592;
cout<<"The pound convert into kilogram ::>"<<kilogram;
return 0;}
Program 18
#include<iostream>
using namespace std;
Int main(){
float radius, theta, area;
cout << "Enter the radius of the circle: ";
cin >> radius;
cout << "Enter the angle in radians: ";
cin >> theta;
area = 0.5 * radius * radius * theta;
cout << "The area of the sector is: " << area << endl;
return 0;}
Program 19
#include<iostream>
using namespace std;
Int main(){
int n;
cout<<"Enter the number :: ";
8
Rana Wasif Rana Masroor
Chapter 4 (Exercise) => Programming in C++ IT SERIES
cin>>n;
cout<<log2(n);
Program 20
char ch;
cout<<"Enter the character ::> ";
cin>>ch;
ch++;
cout<<ch<<endl;
ch++;
cout<<ch<<endl;
return 0;}
Program 21
#include<iostream>
using namespace std;
Int main(){
int a,b,c,d,e;
cout<<"Enter the Five Integer ::> ";
cin>>a>>b>>c>>d>>e;
int sum=a+b+c+d+e;
cout<<"Sum of the integer is equal ::> "<<sum<<endl;
return 0;}
Program 22
#include<iostream>
using namespace std;
Int main(){
int sallary;
cout<<"Enter the sallary ::> ";
cin>>sallary;
int darness_allowance=sallary*0.25;
9
Rana Wasif Rana Masroor
Chapter 4 (Exercise) => Programming in C++ IT SERIES
int house_rent=sallary*0.25;
int gross_sallry=sallary+(darness_allowance+house_rent);
cout<<"Gross salary ::> "<<gross_sallry;
return 0;}
Program 23
#include<iostream>
using namespace std;
Int main(){
int hh,mm,ss;
cout<<"Enter the time in HH_MM_SS ";
cin>>hh>>mm>>ss;
int t=(mm*3600)+(mm*60)+ss;
cout<<"Total Time in Secounds ::> "<<t;
return 0;}
Program 24
#include<iostream>
using namespace std;
Int main(){
int principal_amount,rate_intrest,time,compound_intrest;
cout<<"Enter the principal amount ::> ";
cin>>principal_amount;
cout<<"Ente the intrest rate ::>";
cin>>rate_intrest;
cout<<"Enter the time ";
cin>>time;
compound_intrest=(principal_amount+rate_intrest+time)/100;
cout<<"The principal amount ::> "<<principal_amount<<endl;
cout<<"The intrest rate ::> "<<rate_intrest<<"%"<<endl;
cout<<"The time is ::> "<<time<<" years" <<endl;
10
Rana Wasif Rana Masroor
Chapter 4 (Exercise) => Programming in C++ IT SERIES
cout<<"The compound intrest is ::> "<<compound_intrest;
return 0;}
Program 25
#include<iostream>
using namespace std;
Int main(){
char ch;
cout<<"Enter the letter :: ";
cin>>ch;
int n=ch;
cout<<n;
return 0;}
Program 26
#include<iostream>
using namespace std;
Int main(){
int m1,m2,m3,m4,m5;
int marks_obt,total_marks,percantage;
cout<<"Enter the obtained marks ::> ";
cin>>m1>>m2>>m3>>m4>>m5;
total_marks=500;
percantage=m1+m2+m3+m4+m5*100/total_marks;
cout<<"The total marks is Equal to "<<total_marks<<endl;
cout<<"The percantage of the number is " <<percantage<<endl;
return 0;}
Program 27
#include<iostream>
using namespace std;
Int main(){
11
Rana Wasif Rana Masroor
Chapter 4 (Exercise) => Programming in C++ IT SERIES
int principal_amount,rate_intrest,time,compund_amount;
cout<<"Enter the Principal Amount ::> ";
cin>>principal_amount;
cout<<"Enter the rate of intrest ::> ";
cin>>rate_intrest;
cout<<"Enter the time ::>";
cin>>time;
compund_amount=principal_amount*pow((1+rate_intrest/100),time )-principal_amount;
cout<<"The principal amount is :: >> "<<principal_amount;
return 0;
12
Rana Wasif Rana Masroor
Chapter 5 (Exercise) => Programming in C++ IT SERIES
#include<iostream>
#include<cmath>
using namespace std;
int main(){
Program 1
char ch;
cout<<"Enter the character :: > ";
cin>>ch;
if(ch>='a' && ch<='z')
cout<<"Entered character is a lowercase letter ::> ";
else
cout<<"Entered character is Not a lowercase letter ::> ";
Program 2
char ch;
cout<<"Enter the Charactrer ::> ";
cin>>ch;
if(ch=='s' || ch=='S')
cout<<"Senior sales man salary is 400 a week ";
else if(ch=='j' || ch=='J')
cout<<"Junior sales man salary is 275 a week ";
else
cout<<"Error ";
Program 3
int a,b,c;
cout<<"Enter the three number ::> ";
cin>>a>>b>>c;
if(a!=0)
cout<<((b%a==0 && c%a==0) ? "IS a common divisior " : " Not a common divisior ");
else
13
Rana Wasif Rana Masroor
Chapter 5 (Exercise) => Programming in C++ IT SERIES
cout<<"A Should not be a zero ";
Program 4
char ch;
int a,b,h,s;
cout<<"Enter the character ::> ";
cin>>ch;
if(ch=='S'){
cout<<"Enter the side of the triangle :: > ";
cin>>s;
a=s*s;
cout<<"Area = "<<a;
else if(ch=='T'){
cout<<"Enter the Base of the Triangle ::> ";
cin>>b;
cout<<"Enter the height of the triangle ::> ";
cin>>h;
a=1/2.0*b*h;
cout<<"Area = "<<a;
else
cout<<"INVALID ";
Program 5
char n;
float F,C;
cout<<"Enter the character :: > ";
cin>>n;
if(n=='f' || n=='F'){
cout<<"Enter the temperature in farahanheight :: > ";
14
Rana Wasif Rana Masroor
Chapter 5 (Exercise) => Programming in C++ IT SERIES
cin>>F;
C=(F-32)*5.0/9.0;
cout<<C;
else if(n=='c' || n=='C'){
cout<<"Enter the temperature in calcius ::> ";
cin>>C;
F=(9.0/5.0*C)+32;
cout<<F;
else
cout<<"INVALID ";
Program 6
int n;
cout<<"Enter the number :: > ";
cin>>n;
if(n==1)
cout<<"Wastern Digital "<<endl;
else if(n==2)
cout<<"3M Corporation "<<endl;
else if(n==3)
cout<<"Maxell Corporation "<<endl;
else if(n==4)
cout<<"Sony Corporation "<<endl;
else if(n==5)
cout<<"Verbatim Corporation "<<endl;
else
cout<<"INVALID ";
15
Rana Wasif Rana Masroor
Chapter 5 (Exercise) => Programming in C++ IT SERIES
Program 7
char n;
cout<<"Enter the Characters ::> ";
cin>>n;
if(n=='A')
cout<<"Advanture Movies "<<endl;
else if(n=='C')
cout<<"Comedy Movies "<<endl;
else if(n=='F')
cout<<"Family Movies "<<endl;
else if(n=='H')
cout<<"Horror Movies "<<endl;
else if(n=='S')
cout<<"Science Fiction Movies ";
else
cout<<"Error";
Program 8
int a,b,c,d;
char n;
cout<<"Enter the converstion type ::> ";
cin>>n;
if(n=='i' || n=='I'){
cout<<"Enter the Amount in Inches ::> ";
cin>>a;
cout<<a<<"Inches is = " <<a*2.54<<" Centimeter :: ";
else if(n=='g' || n=='G'){
cout<<"Enter the amount in Gallons ::>";
cin>>b;
16
Rana Wasif Rana Masroor
Chapter 5 (Exercise) => Programming in C++ IT SERIES
cout<<b<<" Gallon is = "<<b*3.785<<" Liters ";
else if(n=='m' || n=='M'){
cout<<"Enter the amount in Miles ::>";
cin>>c;
cout<<c<<" Mile is = "<<c*1.609<<" Kilometers ";
else if(n=='p' || n=='P'){
cout<<"Enter the amount in ponds ::>";
cin>>d;
cout<<d<<" Pound is = "<<d*.4536<<" Kilograms ";
else
cout<<"Error Message ! ";
Program 9
::> agr 100 pa divisble ha to wo leap year nhi ha
int year;
cout<<"Enter the year ::> ";
cin>>year;
if( year%400==0)
cout<<"Is a leap year ";
else if(year%100==0)
cout<<"Not a leap year ";
else if(year%4==0)
cout<<"Year is a leap year ::> ";
else
cout<<"Not a leap year ";
Program 10
int temp;
17
Rana Wasif Rana Masroor
Chapter 5 (Exercise) => Programming in C++ IT SERIES
cout<<"Enter the temperature ::> ";
cin>>temp;
if(temp>35)
cout<<" Hot Day ";
else if(temp>=25 && temp<=35)
cout<<"Pleasant Day ";
else if(temp<25)
cout<<"Cool Day ";
Program 11
int mark,total_mark=1100;
cout<<"Enter the obtained marks out of 1100 :: > ";
cin>>mark;
float percantage=(mark*100)/total_mark;
if(percantage>=80)
cout<<"Grade A+ ";
else if(percantage>=70)
cout<<"Grade A ";
else if(percantage>=60)
cout<<"Grade B ";
else if(percantage>=50)
cout<<"Grade C ";
else if(percantage>=40)
cout<<"Grade D ";
else if(percantage>=33)
cout<<"Grade E ";
else
cout<<"Fail ";
Program 12
int n1,n2,n3;
18
Rana Wasif Rana Masroor
Chapter 5 (Exercise) => Programming in C++ IT SERIES
cout<<"Enter the marks of Three Subjects ::> ";
cin>>n1>>n2>>n3;
int sum=n1+n2+n3;
float avg=(float)sum/3.0;
cout<<"The sum of the subject is :: "<<sum<<endl;
cout<<"The Average marks is ::> " <<avg<<endl;
cout<<((avg>=40) ? "Pass " : "Fail ");
Program 13
int h, m;
cout << "Enter time (HH MM): ";
cin >> h >> m;
if (h == 0)
cout << "Standard Time: 12:" << m << " AM" << endl;
else if (h < 12)
cout << "Standard Time: " << h << ":" << m << " AM" << endl;
else if (h == 12)
cout << "Standard Time: " << h << ":" << m << " PM" << endl;
else
cout << "Standard Time: " << h - 12 << ":" << m << " PM" << endl;
Program 14
float a,b,c,x,x1,x2;
cout<<"Enter the value of A: B: C: ::: > ";
cin>>a>>b>>c;
x=b*b-4*a*c;
if(x>0){
x1=(-b+sqrt(x))/(2*a);
x2=(-b-sqrt(x))/(2*a);
cout<<x1<<" Root is "<<x2 <<endl;
19
Rana Wasif Rana Masroor
Chapter 5 (Exercise) => Programming in C++ IT SERIES
else
cout<<"Invalid ";
Program 15
int main() {
float salary, total_salary, tax;
cout << "Enter the salary of the Employee ::> ";
cin >> salary;
if (salary >= 30000)
tax = salary * 0.20;
else if (salary >= 20000)
tax = salary * 0.15;
else if (salary > 0)
tax = salary * 0.10;
else {
cout << "Invalid Salary!" << endl;
return 1;
total_salary = salary - tax;
cout << "The salary ::> " << salary << endl;
cout << "The tax is ::> " << tax << endl;
cout << "The net salary ::> " << total_salary << endl;
Program 16
int year,month;
cout<<"Enter the year ::> ";
cin>>year;
cout<<"Enter the month ::> ";
cin>>month;
if(month==1 )
cout<<"Janurary " <<year<<" has "<<"31 days";
20
Rana Wasif Rana Masroor
Chapter 5 (Exercise) => Programming in C++ IT SERIES
else if(month==2)
cout<<"Febraury " <<year<<" has "<<"28 or 29 days";
else if(month==3)
cout<<"March " <<year<<" has "<<"31 days";
else if(month==4)
cout<<"April " <<year<<" has "<<"30 days";
else if(month==5)
cout<<"May " <<year<<" has "<<"31 days";
else if(month==6)
cout<<"June " <<year<<" has "<<"30 days";
else if(month==7)
cout<<"July " <<year<<" has "<<"31 days";
else if(month==8)
cout<<"Agust " <<year<<" has "<<"31 days";
else if(month==9)
cout<<"September " <<year<<" has "<<"30 days";
else if(month==10)
cout<<"October " <<year<<" has "<<"31 days";
else if(month==11)
cout<<"November " <<year<<" has "<<"30 days";
else if(month==12)
cout<<"December " <<year<<" has "<<"31 days";
else
cout<<"INVALIED ";
//Months 4 6 9 11 = 30 days
//Month 2 29 or 29
//Months 1 3 5 7 8 10 12 =31
Program 17
cout<<"M =Motorcycle"<<endl;
21
Rana Wasif Rana Masroor
Chapter 5 (Exercise) => Programming in C++ IT SERIES
cout<<"C =Car"<<endl;
cout<<"M =Bus"<<endl;
char t;
int p;
cout<<"Enter the type of vechicle ::> ";
cin>>t;
if(t=='M'){
cout<<"Enter the days to park ::> ";
cin>>p;
cout<<"Total charges of Parking is ::> "<<p*10<<endl;
else if(t=='C'){
cout<<"Enter the days to park ::> ";
cin>>p;
cout<<"Total charges of Parking is ::> "<<p*20<<endl;
else if(t=='B'){
cout<<"Enter the days to park ::> ";
cin>>p;
cout<<"Total charges of Parking is ::> "<<p*30<<endl;
else
cout<<"Invalid ";
Program 18
float a;
string n;yaha pa ham char bi use kar sakta tha lakin wo ik character he safe karta ha ham na jasa kg
rakha ha to wo error da ga is lia ham string ka use kar raha han
cout<<"Enter the choice ::>(c,i,kg,km ) <:: ";
cin>>n;
22
Rana Wasif Rana Masroor
Chapter 5 (Exercise) => Programming in C++ IT SERIES
if(n=="c"){
cout<<"Enter the value in centimeter :>";
cin>>a;
cout<<"The value "<<a<<" convert centimeter to inches is "<<a*.394;
else if(n=="i"){
cout<<"Enter the value in Liter :>";
cin>>a;
cout<<"The value "<<a<<" convert liter to gallon is "<<a*.264;
else if(n=="km"){
cout<<"Enter the value in kilometer :>";
cin>>a;
cout<<"The value "<<a<<" convert kilometer to miles is "<<a*.622;
else if(n=="kg"){
cout<<"Enter the value in kilogram :>";
cin>>a;
cout<<"The value "<<a<<" convert kilogram to pounds is "<<a*2.2;
Program 19
int n;
cout<<"Enter the number :: > ";
cin>>n;
if(n>=0){
if(n%2==0)
cout<<"Positive Even :: ";
else
cout<<"Positive odd ";
23
Rana Wasif Rana Masroor
Chapter 5 (Exercise) => Programming in C++ IT SERIES
else
if(n%2==0)
cout<<"Negative Even :: ";
else
cout<<"Negative odd ";
Program 20
int a,b,c;
cout<<"Enter the Three sides of the triangle :: ";
cin>>a>>b>>c;
if(a==b && a==c && b==c)
cout<<"Equilateral Triangle";
else if(a==b || a==c || b==c)
cout<<"Isosceles Trianlge ";
else
cout<<"Scalene Triangle ";
Program 21
int choice;
float area;
cout << "Choose a shape to calculate the area:\n";
cout << "1. Circle\n";
cout << "2. Rectangle\n";
cout << "3. Triangle\n";
cout << "Enter your choice (1-3): ";
cin >> choice;
switch (choice) {
case 1: {
24
Rana Wasif Rana Masroor
Chapter 5 (Exercise) => Programming in C++ IT SERIES
float radius;
cout << "Enter the radius of the circle: ";
cin >> radius;
area = M_PI * radius * radius; // PIR^2
cout << "Area of the Circle: " << area << endl;
break;
case 2: {
float length, width;
cout << "Enter the length and width of the rectangle: ";
cin >> length >> width;
area = length * width;
cout << "Area of the Rectangle: " << area << endl;
break;
case 3: {
float base, height;
cout << "Enter the base and height of the triangle: ";
cin >> base >> height;
area = 0.5 * base * height;
cout << "Area of the Triangle: " << area << endl;
break;
default:
cout << "Invalid choice! Please select a number between 1 and 3.\n";
return 0;
25
Rana Wasif Rana Masroor
Chapter 6 => Programming in C++ IT SERIES
Nested For Loops
#include<iostream>
using namespace std;
int main(){
int sum;
for(int i=1; i<=5; i++){
cout<<"1";
sum=1;
for(int j=2; j<=i; j++){
cout<<" + "<<j;
sum+=j;
cout<<" = "<<sum<<endl;
program 2
int n;
char ch='A';
cout<<"Enter the height of the character ::> ";
cin>>n;
for(int i=1; i<=n; i++){
for(int j=1; j<=i; j++){
cout<<ch<<" ";
ch++;
cout<<"\n";
Program 3
int n;
26
Rana Wasif Rana Masroor
Chapter 6 => Programming in C++ IT SERIES
for(int i=1; i<=7; i++){
n=i;
while(n<=7){
cout<<"*"<<" ";
n++;
cout<<"\n";
Again For Try ::>
int n;
for(int i=1; i<=7; i++){
n=i;
while(n<=7){
cout<<"*"<<" ";
n++;
cout<<"\n";
Program 4
for(int i=1; i<=5; i++){
for(int j=1; j<=5; j++){
cout<<"*"<<" ";
cout<<"\n";
Program 5
for(int i=4; i>=1; i--){
for(int j=1; j<=i; j++){
cout<<i<<" ";
27
Rana Wasif Rana Masroor
Chapter 6 => Programming in C++ IT SERIES
cout<<endl;
Program 6
for(int i=5; i>=1; i-- ){
for(int j=1; j<=5-i; j++)
cout<<" ";
for(int k=1; k<=i; k++)
cout<<"*";
cout<<endl;
Program 7
for(int i=1; i<=5; i++){
for(int j=1; j<=i; j++){
cout<<"*";
}cout<<endl;
Program 8
int n=2;
for(int i=2; i<=6; i++){
for(int j=1; j<i; j++){
cout<<i*j<<" ";
}cout<<endl;
n++;
Program 9 (Out of Book )
for(int i=1; i<=6; i++){
for(int j=i; j>1; j--)
cout<<" ";
28
Rana Wasif Rana Masroor
Chapter 6 => Programming in C++ IT SERIES
for(int k=1; k<=6+1-i; k++)
cout<<k<<" ";
cout<<endl;
Program 10
for(int i=1; i<=5; i++){
for(int k=1; k<=5-i; k++)
cout<<" ";
for(int j=1; j<=i; j++)
cout<<"*";
cout<<endl;
Program 11
int n=1;
for(int i=1; i<=5; i++){
for(int j=1; j<=5-i; j++)
cout<<" ";
for(int k=1; k<=i; k++)
cout<<n<<" ";
cout<<endl;
n++;
return 0;
29
Rana Wasif Rana Masroor
Full Source Code C++ Available In Github
01 https://github.com/ranawasif896
02 https://github.com/Mas407
30
Rana Wasif Rana Masroor