Pds Lab 2022A Question Paper Upto A03
Pds Lab 2022A Question Paper Upto A03
Note: Always read the instructions in the question very very carefully and get your doubts clarified.
a01-2. Write a C program that, when compiled and run on the terminal, prints a hello in the 1st line, and then
prints your name and roll number in the next line.
The name of your C file should be a01-2.c.
Example:
Hello!
I am Abdul Rao, my roll number is 22XY1009.
Write a C program that takes as inpu t two integers and from the keyboard, computes and
prints its value on the terminal.
The value of should be correct up to 6th decimal place.
The name of your C file should be w01-2.c.
Example
Enter a and b: 2 3
a/b = 0.666667
Note:
i. Any real number should be in floating-point precision, unless stated otherwise.
ii. Every printed real value should be correct up to the 6th decimal place, unless stated otherwise.
iii. You should submit the C file only. The name of your C file should be <assignment number>.c;
for example, for a02-1 it will be a02-1.c
iv. You can name the binary executable file during compilation; for example, for a02-1.c you can
name it a02-1.out instead of the default name a.out as follows:
gcc a02-1.c -o a02-1.out
v. The output format must be as in the examples for all the assignments. Otherwise there will be some
penalty.
vi. Marks will depend on the efficiency of your code. Try to use as few operations (addition, subtraction,
multiplication and division) as possible.
iii.
Example
Enter a, b, c: 3 2 4
a+b-c=1
-a-b+c=-1
a/b + b/c + c/a=3.333333
a02-2. Recall that the area of a triangle ABC is given by If the coordinates of its three vertices
are then it turns out to be
Given as input the coordinates of the three vertices of a triangle as integers, your program has to
compute and print its perimeter and area, correct up to the 3 rd decimal place. For perimeter
computation, you have to use the sqrt function of math.h library as follows.
#include <math.h>
Examples
Enter x: 0.8765677821
0.876567782
1+x(1+x(1+x(1+x(1+x(1+x)))))=4.880024516
1-x(1-x(1-x(1-x(1-x(1-x)))))=0.744789378
#multiplications=?
Enter x: 25.000123456789
25.000123457
1+x(1+x(1+x(1+x(1+x(1+x)))))=254320633.968345135
1-x(1-x(1-x(1-x(1-x(1-x)))))=234757601.247287929
#multiplications=?
Week 3: 28-Nov-2022
Logical expression, conditionals (if-else, switch-case)
a03-1. [Biquadratic equation] Write a program to compute and print the roots of
Assume that are real numbers taken as input in floating-point precision. [10 marks]
Idea: Substitute in to get and use its roots to get the roots of
If are the two complex roots of then the four roots of will be
where,
(2) If 6 or 8, then
(3) If then
Note: For two positive integers and is the remainder obtained when is divided by In C
language, is written as a%b. [10 marks]