0% found this document useful (0 votes)
0 views

Cp end sem 2024

This document outlines the end-semester examination for the Computer Programming course at Dr B R Ambedkar National Institute of Technology, Jalandhar, scheduled for December 2, 2024. It includes details on the marks distribution, cognitive levels, and a list of ten questions covering various programming concepts and tasks, such as array initialization, pointer usage, and program writing in C. Students are instructed to attempt all questions, provide detailed solutions, and are prohibited from using calculators.

Uploaded by

simrang2209
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Cp end sem 2024

This document outlines the end-semester examination for the Computer Programming course at Dr B R Ambedkar National Institute of Technology, Jalandhar, scheduled for December 2, 2024. It includes details on the marks distribution, cognitive levels, and a list of ten questions covering various programming concepts and tasks, such as array initialization, pointer usage, and program writing in C. Students are instructed to attempt all questions, provide detailed solutions, and are prohibited from using calculators.

Uploaded by

simrang2209
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Roll No…………………..

Dr B R Ambedkar National Institute of Technology, Jalandhar


B Tech (All Branches) – 1st Semester
CSFC0101, Computer Programming
End-Semester Examination, December 2024
Duration: 03 Hours Max. Marks: 50 Date: 02 December 2024

Marks Distribution & Mapping of Questions with Course Outcomes (COs)


Question 1 2 3 4 5 6 7 8 9 10
Number
Marks 10 4 4 3 4 4 4 4 5 8
CO No. 1,2,3 1 1 1 2 2 2 3 2 1,2
Cognitive U Ap An An Ap C An C Ap An
Level

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. Answer the following questions with proper examples. [2x5]


a) Write all the different ways to initialize a 2-D array.
b) What is a pointer to an array?
c) Write the function declaration and function call of the function
foo() that accepts two arguments and returns a float. Note that one
of the arguments must be passed by value and the other by
reference.
d) Explain a constant pointer to an integer.
e) What is a register storage class? What type of variables can be
declared as register storage classes?

2. a) Write the IEEE 32-bit floating point standard representation of the


following numbers: i) -7024 ii) 6.484375. [2]

b) Convert the following numbers into base 9: [2]


i) (3897)10 ii) (1AF)16 iii) (6573)8 iv) (542)6

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

4. A Niven number in mathematics is an integer divisible by the sum of


its digits. A C program to compute a Niven number is given below.
Each line number in the program is marked with a line number. Write
the appropriate C statements in the line numbers to complete the
program. Note that a curly brace is also considered as a line. Writing
any extra line will fetch zero marks. [3]
L1: #include<stdio.h>
L2: int main()
L3:{
L4: unsigned int num,sum=0,value;// Declaration of variables
L5: scanf(_____________); // Input a number to check
L6: value = num;
L7: ___________________
L8: ___________________
L9: ___________________
L10: ___________________
L11: ___________________
L12: ___________________
L13: if(_________________)
L14: ___________________
L15: ___________________
L16: ___________________
L17: return 0;
L18:}

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]

6. Write a C program that accepts a positive integer through the


keyboard, and write a recursive function to obtain the prime factors of
the number. [4]

7. Suppose a 2D Array is given as follows: int A[4][5] =


{5,1,4,7,3,2,8,9,0,1,3,2,8,5,4,8,6,3,1,2}. Assuming the size of an
integer is 2 bytes and the base address of the array is 1260, compute
the values of the following: a) A, b) A+2, c) A[3], d) A[2]+3, e)
&A[1], f) &A[2]+3, g) *(&A[2]+2), h) &A[6]+2. [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]

9. Write a program in C to sort the given array of elements using


insertion sort. Then explain your program step by step using the
following array: A[]={40, 20, 10, 90, 60, 70, 80}. [5]

10. Answer the following questions with proper justifications. Answers


without a proper justification will incur zero marks. [2x4]

a) Compute the total space required b) How Many time “NITJ” is


to store set[1000]. printed?
typedef struct{ #include<stdio.h>
int xcoord; void main(){
int ycoord; int x;
}point; for(x=-1;x<=10;x++){
typedef struct{ if(x<5)
point vertex[3]; continue;
}Triangle; else
Triangle set[1000]; break;
printf(“NITJ”);
}
}
3
b) What is the output of the following d) What is the output of the following
program? program?

#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);
}
}

You might also like