Problem Solving Through Programming In C NPTEL Assignment 2

                     

Course Name: Problem Solving Through Programming In C NPTEL

Link of course: Click Here

These are answers for Problem Solving Through Programming In C NPTEL Assignment 2


Q1. A function is
a) Block of statements to perform some specific task
b) It is a fundamental modular unit to perform some task.
c) It has a name and can be used multiple times
d) All of the above

Answer: d) All of the above


Q2. If an integer needs two bytes of storage, then the minimum value of a signed integer in C would be
a) -(2-16-1)
b) 0
c) -(215 –1)
d) -215

Answer: d) -215


Q3. Which of the following statements is correct?
I.     Keywords are those words whose meaning is already defined by Compiler.
II.    Keywords cannot be used as variable names.
III.   There are 32 keywords in C
IV.   C keywords are also called reserved words.

a) I and II
b) II and III
c) I, II and IV
d) All of the above

Answer: d) All of the above


Q4. What will be the output?

#include<stdio.h>
int main() {
int x = 1, y = 3;
int t=x;
x=y;
y =t;
printf("%d %d", x, y),
return 0;
}

a) 1 3
b) 3 1
c) 1 1
d) 3 3

Answer: b) 3 1


Q5. When executed the following code will print ______________ .

#include <stdio.h>
int main() {
     int sum=3+6/2+6*2;
     printf("%d", sum);
     return 0;
     }

Answer: 18


These are answers for Problem Solving Through Programming In C NPTEL Assignment 2


Q6. Which of the following are not standard header files in C?

a) stdio.h
b) conio.h
c) string.h
d) All are standard header file

Answer: d) All are standard header file


Q7. What is the output of the following code?

#include<stdio.h>
#define fun(x) (x*x-x)
void main()
{
  float i;
  i=37.0/fun(2);
  printf("%.2f", i);
}

Answer: 18.50


Q8. Which of the following is not a C variable?

a) Var123
b) Var_123
c) 123Var
d) X_123_Var

Answer: c) 123Var


Q9. What is the output of the following program?

a) 6
b) 3
c) 4
d) Compilation error

Answer: d) Compilation error


Q10. The following C program swaps the value of two numbers without using any third variable. What are the correct operations that need to be inserted inside the blanks?

#include <stdio.h>
int main()
{
  int a=2, b=3;
  printf("The values before swapping a =%d, b=%d", a, b);
  ____; ____; ____;
  printf("The values after swapping a=%d, b=%d", a, b);
  return 0;
}

a) a=a-b; b=a-b; a=a+b;
b) a=a%b; b=a+b; a=a/b;
c) a=a+b; b=ab; a=a-b;
d) None of the above

Answer: c) a=a+b; b=ab; a=a-b;


These are answers for Problem Solving Through Programming In C NPTEL Assignment 2

All weeks of Problem Solving Through Programming In C: Click Here

More NPTEL Solution: Click me


* The material and content uploaded on this website are for general information and reference purposes only. Please do it by your own first.


These are answers for Problem Solving Through Programming In C NPTEL Assignment 2