0% found this document useful (0 votes)
68 views8 pages

Usama Lab 6

This document contains an introduction to computer programming lab exercises for FA19-BEE-010. It includes 7 in-lab exercises that involve writing C++ programs using for loops. The exercises demonstrate basics like displaying a table of a given number, patterns with stars, and programs that take user input for the table length or number of rows/columns to display. Solutions to the exercises are provided in the form of algorithms and program code.

Uploaded by

M mubeen riaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views8 pages

Usama Lab 6

This document contains an introduction to computer programming lab exercises for FA19-BEE-010. It includes 7 in-lab exercises that involve writing C++ programs using for loops. The exercises demonstrate basics like displaying a table of a given number, patterns with stars, and programs that take user input for the table length or number of rows/columns to display. Solutions to the exercises are provided in the form of algorithms and program code.

Uploaded by

M mubeen riaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Introduction to Computer Programming (LAB) FA19-BEE-010

COMSATS University of Information and Technology

(Sahiwal campus)

Introduction to Computer Programming (LAB)

FA19-BEE-010

In Lab Exercises

Submitted To:

Mr. Hammid

Submitted By:

Muhammad Usama Arshad

I stated it with immense pleasure you have taught and allowed me to make an
assignment, which helped me in building my writing skills.

Department of Electrical and Computer Engineering


1
Introduction to Computer Programming (LAB) FA19-BEE-010

In-Lab Exercise

Example # 1. Here in the loop initialization part I have set the value of variable i to

1, condition is i<=6 and on each loop iteration the value of i increments by 1.

Algorithm: - Result

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i;
cout<<"Enter a value=";
cin>>i;
for (int m=1;m<=6;m++)
{
cout<<"Value of variable="<<m<<endl;
}
getch();
}

2
Introduction to Computer Programming (LAB) FA19-BEE-010

Exercise #1. Write a program in C++ using for loop to display the table of your roll

number.

Algorithm: - Result

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j;
cout<<"enter a number=";
cin>>i;
{
for (j=1;j<=10;j++)
cout<<i*j<<endl;
}
getch();
}

3
Introduction to Computer Programming (LAB) FA19-BEE-010

Exercise # 2. Write a program in C++ using for loop to display the following output.

Algorithm: - Result

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j;
for (i=1;i<=5;i++)
{
for (j=1;j<=i;j++)
cout<<"*";
cout<<endl;
}
getch();
}

4
Introduction to Computer Programming (LAB) FA19-BEE-010

Question # 1 Write a Program that input a number for table from the user. And also

input length for table. And shows the table according to its length.

Algorithm: - Result

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j;
cout<<"enter a number=";
cin>>i;
{
for (j=1;j<=10;j++)
cout<<i*j<<endl;
}
getch();
}

5
Introduction to Computer Programming (LAB) FA19-BEE-010

Question # 2: Write a Program that Shows the first 100 odd number on the console.

Algorithm: - Result

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j;
for (i=1;i<=5;i++)
{
for (j=1;j<=i;j++)
cout<<"*";
cout<<endl;
}
getch();
}

6
Introduction to Computer Programming (LAB) FA19-BEE-010

Question #3 Write a Program that display the following output on the console.

(A)

Algorithm: - Result
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k;
cout<<"enter a number=";
cin>>k;
{
for (i=1;i<=k;i++)
{
for (j=1;j<=k-i;j++)
cout<<" ";
}
while (k!=2*i)
cout<<"*";
cout<<endl;
}
getch();
}

7
Introduction to Computer Programming (LAB) FA19-BEE-010

(B)

Algorithm: - Result
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k;
cout<<"enter a number=";
cin>>k;
{
for (i=1;i<=k;i++)
{
for (j=1;j<=k-i;j++)
cout<<" ";
}
while (k!=2*i-1)
cout<<"*";
cout<<endl;
}
getch();
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy