0% found this document useful (0 votes)
12 views6 pages

Programming For Problem Solving (Csen 1001)

Uploaded by

Debian Roy
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)
12 views6 pages

Programming For Problem Solving (Csen 1001)

Uploaded by

Debian Roy
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

B.

TECH/BT/CE/CHE/CSE(AI&ML)/CSE(DS)/EE/ME/1ST SEM/CSEN 1001/2021


B.TECH/BT/CE/CHE/CSE(AI&ML)/CSE(DS)/EE/ME/1ST SEM/CSEN 1001/2021

PROGRAMMING FOR PROBLEM SOLVING


(CSEN 1001)

Time Allotted : 3 hrs Full Marks : 70


Figures out of the right margin indicate full marks.
Candidates are required to answer Group A and
any 5 (five) from Group B to E, taking at least one from each group.
Candidates are required to give answer in their own words as far as practicable.

Group – A
(Multiple Choice Type Questions)

1. Choose the correct alternative for the following: 10 × 1 = 10


(i) Which of the following cannot be a member of a structure in C language?
(a) Function (b) Array (c) Another structure (d) Pointer variable
(ii) sizeof(int)returns the length of an integer. In C, sizeofis -
(a) Operator (b) Reserved word/Keyword
(c) Function (d) Both (a) and (b)
(iii) Which of the following is correct as far as the speed of the memory is
concerned?
(a) CPU registers > Cache Memory > RAM > Hard disk
(b) CPU registers < Cache Memory < RAM < Hard disk
(c) Speeds of all these types of memory are same
(d) Speed varies depending on the situation
(iv) Macro substitution is done at -
(a) post-compilation stage (b) pre-compilation stage
(c) compilation stage (d) run-time
(v) Left shift operation by 1 bit in C is equivalent to ___________________.
(a) Division by 2 (b) Multiply by 2
(c) Adding 2 (d) Subtracting 2
(vi) What is actually passed if you pass a structure variable to a function as an
argument?
(a) Copy of structure variable
(b) Reference of structure variable
(c) Starting address of structure variable
(d) Starting and ending address of structure variable

CSEN 1001 1
B.TECH/BT/CE/CHE/CSE(AI&ML)/CSE(DS)/EE/ME/1ST SEM/CSEN 1001/2021
(vii) What will be the output of the following C program?
#define no 5+3
int main()
{
int result;
result=no*no*no;
printf("%d",result);
return 0;
}
(a) 512 (b) 38
(c) Compile time error (d) None of the above
(viii) Suppose that x is a one-dimensional array, then choose the correct answer
regarding array from the following:
(a) *(x+i)is same as&x[i] (b) *&x[i]is same as(x+i)
(c) *(x+i)is same asx[i] (d) *(x+i)is same asx[i]+1
(ix) Which of the following four assignments in C is valid after the following
declaration?
int A[10], B[20], *C;
(a) A = B (b) B = C (c) A = C (d) C = A
(x) Which of the following is not a valid name of a C variable?
(a) result22 (b) _result22 (c) 22result (d) re2sult2

Group- B

2. (a) Compute the following:


(67.89)10 = (?)8 = (?)16
Show all the intermediate steps. [(CO1) (Understand /LOCQ)]
(b) Following is the IEEE-754 32-bit single precision representation of a floating-
point number.
Find the decimal value closest to this floating-point number.
00111110011011010000000000000000. [(CO1) (Understand/LOCQ)]
(c) Draw a flowchart to find whether a number given by the user is prime or not.
[(CO2)(Apply/IOCQ)]
(2 + 2) + 4 + 4 = 12

3. (a) Given, (121)r=(144)8. Find the base r. [(CO1) (Analyze/IOCQ)]


(b) Compute the following:
(111001)2 – (1001)2 using 2’s complement method.[(CO1) (Understand/LOCQ)]
(c) What is the advantage of using complement method in binary arithmetic? What
are the advantages of using 2’s complement over 1’s complement?
[(CO1)(Understand/LOCQ)]
6 + 2 + (2 + 2) = 12

CSEN 1001 2
B.TECH/BT/CE/CHE/CSE(AI&ML)/CSE(DS)/EE/ME/1ST SEM/CSEN 1001/2021
Group - C
4. (a) Explain the output of the following C programs:
i. int main()
{
int i = -1, j = -1, k = 0, m = 2, n;
n = i++ &&j++&& k++ || m++;
printf("%d %d %d %d %d", i, j, k, m, n);
return 0;
}

ii. int main()


{
int i;
for (i = 1; i< 10; i<<=1)
printf(“%d”, i);
return 0;
}

iii. int main()


{
int x=1, y=1, z=1;
x += y += z;
printf(“%d\n”, x < y ? y : x);
printf(“%d\n”, x < y ? x++ : y++);
printf(“%d\n”, x) ; printf(“%d\n”, y);
return 0;
}
[(CO2) (Evaluate/HOCQ)]
(b) Express the following if...else statements written in C using ternary operator:
if (x + y >= 30)
value = 30;
else if (x + y >= 25)
value = 25;
else
value = 20; [(CO3) (Understand/LOCQ)]
(c) What is the difference between explicit and implicit type casting? Explain with
an example. [(CO3) (Remember/LOCQ)]
(2 + 2 + 3) + 3 + 2 = 12

5. (a) State the differences between a ‘while’ loop and a ‘do-while’ loop. Give a suitable
example where ‘do-while’loop is preferred over ‘while’ loop.
[(CO6) (Understand/LOCQ)]

