6. Write a C program that takes the coordinates of two line segments. Roll No…………………..
Then the program should check if these two line segments are parallel Dr B R Ambedkar National Institute of Technology, Jalandhar
to each other or not. [4] B Tech (All Branches) – 1st Semester
CSFC0101, Computer Programming
7. Consider the program given in Q9(d) and rewrite the program using
Mid-Semester Examination, October 2024
switch case so that the same output can be generated. [4] Duration: 02 Hours Max. Marks: 30 Date: 10 October 2024
8. Write a program in C that characterizes a tropical cyclone based on its
wind speed in knots. [4] Marks Distribution & Mapping of Questions with Course Outcomes (COs)
Wind speed in knots Characterization Question Number 1 2 3 4 5 6 7 8 9
Less than 50 Not a cyclone Marks 2 2 2 4 4 4 4 4 4
Between 51 and 120 Incipient disturbance CO No. 1 1 1 1 1 1 1 1 1
Between 121 and 135 Tropical storm Cognitive Level U R Ap Ap An C An C Ap
Between 136 and 175 Tropical cyclone
Between 176 and 200 Severe tropical cyclone
Note:
1. Attempt all the Nine questions available on Two pages.
Greater than 200 Very Severe tropical cyclone 2. Draw neat and clean diagrams.
3. Write all the possible steps in your solutions.
9. Write the output of the following code snippets with proper 4. If you are assuming something, then clearly mention it.
justifications. Answers without a proper justification will incur zero
1. Write the first 30 numbers of the hexadecimal number systems. Do
marks. [4]
not write a program for it. [2]
a) b)
#include<stdio.h> #include<stdio.h> 2. Describe the important components of a central processing unit in
void main(){ void main(){
int a=3; float a=0.7,b=0.7;
detail. [2]
switch(a){ if(a==0.7f) printf("A"); 3. Swap the values of two variables using bitwise operators. Note that
printf(“NITJ-CSE”); else printf("B");
case 5: printf(“five”); if(a==b) printf("C"); you are not allowed to use more than two variables. [2]
case 3: printf(“Three”); else printf("D");
default: printf(“Correct”); if(a==0.7) printf("E"); 4. Compute the largest and smallest positive floating-point number that
}
}
}
else printf("F"); can be stored using IEEE 32-bit single precision 754 floating-point
c) d) Compute for i=5. representation. [4]
#include<stdio.h>
void main(){
#include<stdio.h>
void main(){
5. Write a single-line expression for each of the following without using
int a = 30, b = 12, c, d; int i; any library functions. Do not write the full program. [4]
float x, y; scanf("%d", &i);
c = a / b * b; if (i == 1) a) Store the absolute difference between two variables in another
d = a++ + --c; printf("i = %d\n", i); variable.
x = (float) a / b * b; else if (i >= -2 && i <= 2)
y = (float) (a / b) * b; printf("i = 1\n"); b) Toggle the third bit of an integer stored in a variable.
printf ("%d %d %f %f", c, d, x, y); else if ((i > 4 || i < -4) &&
} (i == 5 || (i += 1)))
c) Print YES if x is a power of 2, otherwise NO.
printf("i = 5\n"); d) If the bitwise OR of A and B is greater than 100, and the bitwise
else if (i = 4)
printf("i = %d\n", i); AND of A and B is not zero, set the flag to true, otherwise false.
}