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

Lab Task # 1: 1. Write The Hello World Program

The document outlines 5 programming tasks: 1) print a hello world message, 2) print the sum of two hardcoded numbers, 3) print the sum of two numbers entered by the user, 4) compute the quotient and remainder of a dividend and divisor entered by the user, 5) find the largest of three numbers entered by the user.

Uploaded by

Anum Aamir
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)
28 views

Lab Task # 1: 1. Write The Hello World Program

The document outlines 5 programming tasks: 1) print a hello world message, 2) print the sum of two hardcoded numbers, 3) print the sum of two numbers entered by the user, 4) compute the quotient and remainder of a dividend and divisor entered by the user, 5) find the largest of three numbers entered by the user.

Uploaded by

Anum Aamir
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/ 5

LAB TASK # 1

1. Write the Hello World program.


1 //Printing String
2 #include <iostream>
3 using namespace std;
4 int main(){
5 cout<< "Hello to Lab 1";
6 return 0;
7 }

1
2. Print sum of two numbers 100 and 200.

1 //Printing Sum of literals


2 #include <iostream>
3 using namespace std;
4 main(){
5 int a= 10;
6 int b= 20;
7 cout<< "Sum= "<< a+b;
8 }

2
3. Print sum of two numbers entered by user.

1 //Printing Sum of two numbers


2 #include <iostream>
3 using namespace std;
4 main(){
5 int num1, num2= 0;
6 cout<< "Enter Number 1: ";
7 cin>> num1;
8 cout<< "Enter Number 2: ";
9 cin>> num2;
10 cout<< "\nSum of "<< num1<<" and "<< num2<< "= "<< num1 + num2;
11 }

3
4. Compute Quotient and Reminder by asking dividend and divisor
from user.

1 //Computing Quotient and Remainder


2 #include <iostream>
3 using namespace std;
4 main(){
5 int dividend, divisor;
6 cout<< "Enter Dividend: ";
7 cin>> dividend;
8 cout<< "Enter Divisor: ";
9 cin>> divisor;
10 cout<< "\nQuotient: "<< dividend / divisor;
11 cout<< "\nRemainder: "<< dividend % divisor;
}

4
5. Find the largest number from three numbers entered by the user.

1 //Finding largest number


2 #include <iostream>
3 using namespace std;
4 main(){
5 int num1, num2, num3 =0;
6 cout<< "Enter three numbers: \n";
7 cin>> num1>> num2>> num3;
8 if(num1 > num2 && num1 > num3)
9 cout<< "Number "<<num1<<" is the largest.";
10 else if(num2 > num1 && num2 > num3)
11 cout<< "Number "<<num2<<" is the largest.";
12 else
13 cout<< "Number "<<num3<< " is the largest.";
14 }

You might also like