You are on page 1of 11

ITC LAB TASK # 8

Q1
#include <iostream>
using namespace std;
int main ()
{
int x=1;
int y=1;

for (x=1;x<=4;x++)
{
for (y=1;y<=7;y++)
{
cout<<" * ";
}
cout<<endl;
}
system("pause");
return 0;
}

Q2
#include <iostream>
using namespace std;
int main ()
{
int x=1;
int y=1;

for (x=0;x<=7;)
{
x=x+2;
for (y=1;y<x;y++)
{
cout<<" * ";
}
cout<<endl;
}
system("pause");
return 0;
}

Q3
(A)
#include <iostream>
using namespace std;
int main ()
{
int x=1;
int y=1;

for (x=1;x<=7;x++)
{
for (y=1;y<x;y++)
{
cout<<" * ";
}
cout<<endl;
}
system("pause");
return 0;
}

(B)
#include <iostream>
using namespace std;
int main ()
{
int x=7;
int y=7;

for (x=7;x>=0;x--)
{
for (y=7;y>=x;y--)
{
cout<<" * ";
}
cout<<endl;
}
system("pause");
return 0;
}
Q4
(A)
#include <iostream>
using namespace std;
int main ()
{
int x=7;
int y=7;

for (x=7;x>=1;x--)
{
for (y=1;y<x;y++)
{
cout<<" * ";
}
cout<<endl;
}
system("pause");
return 0;
}

(B)
#include <iostream>
using namespace std;
int main ()
{
int x=7;
int y=7;

for (x=7;x>=1;x--)
{
for (y=1;y<x;y++)
{
cout<<" * ";
}
cout<<endl;
}
system("pause");
return 0;
}

Q5
(A)
#include <iostream>
using namespace std;
int main ()
{
int x=2;
int y=1;

for (x=2;x<=6;x++)
{
for (y=1;y<x;y++)
{
cout<< y ;
}
cout<<endl;
}
system("pause");
return 0;
}

(B)
#include <iostream>
using namespace std;
int main ()
{
int x=2;
int y=1;

for (x=6;x>1;x--)
{
for (y=1;y<x;y++)
{
cout<< y ;
}
cout<<endl;
}
system("pause");
return 0;
}
Q6
#include <iostream>
using namespace std;
int main ()
{
int x=2;
int y=1;

for (x=5;x>=0;x--)
{
for (y=x;y>0;y--)
{
cout<< y ;
}
cout<<endl;
}
system("pause");
return 0;
}

Q16
(A)

#include <iostream>
using namespace std;
int main ()
{
int x=1;
int y=0;

for (x=1;x<=7;x++)
{
for (y=0;y<x;y++)
{
cout<< x ;
}
cout<<endl;
}
system("pause");
return 0;
}

(B)
#include <iostream>
using namespace std;
int main ()
{
int x=1;
int y=0;

for (x=7;x>=1;x--)
{
for (y=0;y<x;y++)
{
cout<< x ;
}
cout<<endl;
}
system("pause");
return 0;
}

Q11
#include <iostream>
using namespace std;
int main()
{
int rows = 10;
int columns = 15;
for (int i = 1; i <= rows; ++i)
{
for (int j = 1; j <= columns; ++j)
{
if (i == 1 || i == rows || j == 1 || j == columns)
{
cout << "@";
}
else
{
cout << " ";
}
}
cout << endl;
}
system("pause");
return 0;
}

Q15
#include <iostream>
using namespace std;
int main()
{
int rows = 5;
for (int x = 1; x <= rows; ++x)
{
for (int y = 1; y <= x; ++y)
{
cout << x * y << " ";
}
cout << endl;
}
system("pause");
return 0;
}

Q8
#include <iostream>
using namespace std;
int main()
{
int rows = 4;
int columns = 7;
for (int i = 1; i <= rows; ++i)
{
for (int j = 1; j <= columns; ++j)
{
if (i == 1 || i == rows || j == 1 || j == columns)
{
cout << "*";
}
else
{
cout << " ";
}
}
cout << endl;
}
system("pause");
return 0;
}

You might also like