Professional Documents
Culture Documents
UNIVERSITY
ISLAMABAD
NAME: MUHAMMAD USAMA MASOOD
REG.NO: SP20-BCS-033
ASSIGNMENT
SUBMITTED TO : SIR SHAHZAD
PROGRAM 1:
Write a Program that input two numbers and radius of circle from the user.
You give the choice to the user that when user entered # symbol, then it
prints Area and Circumference of circle. If user entered * symbol, then it
displays the Result of Addition and Division of two numbers. You do
perform this task by using “Switch Multiple Selection Statement”
CODE:
#include<iostream>
#include<conio.h>
int main()
{
float a,b,radius;
char c;
cin>>a;
cin>>b;
cin>>radius;
cout<<"enter choice:"<<endl;
cin>>c;
switch(c)
case'#':
cout<<"area of circle:"<<3.14*(radius*radius)<<endl;
cout<<"circumference of circle:"<<2*3.14*radius<<endl;
break;
case'*':
default:
cout<<"invalid input..";
}
getch();
return 0;
PROGRAM 2:
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. You do
perform this task by using “For Loop”
CODE:
#include <iostream>
int main()
int n, range;
cin >> n;
cout << n << " * " << i << " = " << n * i << endl;
return 0;
PROGRAM 3:
Write a Program that display the following output on the console ”for
Loop”:- 0 2 4 6 8 . . . . . . . . . . . . . . . . . . . . . . . . 100 1 3 5 7
9 . . . . . . . . . . . . . . . . . . . . . . . . 99
CODE:
#include <iostream>
int main()
int i;
return 0;
--------------------------------------------------------------------------------------------
PROGRAM 4:
Write a program that input 10 numbers from the user in the Array and find
out Sum and Average of the Numbers using One Dimensional Array.
CODE:
#include<iostream>
int arr[10];
float average,sum=0;
for(int i=0;i<10;i++)
cout<<i+1<<"enter number"<<endl;
cin>>arr[i];
sum=sum+arr[i];
cout<<"sum of number="<<sum<<endl;
average =sum/10;
cout<<"average of number="<<average<<endl;
return 0;
PROGRAM 5:
Write a Program that display the following output on the console ”Nested
Loop”:
SHAPE 1:
CODE:
main()
cin>> squareHeight;
cin>> squareWidth;
if(width <= 1)
cout<< "*";
else if(width<squareHeight) {
cout<< endl;
if(width2==1 || width2==squareWidth)
cout<< "*";
else
else
cout<< endl;
cout<<"*";
SHAPE 2:
CODE:
#include<iostream>
int main ()
{
int c,d;
for(c=1;c<=5;c++)
for(d=1;d<=5;d++)
if(d>=6-c)
cout<<"*";
else
cout<<"";
cout<<"\n";
SHAPE 3:
CODE:
#include<iostream.h>
#include<conio.h>
int main()
int i,j;
clrscr();
cout<<"*";
cout<<"\n";
getch();
SHAPE 4:
CODE:
#include<iostream>
int main ()
{
int o,p;
for(o=1;o<=5;o++)
for(p=1;p<=4;p++)
cout<<"*";
cout<<endl;
return 0;
SHAPE 5:
CODE:
#include<iostream.h>
#include<conio.h>
void main()
int i, j, k;
for(i=5;i>=1;i--)
{
for(j=1;j<i;j++)
cout<<" ";
for(k=5;k>=i;k--)
cout<<"*";
cout<<"\n";
getch();
----------------------------------------------------------------------------------------------------
Program 6:
Write a Program that input 10 values from the user in the Array and find out
the Minimum value using the concepts of Searching.
Code:
#include<iostream>
int main()
{
int arr[2][3];
cout<<"enter values"<<endl;
for(int x=0;x<2;x++)
for(int a=0;a<3;a++)
cin>>arr[x][a];
int min=arr[0][0];
for(int y=0;y<2;y++)
for(int b=0;b<3;b++)
if(arr[y][b]<min)
min=arr[y][b];
cout<<"minimum value="<<min;
return 0;
----------------------------------------------------------------------------------------------------
Program 7:
Write a program that input 10 numbers from the user in the Array and find
out Sum and Average of the Numbers using One DimensionalArray.
Code:
#include<iostream>
int main ()
int arr[10];
float average,sum=0;
for(int i=0;i<10;i++)
cout<<i+1<<"enter number"<<endl;
cin>>arr[i];
sum=sum+arr[i];
cout<<"sum of number="<<sum<<endl;
average =sum/10;
cout<<"average of number="<<average<<endl;
return 0;
----------------------------------------------------------------------------------------------------
Program 8:
Write a program that perform “Passing Array to Function” with any program
example
Code:
#include <iostream>
cout << "Student " << i + 1 << ": " << m[i] << endl;
int main() {
return 0;
PROGRAM 9:
CODE:
#include <iostream>
#include<math.h>
int main()
double x = 13.2;
double y = 90;
return 0;
}
----------------------------------------------------------------------------------------------------
PROGRAM 10:
Write a Program that input radius of Circle and this radius “pass by value”
as FunctionArguments and display Area of Circle.
CODE:
#include<iostream>
float pi=3.14;
float area=pi*r*r;
cout<<"area of circle="<<area<<endl;
return 0;
int main ()
float r;
cin>>r;
black (r);