Coding Session Week 1 - Assignment 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

PERSONALITY DEVELOPMENT ASSOCIATION

MADRAS INSTITUTE OF TECHNOLOGY CAMPUS


CHROMPET, CHENNAI – 44

WEEKLY CODING SESSION 2023 - 2024

ASSIGNMENT-1 ATTACH OUTPUT SCREENSHOTS


1. Write a C++ program to get values in different data types from the users and display it to the user.
2. Write a C++ program to get the marks (6 Subjects) from a student, calculate Total, Average Cut-off
mark of that student and display it to the student.

3. Write a C++ program to assign value 5 to following variables a, b, c, d using a single statement.

4. Write a C++ program to get two values x and y, find out the quotient and remainder while dividing x by
y.

5. Write a C++ program to accept the following input (Input 1 and Input 2) and produce the output using
the respective operator.

Input 1 Input 2 Output

True False False

True False True

6. Write a C++ program to accept the following input and produce the respective output.

Input: 15.11112222

Output: 15. 111

7. Write a C++ program to apply increment/decrement operator on a = 10 sequentially and print the result
of each of the following.

1) a++

2) ++a

3) a--

4) a--

5) --a

8. Program to convert temperature from Celsius to Fahrenheit and vice versa using the following formula:
F = (C*9/5) +32. Sample input/output:

A)Enter temperature in Celsius 36.56 Temperature in Fahrenheit = 97.808

B)Enter temperature in Fahrenheit 97.808 Temperature in Celsius = 36.56

9. Program to input the values of two variables a and b and swap / interchange the values. Sample
input/output:

Enter the value of a 10


PERSONALITY DEVELOPMENT ASSOCIATION
MADRAS INSTITUTE OF TECHNOLOGY CAMPUS
CHROMPET, CHENNAI – 44

WEEKLY CODING SESSION 2023 - 2024

Enter the value of b 20

Before swapping: a = 10 , b = 20 After swapping: a = 20, b = 10

Note: Values of variables have to be updated. simply changing the order of printing variables will not be
accepted..

10. Write a C++ program and find the output of the following.

Expression Output

10 == 10 ?

11 > 12 ?

12>=13 ?

13 <10 ?

11. Write a C++ program that calculates the area of a rectangle using the length and width provided by the
user. Use arithmetic operators.
12. Write a C++ program that takes an integer as input and checks if it's even or odd. Use conditional
statements (if-else).
13. Write a C++ code snippet that checks if a number is positive, negative, or zero using conditional
statements.
14. Write a C++ program that takes three integers as input and finds the largest among them. Use
conditional statements (if-else if).
15. Write a C++ program that calculates the Grade Point Average (GPA) for a student based on their grades.
The program should take the grades as input, calculate the GPA, and display the result.
Here's how you should structure this program:
● Define a variable for each subject's grade (use integer values from 0 to 100).
● Calculate the GPA using the following grading scale: (A: 90-100, B: 80-89, C: 70-79, D: 60-69,
F: 0-59)
● Use conditional statements to determine the letter grade for each subject based on the provided
grades.
● Calculate the GPA by averaging the GPA equivalent for each subject.
● Display the calculated GPA.
For example, if a student has grades of 95 (A) in Math, 85 (B) in English, and 75 (C) in Science, the
program should calculate the GPA and output the result.
Theory Questions
1. List and briefly describe the fundamental data types available in C++.
2. Write the syntax of ternary conditional operators in C++ (?:)? Provide an example.
3. Explain the difference between the pre-increment operator (++x) and post-increment operator (x++) in
C++.
4. What is the difference between the switch statement and the if statement in C++? When would you use
one over the other?
5. What is the purpose of the logical AND (&&) and logical OR (||) operators in C++? Provide examples
of their usage.

You might also like