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

C++ Lab2

for Cout and Cin
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

C++ Lab2

for Cout and Cin
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Lecture 2: Data Types and Variables

1. Declare an integer, float, and character variable in a program.

2. Create a program to swap two integers without using a temporary variable.

3. Write a program to add two integers and display their sum.

4. Create a program that declares and initializes an integer array.

5. Write a program that uses const to declare a constant and print its value.

6. Create a program that prints the size of different data types (int, float, char, etc.).

7. Write a program that demonstrates the overflow of an integer.

8. Create a program that swaps two numbers using a third variable.

9. Write a program that initializes a character and prints its ASCII code.

10. Create a program to find the maximum of two variables using conditional operators.

11. Write a program to find the square of an integer.

12. Create a program that declares a double variable and outputs its value.

13. Write a program to demonstrate typecasting (convert float to int).

14. Create a program to calculate the sum of three float numbers.

15. Write a program to find the average of three integers.

16. Create a program that converts an integer into a float.

17. Write a program to demonstrate the use of the bool data type.

18. Create a program that swaps the values of two characters.

19. Write a program that initializes and prints a string.

20. Create a program that takes three different numbers and finds the largest one.

You might also like