You are on page 1of 25

Submitted by :MOIZ Arshad

Submitted to : MR SAKEEL

Section :C

Department :CS

Semester :1

Date :30 April 2023

#include<iostream>

using namespace std;

intmain()

cout<<"Assalam O Alikum";

OUTPUT

Assalam O Alikum

#include<iostream>

using namespace std;


intmain()

cout<<"Hello World";

OUTPUT

Hello World

#include<iostream>

using namespace std;

intmain()

cout<<"This is C++ Programming";

OUTPUT

This is C++ Programming

#include <iostream>

using namespace std;

int main()

int hour;

cout << "Enter Hours:" << endl;

cin >> hour;

if (hour >= 9 && hour <= 18)

{
cout << "Working Hours";

else

cout << "Relaxation Hours";

} }

OUTPUT

Enter Hours: 14

Working Hours

#include <iostream>

using namespace std;

int main()

int age;

cout << "Enter your age: " << endl;

cin >> age;

if (age >= 12 && age <= 50)

cout << "Young" << endl;

else

cout << "Not Young" << endl;


}

if (age < 12 || age > 50)

cout << "Eligible for the Offer" << endl;

else

cout<<"Not Eligible for the Offer"<<endl;

OUTPUT

Enter your age: 34

Young

Eligible for the Offer

#include <iostream>

using namespace std;

main()

int n;

cout<<"Enter a number \n";

cin>>n;

if (!(n%2 == 0))