CSEN 1001 3
B.TECH/BT/CE/CHE/CSE(AI&ML)/CSE(DS)/EE/ME/1ST SEM/CSEN 1001/2021
(b) Write a C program to take the number of rows to be printed as input and display
the following pattern as output. As for example, if the number of rows to be
printed is 5 then the output will look like as follows:
* *
** **
*****
** **
* *
[(CO5) (Create/HOCQ)]
(c) Write a C program to find the sum of the following series:
x x 2 x3
1     ...upto 50 terms
1! 2! 3!
Note that the value of neither 40! nor x40 can be calculated.
[(CO4) (Create/HOCQ)]
(2 + 2) + 4 + 4 = 12

Group - D

6. (a) Show how to enter two integers and print their sum using command line
arguments. If the number of integers is less than 2, show appropriate error
message. You may take the help of a C program for this.
[(CO5) (Understand/LOCQ)]
(b) Distinguish between following (i) and (ii):
i. int* ip[10] and int (*ip)[10]
ii. int p(char *a) and int *p(char *a). [(CO3) (Understand/LOCQ)]
(c) Write a program in C to delete an element from a particular position in an array
where position will be a user input. After deletion, array elements must be in
continuous locations. [(CO5) (Create/HOCQ)]
4 + (2 + 2) + 4 = 12

7. (a) Write a recursive function to calculate the sum of all digits of a number entered
by the user. Also write the main() to test the function. [(CO5) (Create/HOCQ)]
(b) What are the advantages of using dynamic memory allocation over static
memory allocation? Is there any disadvantage of dynamic memory allocation?
[(CO6) (Understand/LOCQ)]
(c) If an array is passed to a C function as an argument and some of its elements are
modified within the function, are these modifications visible in the calling
function of the program? Explain. [(CO3) (Analyse/IOCQ)]
4 + (2 + 2) + 4 = 12

Group - E

8. (a) What is the difference between the file opening modes “r+” and “w+”?
[(CO3) (Remember/LOCQ)]
(b) Define a structure called Point having two float type variables, representing the
x-coordinate and y-coordinate of the point.
CSEN 1001 4
B.TECH/BT/CE/CHE/CSE(AI&ML)/CSE(DS)/EE/ME/1ST SEM/CSEN 1001/2021
Write a C function named as ‘distance’ to calculate the distance between two
points using the Point structure defined above. The prototypeof the function is
given below:
float distance(Point, Point)
Note: Given two points (x1, y1) and (x2, y2), the formula to calculate the distance
between them is:
distance = ( x2  x1 )2  ( y2  y1 )2
Write anotherC function named as ‘mid’ to find the mid-point between two
points using the
Point structure defined above. The prototypeof the function is given below:
Point mid(Point, Point)
Note: Given two points (x1, y1) and (x2, y2), the mid-point between them is given
by:
x1  x2 y1  y2 
Coordinates of the mid-point:  , 
 2 2 
Write a main() function to test the above two functions.[(CO5) (Create/HOCQ)]
2 + 10 = 12

9. (a) Write a program in C to read a data file, to print the size of the file and to print
the last 5 characters from the file. Use separate function for different operation.
[(CO5) (Create/HOCQ)]
(b) Write a program in C to define a structure named Customer with members -
Name (string), Account_No(integer) and Balance (float). It should be able to take
n many customers’ details as input and search for a particular customer by the
account number. Write a separate function for searching operation.
[(CO5) (Create/HOCQ)]
6 + 6 = 12

Cognition Level LOCQ IOCQ HOCQ


Percentage distribution 38.54% 14.58% 46.88%

Course Outcome (CO):


After the completion of the course students will be able to:
CO1: Understand and remember functions of the different parts of a computer.
CO2: Understand and remember how a high-level language (C programming language,
in this course)works, different stages a program goes through.
CO3: Understand and remember syntax and semantics of a high-level language (C
programming language,in this course).
CO4: Understand how code can be optimized in high-level languages.
CO5: Apply high-level language to automate the solution to a problem.
CO6: Apply high-level language to implement different solutions for the same problem
and analyse whyone solution is better than the other.

CSEN 1001 5
B.TECH/BT/CE/CHE/CSE(AI&ML)/CSE(DS)/EE/ME/1ST SEM/CSEN 1001/2021
*LOCQ: Lower Order Cognitive Question; IOCQ: Intermediate Order Cognitive Question;
HOCQ: Higher Order Cognitive Question

Department &
Submission Link
Section
BT https://classroom.google.com/u/1/w/NDA1ODY2MzE1OTM0/tc/NDY3OTg5NDY4NTY0
CE https://classroom.google.com/c/NDA2MDk3ODY4NTY1/a/NDY3Nzc3OTU4NjYx/details
CHE https://classroom.google.com/c/NDA2MDk5NTQwMTc3/a/NDY3Nzc5MzM4MTE0/details
CSE
https://classroom.google.com/c/NDA1MzEwOTQzODYy/a/NDY0MjAwODc4ODYx/details
(AI&ML)
CSE(DS) https://classroom.google.com/w/NDA1MTkzMTc0Nzg2/tc/NDc0ODM0Mzk1MzQw
EE https://classroom.google.com/c/NDA2MDkwMjk4OTI5/a/NDU5ODI0NDM5NDIy/details
ME https://classroom.google.com/w/NDA1NTg0MzE4NDY1/tc/MjI3ODkwMDQxNjk2
CSEN1001 Backlog Students Google Classroom Joining Link
https://classroom.google.com/c/NDA1ODY2MzE1OTM0?cjc=aitezyg
Backlog CSEN1001 Backlog Semester Exam Paper Submission Link
https://classroom.google.com/c/NDA1ODY2MzE1OTM0/a/NDY3OTg5NDY4Mjcz/details

CSEN 1001 6

You might also like