NPTEL Problem Solving Through Programming In C Week 3 Assignment Answers
Q1. Which of the following statements is correct?
a. Operator precedence determines which operator is performed first in an expression with more than one operator with different precedence. Associativity is used when two operators of same precedence appear in an expression
b. Operator associativity determines which operator is performed first in an expression with more than one operator with different associativity. Precedence is used when two operators of same precedence appear in an expression
c. Operator precedence and associativity are same.
d. None of the above
Answer: a. Operator precedence determines which operator is performed first in an expression with more than one operator with different precedence. Associativity is used when two operators of same precedence appear in an expression
Q2. What is the output of the following program?
#include<stdio.h>
int main()
{
int x=11, y=5, z;
float w;
z=x%y;
w=x/y;
printf("Value of z and w are %d and %f respectively", z, w);
return 0;
}
a. Value of z and w are 1 and 2 respectively
b. Value of z and w are 1 and 2.200000 respectively
c. Value of z and w are 1.000000 and 2.200000 respectively
d. Value of z and w are 1 and 2.000000 respectively
Answer: d. Value of z and w are 1 and 2.000000 respectively
Q3. What will be the output?
#include<stdio.h>
int main()
{
int a=4, b=15, c=29;
if(c>b>a)
printf("TRUE");
else
printf("FALSE");
return 0;
}
a. TRUE
b. FALSE
c. Syntax Error
d. Compilation Error
Answer: b. FALSE
Q4. What will be the output of following program?
#include<stdio.h>
int main()
{
int x=(10 || 0) && (10);
printf("x=%d", x);
}
a. x=60
b. x=70
c. x=0
d. x=1
Answer: d. x=1
Q5. What will be the output?
#include<stdio.h>
int main()
{
int x=17, y=1;
if(!(!x) && y)
printf("%d", x);
else
printf("%d", y);
return 0;
}
a. 17
b. 18
c. 1
d. 0
Answer: a. 17
Check Out More NPTEL Assignment Answers
Q6. What is the output of the following C code?
#include<stdio.h>
int main()
{
int x=7, y=3, z=5;
printf("%d\n", x-x/y*y%z);
return 0;
}
a. 7
b. 6
c. 5
d. 0
Answer: b. 6
Q7. What will be the output?
#include<stdio.h>
int main()
{
int x;
x = (11+3)%5/2;
printf("%d\n", x);
return 0;
}
a. 0
b. 1
c. 2
d. Compilation error
Answer: c. 2
Q8. Find the output of the following C code
#include<stdio.h>
int main()
{
int a=3, b=2;
a=a==b==0;
printf("%d,%d", a,b);
return 0;
}
a. 1,2
b. 0,0
c. 3,2
d. 1,0
Answer: a. 1,2
Q9. The output of the following program will be
#include<stdio.h>
int main()
{
int a=0, b=1, c=-1;
if(a)
printf("IITKGP\n");
if(b)
printf("IITM \n");
if(c)
printf("IITR \n");
return 0;
}
a. IITKGP
b. IITMIITR
c. IITM
IITR
d. IITKGP
IITR
Answer: c. IITM
IITR
Q10. Which of the following is/are the What is the output of this C code?
#include<stdio.h>
int main()
{
int x = 10;
if(x>0)
printf("inside if\n");
else if(x>0)
printf("inside elseif\n");
return 0;
}
a. inside if
b. inside elseif
c. inside if
inside elseif
d. compile time error
Answer: a. inside if
Disclaimer: These answers are provided only for the purpose to help students to take references. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.
Also Available:
Problem Solving Through Programming In C NPTEL Assignment 4 Answers
Cloud Computing NPTEL Assignment 4 Answers