{
cout<<"You entered an odd number\n";

else

cout<<"You entered an even number\n";

OUTPUT

Enter a number 4

You entered an even number

#include <iostream>

using namespace std;

main()

int a=11, b=8,s;

s=a-b;

cout<<"Subtract ="<<s;

OUTPUT

Subtract =3

#include <iostream>
using namespace std;

main()

float r , pie=3.14;

cout<<"Enter Radius:"<<endl;

cin>>r;

cout<<"Area ="<<(r*r)*pie<<endl;

cout<<"Circumference ="<<2*pie*r<<endl;

OUTPUT

Enter Radius: 5

Area =78.5

Circumference =31.4

#include <iostream>

using namespace std;

int main( )

int age;

cout << "Enter your age: "<<endl;

cin >> age;

cout << "Your age is: " << age << endl;

OUTPUT
Enter your age:69

Your age is 69

#include<iostream>

using namespace std;

int main()

int a,b,c;

cout<<" Please Enter the first number "<<endl;

cin>>a;

cout<<" Please Enter the second number "<<endl;

cin>>b;

c=a+b;

cout<<" Your sum is "<<c;

Output

Please Enter the first number 4

Please Enter the second number 7

Your sum is 11

10

#include<iostream>

using namespace std;


int main()

int a,b,c;

cout<<" enter the 1st number please "<<endl;

cin>>a;

cout<<" enter the 2nd number please "<<endl;

cin>>b;

c=a-b;

cout<<" the subtraction of these two numbers is "<<c;

Output

enter the 1st number please 56

enter the 2nd number please 34

the subtraction of these two numbers is 22

11

#include<iostream>

using namespace std;

int main()

int a,b,c;

cout<<" enter the 1st number please "<<endl;

cin>>a;

cout<<" enter the 2nd number please "<<endl;

cin>>b;
c=a*b;

cout<<" Multiplication is of these two numbers is "<<c;

Output

enter the 1st number please 2

enter the 2nd number please 5

Multiplication is of these two numbers is 10

12

#include<iostream>

using namespace std;

int main()

int a,b,c;

cout<<" enter the 1st number please "<<endl;

cin>>a;

cout<<" enter the 2nd number please "endl;

cin>>b;

c=a/b;

cout<<" division of these two numbers is "<<c;

Output

enter the 1st number please 12

enter the 2nd number please 4

division of these two numbers is 3


13

#include<iostream>

using namespace std;

int main()

float r,b,h,l,w,PI=3.14;

cout<<"Enter Radius ="<<endl;

cin>>r;

cout<<"Area of Circle="<<(r*r)*PI<<endl;

cout<<"Enter Base and Height: "<<endl;

cin>>b>>h;

cout<<"Area of Triangle="<<b*h*0.5<<endl;

cout<<"Enter Length and Width:"<<endl;

cin>>l>>w;

cout<<"Area of Rectangle="<<l*w<<endl;

Output

Enter Radius=4

Area of Circle=50.24

Enter Base and Height:12 14

Area of Triangle=84

Enter Length and Width: 20 23

Area of Rectangle= 460


14

#include<iostream>

using namespace std;

int main()

int pf=40,ict=39;

if(pf>ict)

cout<<"PF="<<pf;

else

cout<<"ICT="<<ict;

Output

PF=40

15

#include<iostream>

using namespace std;

int main()

int pf=100,ict=69;

if(pf>ict)
{

cout<<"PF"<<pf;

else

cout<<"ICT"<<ict;

Output

PF

16

#include <iostream>

using namespace std;

int main()

char ch;

cout << "Enter a character: ";

cin >> ch;

if (isalpha(ch))

cout << "You entered an alphabet\n";

else if (isdigit(ch))

{
cout << "You entered a digit\n";

else

cout << "You did not enter an alphabet or digit\n";

Output

Enter a character:g

You entered an alphabet

17

#include <iostream>

using namespace std;

int main()

char ch;

cout << "Enter a character: ";

cin >> ch;

if (isalpha(ch)) {

if (isupper(ch)) {

ch = tolower(ch);

else

{
ch = toupper(ch);

cout << "Converted character: " << ch << endl;

else

cout << "You did not enter an alphabet." << endl;

Output

Enter a character:A

Converted character:a

18

#include <iostream>

using namespace std;

int main()

float n,a,sum=0,0;

int i,n,count=0;

cout<<"Maximun Number of inputs:"<<endl;

cin>>n;

for(i=1;i<=n;i++)

cout<<"Enter n"<<i<<":"<<endl;
cin>>n;

if(n<0.0)

goto jump;

sum+= n;

count++;

jump:

a=s/count;

cout<<"Average="<<a<<endl;

Output

Maximum Number of inputs: 3

Enter n1: 2

Enter n2: 5

Enter n3:7

Average=3.7

19

#include <iostream>

using namespace std;

int main()

{
int n=1;

print:

cout<<n<<" ";

n++;

if(n<=5)

goto print;

Output

12345

20

#include <iostream>

using namespace std;

int main()

cout<<"Start"<<endl;

exit(0);

cout<<"Stop"<<endl;

Output

Start
21

#include <iostream>

using namespace std;

int main()

int n;

cout<<"Enter a Number"<<endl;

cin>>n;

if(n>10)

exit(0);

else

cout<<"Rest of the Program";

Output

Enter a Number 45

22

#include <iostream>

using namespace std;

int main()

{
for(int i=0;i<=10;i++)

cout<<i<<endl;

if(i==5)

exit(0);

cout<<"Rest of the Program"<<endl;

Output

23

#include <iostream>

using namespace std;

int main()

for (int i = 1; i < 30; i += 2)

{
cout << i << " ";

cout << endl;

Output

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29

24

#include <iostream>

using namespace std;

int main()

for (int i = 1; i < 30; i++)

if (i % 3 == 0)

cout << i << " ";

cout << endl;

Output

3 6 9 12 15 18 21 24 27

25
#include <iostream>

using namespace std;

int main()

for (int i = 1; i < 30; i++)

if (i % 3 == 0 && i % 5 == 0)

cout << i << " ";

cout << endl;

Output

15

26

#include <iostream>

using namespace std;

int main()

int count;

cout << "Enter a count: ";

cin >> count;

for (int i = 1; i < count; i += 2)


{

cout << i * i << " ";

cout << endl;

Output

Enter a Count:10

1 9 25 49 81

27

#include <iostream>

using namespace std;

int main()

char c;

int count = 0;

cout << "Enter some characters, terminated by '#': ";

while (cin.get(c) && c != '#')

if (c != ' ' && c != '\t' && c != '\n')

count++;

cout << "Number of non-whitespace characters entered: " << count << endl;
}

Output

Enter some characters, terminated by '#': Hello, world!#

Number of non-whitespace characters entered: 12

28

#include<iostream.h>

using namespace std;

void main()

for( int x = 1; x < 3; x ++)

for ( int y = 1; y <= x; y ++)

cout<<y <<”\t”;

cout<< ”\n” ;

Output

12

123

29

#include<iostream.h>

#include<conio.h>
void main()

int n, k;

cout<< “Enter the number of integers :”;

cin >> n;

forFonts for Android and iPhone - www.fontskeyboard.com/share-now( int i = 0; i < n; i ++)

cout<< “Enter the number of whose divisor are to be found”;

cin >> k;

cout << “\n The divisor are :”<<”\n”;

for ( int j = 1; j <= k/2; j ++)

if( k%j == 0)

cout<< j <<”\t”;

Output

Enter the number of integers : 2

Enter the number whose divisor is to be found : 12

The divisors are :

12346

Enter the number whose divisor is to be found : 10

The divisors are :

125
30

#include<iostream>

using namespace std;

void main()

int num, l;

char ch;

do

cout<<”Enter a number whose multiplication table is to be displayed:”;

cin>>num;

cout<<”Enter the limit of upto which table is to be displayed :”;

cin>>l;

int i = 1;

while( i <= l)

cout<<num<<”X”<< i <<”=”<<num*i <<”\n”;

cout<<”Do you wish to continue (Y/N)”<<”\n”;

cin>>ch;

while(ch!=’n’||ch!=’N’);
}

Output

Enter a number whose multiplication table is to be displayed: 9

Enter the limit upto which table is to be displayed : 5

9X1=9

9X2=18

9X3=27

9X4=36

9X5=45

Do you wish to continue(Y/N)

Enter a number whose multiplication table is to be displayed: 6

Enter the limit upto which table is to be displayed : 5

6X1=6

6X2=12

6X3=18

6X4=24

6X5=30

Do you wish to continue(Y/N)

«_______Thanks ________»

You might also like