0% found this document useful (0 votes)
226 views2 pages

PDS Lab Assignment 2 Overview

This document outlines 6 programming assignments: 1) Determine characteristics of roots of a quadratic equation 2) Check divisibility of a number by 5 and 3 3) Swap values of two variables 4) Encode a 4-digit message into another 4-digit encoded message 5) Calculate a final score and grade based on marks and attendance 6) Implement a basic calculator to perform addition, subtraction, multiplication, and division
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)
226 views2 pages

PDS Lab Assignment 2 Overview

This document outlines 6 programming assignments: 1) Determine characteristics of roots of a quadratic equation 2) Check divisibility of a number by 5 and 3 3) Swap values of two variables 4) Encode a 4-digit message into another 4-digit encoded message 5) Calculate a final score and grade based on marks and attendance 6) Implement a basic calculator to perform addition, subtraction, multiplication, and division
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

IIT Bhubaneswar

PDS Lab (Section 4)


Assignment 2 Date: 9/12/2020
1. Read coefficients a, b and c for a quadratic equation ax2+bx+c = 0. Print the roots and
characteristics of the roots in following format:

The roots are real and distinct


Root 1 = <root1> and Root 2 = <root2>

The roots are real and equal


Root 1 = Root 2 = <val>

The roots are imaginary


Root 1 = <p> + i <q> and Root 2 = <p> - i <q>

2. Read an integer X. Determine if X is divisible by 5 and by 3. The output should be in the


following format:

<value of X> is divisible by 5 and not divisible by 3


<value of X> is divisible by 3 and not divisible by 5
<value of X> is divisible by both 5 and 3
<value of X> is neither divisible by 5 nor by 3

3. Read two numbers X and Y. Swap (exchange) the value of X and Y using arithmetic
operations. The output will be in the following format:

Before swap
X = <val1> Y = <val2>
After swap
X = <val 2> Y = <val 1>

4. A messaging system reads message as 4-digit positive integer d1d2d3d4 and stores
encoding of the message e1e2e3e4 for security reason. The encoding process is as follows:
ei = (ei+i) mod 4

For example, if message is 4590, the encoded message is 1300.


Read any arbitrary message and display the encoded message in the following format:

Original message =
Encoded message =

5. Your score of PDS Lab is determined as follows:

Final Score (T) = Marks obtained (M) X Attendance weight (W)


Attendance weight (W) = no of classes attended (N) / Total number of classes conducted
(K)

Then your grade is decided as follows:

T >= 90 ➔ Grade = EX
T >= 80 and T < 89 ➔ Grade = A
T >= 70 and T< 79 ➔ Grade = B
T > = 60 and T < 69 ➔ Grade = C
T > = 50 and T < 59 ➔ Grade = D
T > = 40 and T < 49 ➔ Grade = P
T < 40 ➔ Grade = F

Read the values of M, N and K such that M is between 0 and 100; N < = K and print Final
score and Grade in the following format:

Final Score =
Grade is

6. Implement a simple calculator with four operations Addition, Subtraction, Multiplication,


Division using switch statement:

Case ‘+’ : Result = <operand 1> + <operand 2>


Case ‘-’ : Result = <operand 1> - <operand 2>
Case ‘x’ : Result = <operand 1> x <operand 2>
Case ‘/’ : Result = <operand 1> / <operand 2>

Your program will read operand 1 and operand 2 and the character constant c for the
respective operation and will display:

Operation is <Addition/Subtraction/multiplication/Division>
Result =

You might also like