0% found this document useful (0 votes)
73 views5 pages

Programming For Problem Solving (Csen 1001)

The document outlines the examination structure for the Programming for Problem Solving course (CSEN 1001) for various B.Tech programs. It includes multiple-choice questions and problem-solving tasks divided into groups, covering topics such as binary representation, C programming concepts, and file handling. Students are required to answer questions from different groups, ensuring a comprehensive assessment of their knowledge.

Uploaded by

aneeshpal956
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)
73 views5 pages

Programming For Problem Solving (Csen 1001)

The document outlines the examination structure for the Programming for Problem Solving course (CSEN 1001) for various B.Tech programs. It includes multiple-choice questions and problem-solving tasks divided into groups, covering topics such as binary representation, C programming concepts, and file handling. Students are required to answer questions from different groups, ensuring a comprehensive assessment of their knowledge.

Uploaded by

aneeshpal956
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
You are on page 1/ 5

B.

TECH/AEIE/CSBS/CSE/ECE/IT/2ND SEM/CSEN 1001/2021


B.TECH/AEIE/CSBS/CSE/ECE/IT/2ND 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) The expression 4 + 6 / 3 * 2 – 2 + 7 % 3 evaluates to
(a) 7 (b) 6 (c) 4 (d) 3.
(ii) Consider the following macro definition with arguments:
#define CUBE(x) (x*x*x)
Which of the following would be the correct expansion of the following
statement written in C?
volume = CUBE(a+b);
(a) volume = (a+b * a+b * a+b); (b) volume = ((a+b) * (a+b) * (a+b));
(c) both (a) and (b) (d) None of these.
(iii) Suppose both p1 and p2 are pointers to the same array. Now which of the
following operations on the pointers are not allowed in C language?
(a) p1 + p2 (b) p1 - p2 (c) p1+1 (d) p2++
(iv) Bootstrap program is stored in
(a) PROM (b) EEPROM (c) RAM (d) None of these
(v) Consider the following C statement, where a & b are two integer variables:
scanf(“%d %*d %d”, &a, &b);
If the input data is: 123 456 739, then which of the following value will be
assigned to the variable b?
(a) 123 (b) 456 (c) 739 (d) garbage value.
(vi) When printf() fails, it returns
(a) 0 (b) Negative number (c) NULL (d) None of these
(vii) Consider the following two statements written in C language:
FILE * fp;
fp = fopen(“TEST.TXT”, ”r+”);
CSEN 1001 1
B.TECH/AEIE/CSBS/CSE/ECE/IT/2ND SEM/CSEN 1001/2021
Which of the following operations can be performed on the file named as
“TEST.TXT”?
(a) only reading (b) only writing
(c) both reading and writing (d) appending.
(viii) Which of the following is the 2’s complement representation of -4?
(a) 1011 (b) 0100 (c) 1101 (d) 1100
(ix) Packed BCD representation of the decimal number 123 is
(a) 0000 0001 0010 0011 (b) 0001 0010 0011 0000
(c) 0000 0001 0000 0010 0000 0011 (d) None of these.
(x) In which part of a C program compilation process, file inclusion is dealt with?
(a) Assembling (b) Linking (c) Loading (d) Pre-processing

Group – B
2. (a) “Storing negative numbers using 1’s complement or 2’s complement
representation rather than signed magnitude representation leads to
substantial saving in circuitry” – Is the above statement TRUE or FALSE? Give
reasons against your answer.
(b) Find the sum of the following binary numbers represented in a 5-bit sign-
magnitude register and that uses 1’s complement to represent negative
numbers:
(i) -0110 and -0111
(ii) + 0011 and - 1101
(c) Draw a flowchart to print the sum of the digits of a number given by the user.
(1 + 2) + (2 + 2) + 5 = 12

3. (a) Convert the following:


(i) 25.62510 = (?)2
(ii) 362.358 = (?)10
(iii) 42A.1216 = (?)10
(b) Consider the decimal number +2.7. Convert this number to its equivalent
IEEE754 32-bit floating point representation.
(c) Consider the following IEEE754 32-bit pattern:
1 10000001 01000…00
What is the decimal value that the above pattern represents?
(2 + 2 + 2) + 3 + 3 = 12

Group – C
4. (a) Consider the following code snippets written in C along with their outputs. Give
the reasons in detail behind the results for each of the following cases.
i)
int main ()
CSEN 1001 2
B.TECH/AEIE/CSBS/CSE/ECE/IT/2ND SEM/CSEN 1001/2021
{
int a = 1, b = 2, c = 3;
printf (“%d \n", a += (a += 3, 5, a));
return 0;
}
The above code returns the output 8.
ii)
int main ()
{
int m=1, n=1, r=1, s=3, t=5, x;
x=++m && n++ && --r && s/2 && ++t;
printf ("\n m=%d, n=%d, r=%d, s=%d, t=%d, x=%d", m, n, r, s, t, x);
return 0;
}
The output of the above code is:
m=2, n=2, r=0, s=3, t=5, x=0
iii)
int main ()
{
int i =1024;
for (; i; i>>=1)
printf (“Hello world\n”);
return 0;
}
The above program prints “Hello World” 11 times.
(b) Write a C program to find which of the numbers is odd and which of the
numbers is even from a set of numbers given by the user using bitwise AND
operator.
Note that you don’t know in advance how many numbers are there and that’s
why you are not allowed to use array.
(3 + 2 + 2) + 5 = 12

