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

LAB C++ Basics

The document outlines guidelines for a LAB manual focused on programming fundamentals using C++, specifically covering loops, conditional control structures, and operators. It includes a list of 50 exercises that students must complete, compile, and document by a deadline of March 3, 2025. Students are encouraged to use specific IDEs for development and must save their lab files with designated naming conventions.

Uploaded by

syedbaran438
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

LAB C++ Basics

The document outlines guidelines for a LAB manual focused on programming fundamentals using C++, specifically covering loops, conditional control structures, and operators. It includes a list of 50 exercises that students must complete, compile, and document by a deadline of March 3, 2025. Students are encouraged to use specific IDEs for development and must save their lab files with designated naming conventions.

Uploaded by

syedbaran438
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

[Programming Fundamentals] – LAB Exercises BS (CySec)

Instructor: (Dr. Aamir Raza) Page 1 of 3

Guidelines for LAB Manual - Based on only Loops, Conditional Control Structure, Operators
1. Write a separate C++ program for each task.
2. Compile and run each program to verify the output and save screen shot for LAB
Manual.
3. Output of each program should be clearly depicted according to Programming Exercise.
Very Important:
The lab name must be saved according to the lab number. For example, if the lab number is 2
or 3, its name must be labexercise02.cpp or labexercise03.cpp

In the Security Lab you have access to DEV-C++ as the default IDE. But you may also
choose to download and use any of the following alternatives:

1. CLion → Click to https://www.jetbrains.com/clion/


2. Code::Blocks → Click to https://www.codeblocks.org/
3. Visual Studio Code (VS Code) → Click to https://visualstudio.microsoft.com/
4. Eclipse CDT → Click to https://projects.eclipse.org/projects/tools.cdt
https://github.com/eclipse-cdt

Recommendation:

I recommend Visual Studio Code or Eclipse CDT for a better development experience. But you
are also free to choose any C/C++ IDE based on your laptop/desktop's memory and processing
capabilities.

LAB Exercises [1-50] ----- Deadline: March 03, 2025

1. Add and subtract two numbers.


2. Multiply and divide two numbers.
3. Find the remainder of division (modulus operator).
4. Increment a number using the pre-increment operator
5. Increment a number using the post-increment operator.
6. Decrement a number using the pre-decrement operator
7. Decrement a number using the post-decrement operator
8. Demonstrate the difference between pre-increment and post-increment with code
9. Demonstrate the difference between pre-decrement and post-decrement with and code.
10. Calculate the sum of three numbers
11. Find the average of three numbers
12. Calculate the area of a rectangle (length × width)
13. Calculate the area of a circle (π × radius², where value of π = 3.1416)
14. Calculate the perimeter of a rectangle (2 × (length + width))
[Programming Fundamentals] – LAB Exercises BS (CySec)
Instructor: (Dr. Aamir Raza) Page 2 of 3
15. Swap two numbers using arithmetic operators (without a third variable)

16. Find the square of a number using multiplication


17. Find the cube of a number using multiplication
18. Calculate simple interest using the formula (P × R × T / 100).
19. Write a program to print numbers from 1 to N using a for loop.
20. Write a program to calculate the sum of the first N natural numbers using a for loop.
21. Write a program to calculate the factorial of a number using a for loop.
22. Write a program to display the multiplication table of a given number using a for loop.
23. Write a program to check if a number is prime or not using a for loop.
24. Write a program to print numbers from 1 to N using a while loop.
25. Write a program to find the sum of digits of a given number using a while loop.
26. Write a program to count the number of digits in a given number using a while loop.
27. Write a program to print the Fibonacci series up to N terms using a while loop.
28. Write a program to find the largest digit in a given number using a while loop.
29. Write a program to check if a number is prime or not using a do-while loop.
30. Write a program to calculate the sum of the first N natural numbers using a do-while
loop.
31. Write a program to reverse a given number using a do-while loop.
32. Write a program to calculate the power of a number using a do-while loop.
33. Write a program to check whether a given number is even or odd using an if-else
statement.
34. Write a program that takes an integer (1-7) and prints the corresponding day of the week
using a switch statement.
35. Write a program to perform simple arithmetic operations (addition, subtraction,
multiplication, and division) based on user input using a switch statement.
36. Find the largest and smallest number in a given list of N numbers (use for or while loop
with if condition).
37. Check if a number is an Armstrong number (use while loop and if condition).
38. Check if a number is a Strong number (use for loop and if condition).
39. Find the sum of even and odd numbers separately from 1 to N (use for loop with if-else).
40. Generate and display all prime numbers between two given numbers (use for loop with
if condition).
41. Display the Fibonacci series up to N terms and check if each number is even or odd (use
for loop with if-else).
42. Find the sum of digits of a number and check if it’s prime (use while loop with if
condition).
43. Reverse a number and check if it is a palindrome (using while loop along with if-else).
44. Print numbers in words (e.g., input: 123 → output: One Two Three) (use while loop and
switch-case).
45. Count the occurrences of each digit in a given number (use while loop with an array and
if condition).
46. Find the factorial of a number and check if it's even or odd (use for loop with if-else).
[Programming Fundamentals] – LAB Exercises BS (CySec)
Instructor: (Dr. Aamir Raza) Page 3 of 3
47. Create a number guessing game where the user has limited attempts (use do-while loop
with if-else).---- You need to work on this logic… In your childhood, you played such
games with your friends.
48. Display a pattern (like a pyramid or diamond) based on user input (use nested for loops
with if conditions).
49. Find the HCF (GCD) of two numbers using a loop and conditional statements (use while
loop with if conditions).
50. Develop a simple ATM system where users can deposit, withdraw, and check balance
using a menu-driven approach (use do-while loop and switch-case).

In case of any questions; you may send an email or ask during class.

You might also like