0% found this document useful (0 votes)
35 views

Assignment No: 05: Submitted By: Muhammad Idrees Asghar

This document contains the code for 7 programming questions submitted as part of an assignment. Each question covers a different programming concept like loops, conditional statements, functions etc. The code shows calculations for converting between different distance/weight units and counting the number of characters entered by the user.

Uploaded by

Umar Nawaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Assignment No: 05: Submitted By: Muhammad Idrees Asghar

This document contains the code for 7 programming questions submitted as part of an assignment. Each question covers a different programming concept like loops, conditional statements, functions etc. The code shows calculations for converting between different distance/weight units and counting the number of characters entered by the user.

Uploaded by

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

1

ASSIGNMENT NO : 05
SUBMITTED BY

REG NO

L1F09BSCS2116

SECTION

SUBJECT

MUHAMMAD IDREES ASGHAR

PROGRAMMING FUNDAMENTALS

SUBMITTED TO

PROF. FAKHAR ABBAS

Due date

02 december, 2009

*Q NO:01*
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int j;
cout<<"Number\tSquare\t\tCube\n";
for(j=1;j<=10;j++)
{
cout<<endl<<j<<"\t"<<j*j<<"\t\t"<<j*j*j<<"\n
\n";

}
getch();
}

*Q NO:02*
#include<iostream.h>
#include<conio.h>
void main(){
clrscr();
char X,i,x,y;
cout<<"Enter ten alphabets:";
for (i=0;i<=10;i++)
{
cin>>X;

if(X>=65&&X<=90||
X>=97&&X<=122)
{}
else
cout<<"Invalid entry";
x=X+2;
cout<<x;
}
getch();
}

*Q NO:03*
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,d,e,f,X=5,Y,Z,A,B,C;
cout<<"Enter 5 number between 110";
cin>>a>>b>>c>>d>>e;
if(a==b||a==c||a==d||a==e)
{ Y=X-1;
cout<<Y;}
else if(b==a||b==c||b==d||b==e)
{ Z=Y-1;
cout<<Z;}
else if(c==a||c==b||c==d||c==e)
{ A=Z-1;
cout<<A; }
else if(d==a||d==b||d==c||d==e)

{ B=A-1;
cout<<B; }
else if(e==a||e==b||e==c||e==d)
{ C=B-1;
cout<<C; }
else
cout<<X;

getch();
}

*Q NO:04*
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char X;
int A=0,S=0,N=0,Y=0;
while(X!=48)
{
cout<<"Enter anything from
keyboard(Enter 0 for exit)"<<endl;
X=getche();
cout<<endl;

if (X>48&&X<=57)
N=N++;

else if (X>=65&&X<=90||
X>=97&&X<=122)
A=A++;

else if(X==32)

Y=Y++;
else if (X>=33&&X<=47||
X>=58&&X<=64||X>=123&&X<=127||
X>=91&&X<=96)
S=S++;

}
cout<<"Alphabets=
cout<<"Number=

"<<A<<endl;

"<<N<<endl;

cout<<"Special characters=
"<<S<<endl;
cout<<"Spaces=
getch();
}

"<<Y<<endl;

*Q NO:05
include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char X;
int A=0,S=0,N=0,Y=0;
while(X!=48)
{
cout<<"Enter anything from
keyboard(Enter 0 for exit)"<<endl;
X=getche();
cout<<endl;

if (X>48&&X<=57)
N=N++;

else if (X>=65&&X<=90||
X>=97&&X<=122)
A=A++;

else if(X==32)

Y=Y++;
else if (X>=33&&X<=47||
X>=58&&X<=64||X>=123&&X<=127||
X>=91&&X<=96)
S=S++;

}
cout<<"Alphabets=
cout<<"Number=

"<<A<<endl;

"<<N<<endl;

cout<<"Special characters=
"<<S<<endl;
cout<<"Spaces=
getch();
}

"<<Y<<endl;

10

*Q NO:07*
#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();

float
x=0,y=82,miles=0,pounds=0,usdoller=0;
char ch;

cout<<"\n\nenter 1 for
kilometer to miles:"<<endl;
cout<<"\n\nenter 2 for kilogram
to pounds:"<<endl;

cout<<"Enter 3 for rupees to US


doller:\t";

cout<<"\nenter 4 for
exit:\t\t";

11

cin>>ch;

switch(ch)
{
case'1':
cout<<"enter distance in
kilometers:\t";
cin>>x;

miles=(x*(0.6));
cout<<"the miles in that
kilometer="<<miles<<endl;
break;

case '2':
cout<<"enter kilograms:";
cin>>x;

pounds=(x*(2.205));
cout<<"the pounds in that
kilograms is="<<pounds<<endl;
break;
case'3':

12

cout<<"enter pkaistani
rupees:\t";
cin>>x;
usdoller=(x/y);
cout<<"the us doller in that
rupees is="<<usdoller<<endl;
break;

case'4':
break;

default:
cout<<"/n/ninvalid entry";
}
getch();
}

You might also like