ITC Lab 03 - Input, Output, Variables
ITC Lab 03 - Input, Output, Variables
Lab 03
Course Instructor: Fraz Aslam
Instructions:
• Create separate C++ source files for each task, named as “task1.cpp”, “task2.cpp”, and so on
depending on the task number.
• After completing all tasks, place all .cpp files into a folder. Name the folder with your
university registration number (e.g., L1F20BSCS0999). Compress the folder into a .zip file
and upload it on the portal.
• Ensure that the work you submit is entirely your own. Avoid copying from peers, online
sources, or any other unauthorized material. Plagiarism will not be tolerated.
• If you encounter difficulties, feel free to reach out to the instructor. Collaboration and
discussion are encouraged, but the final implementation should be your own work.
• Write clean and well-structured code. Use comments to explain key sections of your code to
make it easier for others (and yourself) to understand.
• These tasks are designed to help you strengthen your logical thinking and problem-solving
skills. Think through each problem carefully before starting to code. The aim is to develop a
deep understanding of the problem and to devise solutions independently.
C++ Variables
In C++, variables are used to store data values that can change during the execution of a
program. Each variable has a specific type, which defines the kind of data it can hold, such as
integers, floating-point numbers, or characters.
cout (Output in C++)
cout is used in C++ to print output to the console. It belongs to the C++ Standard Library and is
defined in the iostream header.
The << is called the "insertion operator" and is used to send data to the output stream (cout).
You can output multiple items by chaining them with <<.
Task 1
Write a C++ program that asks the user to input two numbers and then outputs their sum,
difference, product, and quotient.
Task 2
Write a program that converts temperature from Celsius to Fahrenheit.
• Formula: F = (9/5)*C + 32
• Example Input: 25 (Celsius)
• Example Output: 77 (Fahrenheit)
Task 3
Create a program that asks the user for the radius of a circle and calculates its area.
Task 5
Write a program that takes an integer as input and outputs the remainder when divided by 2, 3,
and 5.
Task 6
Write a program that asks the user to input their age in years and calculates their age in days.
Task 7
Create a program that takes an input in minutes and converts it to hours and minutes.
Task 9
Write a program that calculates simple interest based on user input.
• Formula: Simple Interest = (A*R*T)/100 where A is the amount, R is the rate of interest, and
T is the time in years.
• Example Input: 1000 5 2
• Example Output: Simple Interest = 100
Task 10
Write a program that takes a two-digit number as input and prints the sum of its digits.
• Example Input: 45
• Example Output: The sum of digits is 9.