Cp end sem 2024
Cp end sem 2024
Note:
1. Attempt all the TEN questions available on FOUR pages.
2. Write all the possible steps in your solutions.
3. If you are assuming something, then clearly mention it.
4. CALCULATORS ARE NOT ALLOWED.
1
3. a) Write a program to print 24 hours of a day with suitable suffixes
like AM, PM, Noon, and Midnight. [2]
b) Write a program that will read the value of x from the user and
evaluate the following function using a) nested if statements, b) else if
statements, and c) conditional operator. [2]
1 𝑓𝑜𝑟 𝑥 > 0
𝑦 = { 0 𝑓𝑜𝑟 𝑥 = 0
−1 𝑓𝑜𝑟 𝑥 < 0
2
5. Write a program in C that accepts a string that contains digits and
converts the string to an integer. For example, if the string is “124”,
then the output is 124. [4]
8. There is a car showroom with ten different cars. You need to construct
a structure to store the specifications of each car appropriately. The
car specification details are as follows: Name of the car, model
number, brand, color, weight, dimension (length and breadth), show-
room price and on-road price. [4]
#include<stdio.h> #include<stdio.h>
void foo(int *a, int b, int *c, int #include<string.h>
d){ void main()
*a = *a * 3; {
b = b * 3; char str1[]="CaLiCuT";
*c = *c * 3; char str2[]="cAlIcUt";
d = d * 3; printf("%d ",strcmp(str1,str2));
} if(strcmp(str1,str2) >= 0){
void main(){ strcpy(str1,str2);
int a=3, b=6, c=2, d=4; printf("%s",str1);
foo(&a,b--,&c,d+2); }
printf(“%d,%d,%d,%d”,a,b,c,d); else {
} strcpy(str2,str1);
printf("%s",str2);
}
}