5. (a) Consider the weekly salary of a salesperson who is selling some domestic
products. If x is the number of products sold in a week, then the weekly salary is
given by the following rules:
4x + 100 for x < 40
Salary = 300 for x = 40
4.5x + 150 for x > 40
(i) Write the if…else statements in C language to represent the above rules
Replace the if…else statements written in part (i) above with its equivalent
expression using conditional operator.
(b) Suppose you want to write a ‘if’ statement in a C program as follows, where
‘payCode’ is an integer variable:
if (payCode = = 4)
CSEN 1001 3
B.TECH/AEIE/CSBS/CSE/ECE/IT/2ND SEM/CSEN 1001/2021
printf (“\n You get a bonus”);
But by mistake the ‘if’ statement is written as follows:
if (payCode = 4)
printf (“\n You get a bonus”);
Do you get the same result for this mistake? Give reasons against your answer.
(c) Write a C program to print the following pattern where the number of rows in
the pattern is a user input.
****
***
**
*
**
***
****
(2 + 2) + (1 + 2) + 5 = 12

Group – D
6. (a) What do you mean by storage class of a variable in C language? What is the
default storage class of C variables? What is the scope and longevity of static
variables?
(b) How can you allocate a 2-D integer array with 2 rows and 3 columns
dynamically in C? Show the steps using an example
(c) Write a C program to insert an element (given by the user) into an array at a
particular valid position (given by the user) assuming that the array is not full.
Insertion will take place in an user defined function, which will be called by your
main() by passing the array and the position where insertion will take place.
You should access the array elements by using pointers only.
(2 + 1 + 1) + 3 + 5 = 12

7. (a) Write a recursive function in C language that will print the binary equivalent of a
given positive integer. Note that your program should not contain any
iterations, like ‘for loop’, ‘while loop’, ‘do-while loop’.
(b) What is the effect of accessing a [5] in an integer array of size 5 i.e., int a [5]?
(c) The header file string.h contains a library function strcat (string1, string2), that
appends character array string2 to the character array string1. Write a C
program using function that will behave exactly the same way strcat (string1,
string2) behaves. Elements of character arrays will be accessed through
pointers.
5 + 2 + 5 = 12

CSEN 1001 4
B.TECH/AEIE/CSBS/CSE/ECE/IT/2ND SEM/CSEN 1001/2021

Group – E
8. (a) Write a C program which will print the executable file name when you run your
program. You are also supposed to show how you run the program from the
command prompt.
(b) How can you test whether a file is opened successfully or not? Give example.
(c) Write a C program to copy the contents of a source file to a destination file,
where names of both files are supplied as command line arguments.
3 + 3 + 6 = 12

9. (a) Consider the following structure definition followed by one C statement:


struct student
{
char name [30];
int roll_number;
int marks;
} s [2], *ptr;
ptr = s;
What ‘ptr’ will contain? If ‘ptr’ is increased by 1 then what it will point to?
(b) Write a program in C to define a structure named student with members – name
(string), roll (integer) and CGPA (float). It should be able to take n many
students’ details as input and print the details of the student who obtained
highest CGPA.
(c) Write the uses of the following file handling functions along with their proper
syntax: ferror(), ftell(), rewind(), fseek().
2 + 6 + 4 = 12

Department &
Submission Link
Section
AEIE https://classroom.google.com/c/MzEyOTI5NTQ1MzU2/a/Mzc0MjE2MTk4NTg0/details
CSBS https://classroom.google.com/c/MzExOTEwMDk0ODcw/a/Mzc0MTk4MDQ0NjY0/details
CSE - A https://classroom.google.com/c/MzExMDM2MDMwMjg5/a/Mzc0MjIxMTM1MDU4/details
CSE - B https://classroom.google.com/c/MzEyMTgwMTgyNzM5/a/Mzc0MjI0MjA2MDUw/details
CSE - C https://classroom.google.com/c/MjgwODI4MDc4NDE2/a/Mzc0MTM2ODk1NjQ3/details
ECE - A https://classroom.google.com/w/Mjk3MjI5Nzc2MDk4/t/all
ECE - B https://classroom.google.com/c/MzEyNTE0NzAyMTc1/a/MzcxNjYwNTUwMjY1/details
ECE - C https://classroom.google.com/w/Mjk3MjQwNTM1Mzcz/t/all
IT https://classroom.google.com/c/MzExNjAwMzk2OTA5/a/Mzc0MjA4MTEyNTM0/details

CSEN 1001 5

You might also like