Problem Solving Through Programming In C Nptel Week 3 Assignment Answers

Are you looking for the Problem Solving Through Programming In C Week 3 Answers 2024? You’ve come to the right place! This resource offers comprehensive solutions to the Week 3 assignment questions, focusing on fundamental concepts in C programming.

Course Link: Click Here


Problem Solving Through Programming In C Week 3 Answers
Problem Solving Through Programming In C Week 3 Answers

Problem Solving Through Programming In C Week 3 Answers (July-Dec 2024)


Q1.The precedence of arithmetic operators is (from highest to lowest)
a) %, *, /, +, –
b) %, +, /, *, –
c) +, -, %, *, /
d) %, +, -, *, /

Answer: a) %, *, /, +, –


Q2.Which of the following is a logical operator in C?
a) &&
b) ==
c) =
d) +=

Answer: a) &&


For answers or latest updates join our telegram channel: Click here to join

These are Problem Solving Through Programming In C Week 3 Answers


Q3.What is the output of the following program?

include

int main()
{
float i = -3.0;
int k = i % 2;
printf(“%d”, k);
return 0;
}

a) -1
b) 1
c) 0
d) Compilation error

Answer: d) Compilation error


Q4.Find the output of the following C code. (% indicates modulo operation, which results in the remainder of a division operation)

include

int main()
{
int a=10, b=3, c=2, d=4, result;
result=a+a-b/c%d+cd;
printf(“%d”, result);
return 0;
}

a) -42
b) 24
c) 15
d) -34

Answer: c) 15


For answers or latest updates join our telegram channel: Click here to join

These are Problem Solving Through Programming In C Week 3 Answers


Q5.What is the output of the following C code?

include

int main()
}
int h = 8;
int b=46+34<h*574:3;
printf(“%d\n”, b);
return 0;
}

Answer: c. 4


Q6.What will be the output of the following C code snippet?

include

int main() {
int x = 1, y = 0;
if (x && y) {
printf(“Both are true\n”);
} else {
printf(“At least one is false\n”);
}
return 0;
}

a) Both are true
b) At least one is false
c) Compilation error
d) None of the above

Answer: b) At least one is false


For answers or latest updates join our telegram channel: Click here to join

These are Problem Solving Through Programming In C Week 3 Answers


Q7.What will be the output of the following C code?

include

int main() {
int x = 10;
if (x = 5) {
printf(“x is 5\n”);
} else {
printf(“x is not 5\n”);
}
return 0;
}

a) x is 5
b) x is not 5
c) Compilation error
d) None of the above

Answer: a) x is 5


Q8.What will be the output of the following C code? #include
int main() {
int a = 10, b = 5;
if (a > b)
if (b > 0)
printf(“b is positive\n”);
else
printf(“b is non-positive\n”);
printf(“a is greater than b\n”);
return 0;
}

a) b is positive
b) b is non-positive
c) a is greater than b
d) b is positive
a is greater than b

Answer: d) b is positive
a is greater than b


For answers or latest updates join our telegram channel: Click here to join

These are Problem Solving Through Programming In C Week 3 Answers


Q9. Which of the following method are accepted for assignment?
a) 8=x=y=z
b) x=8=y=z
c) x=y=z=8
d) None

Answer: c) x=y=z=8


Q10.What will be the output?

include

int main()
{
int x;
x= 9<5+3 && 7;
printf(“%d”, x);
return 0;
}

a) 0
b) 1
c) 7
d) Compilation error

Answer: a) 0


For answers or latest updates join our telegram channel: Click here to join

See also  Problem Solving Through Programming In C Week 12

These are Problem Solving Through Programming In C Week 3 Answers


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

More Nptel Courses: https://progiez.com/nptel-assignment-answers


Problem Solving Through Programming In C Week 3 Answers (July-Dec 2023)

Course Name: Problem Solving Through Programming In C

Course Link: Click Here

These are Nptel Problem Solving Through Programming In C Week 3 Answers


Q1. Which of the following statement 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. Find the output of the following C code
a) 67
b) -36
c) 66
d) -37

Answer: a) 67


Q3. What 1s the output of the following C code?
a) 0
b) 3
c) 4
d) Compilation error

Answer: c) 4


These are Nptel Problem Solving Through Programming In C Week 3 Answers


Q4. Find the output of the following C code
a) IITKGP
b) IITD and IITM
c) IITKGP and IITM
d) IITM

Answer: a) IITKGP


Q5. What will be the output?
a) Condition is true
b) Condition is false
c) Error
d) No output possible

Answer: a) Condition is true


Q6. What is the output of the following program?
a) Programming on C 0
b) NPTEL 0
c) NPTEL 3
d) Compilation error

Answer: b) NPTEL 0


These are Nptel Problem Solving Through Programming In C Week 3 Answers


Q7. What is the output of the C program given below
a) true
b) false
c) Compiler dependent
d) Compiler error

Answer: b) false


Q8. What will be the output?
a) 0
b) 1
c) 10
d) 30

Answer: b) 1


Q9. What will be the output?
a) TRUE
b) FALSE
c) Syntax Error
d) Compilation Error

Answer: b) FALSE


These are Nptel Problem Solving Through Programming In C Week 3 Answers


Q10. What is the output of the following C code?
a) 10
b) 11
c) 20
d) Compiler error

Answer: b) 11


Assignment

Question 1
Write a C Program to calculates the area (floating point number with two decimal places) of a Circle given it’s radius (integer value). The value of Pi is 3.14.

Solution:

    area = PI * radius * radius;

Question 2
Write a C program to check if a given Number is zero or Positive or Negative Using if…else statement.

Solution:

if(number <= 0.0)
    {
        if (number == 0.0)
            printf("The number is 0.");
        else
            printf("Negative number.");
    }
    else
        printf("Positive number.");
}

Question 3
Write a C program to check whether a given number (integer) is Even or Odd.

Solution:

if(number % 2 == 0)
    	printf("%d is even.", number);
    else
    	printf("%d is odd.", number);
}

Question 4
Write a C Program to find the Largest Number (integer) among Three Numbers (integers) using IF and Logical && operator.

Solution:

if( n1>=n2 && n1>=n3 )
        printf("%d is the largest number.", n1);

    if( n2>=n1 && n2>=n3 )
        printf("%d is the largest number.", n2);

    if( n3>=n1 && n3>=n2 )
        printf("%d is the largest number.", n3);
}

These are Nptel Problem Solving Through Programming In C Week 3 Answers

More Weeks of Problem Solving Through Programming In C: Click here

More Nptel Courses: Click here


Problem Solving Through Programming In C Week 3 Answers (Jan-Apr 2023)

Course Name: Problem Solving Through Programming In C

See also  Problem Solving Through Programming In C Week 8

Course Link: Click Here

These are Nptel Problem Solving Through Programming In C Week 3 Answers


Q1. What should be the value of ‘b’ such that the output of the program will be 20?
a) 1
b) 2
c) 3
d) 4

Answer: b) 2


Q2. Find the output of the following C code
a) IITKGP
b) IITD and IITM
c) IITKGP and IITM
d) IITM

Answer: a) IITKGP


These are Nptel Problem Solving Through Programming In C Week 3 Answers


Q3. What is the output of the following program?
a) Programming on C 0
b) NPTEL 0
c) NPTEL 3
d) Compilation error

Answer: b) NPTEL 0


Q4. Find the output of the following C code
a) -42
b) 24
c) 15
d) -34

Answer: c) 15


These are Nptel Problem Solving Through Programming In C Week 3 Answers


Q5. Which of the following statement 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


Q6. What is the output of the C program given below?
a) true
b) false
c) Compiler dependent
d) Compiler error

Answer: b) false


These are Nptel Problem Solving Through Programming In C Week 3 Answers


Q7. What is the output of the following program?
a) Value of c and d are 1 and 3 respectively
b) Value of c and d are 1 and 3.333333 respectively
c) Value of c and d are 1.000000 and 3.000000 respectively
d) Value of c and d are 1 and 3.000000 respectively

Answer: d) Value of c and d are 1 and 3.000000 respectively


Q8. What will be the output?
a) TRUE
b) FALSE
c) Syntax Error
d) Compilation Error

Answer: b) FALSE


These are Nptel Problem Solving Through Programming In C Week 3 Answers


Q9. What will be the output?
a) 0
b) 1
c) 7
d) Compilation error

Answer: a) 0


Q10. The precedence of arithmetic operators is (from highest to lowest)
a) %, *, /, +, –
b) %, +, /, *, –
c) +, -, %, *, /
d) %, +, -, *, /

Answer: a) %, *, /, +, –


These are Nptel Problem Solving Through Programming In C Week 3 Answers


Assignment

Question 1

Write a C Program to calculates the area (floating point number with two decimal places) of a Circle given it’s radius (integer value). The value of Pi is 3.14.

Solution:

area = PI * radius * radius;
printf("Area of a circle = %5.2f", area);
}

Question 2

Write a C program to check if a given Number is zero or Positive or Negative Using if…else statement.

Solution:

if (number <= 0.0)
    {
        if (number == 0.0)
            printf("The number is 0.");
        else
            printf("Negative number.");
    }
    else
        printf("Positive number.");
}

These are Nptel Problem Solving Through Programming In C Week 3 Answers


Question 3

Write a C program to check whether a given number (integer) is Even or Odd.

Solution:

if(number % 2 == 0)
        printf("%d is even.", number);
    else
        printf("%d is odd.", number);
}

Question 4

Write a C Program to find the Largest Number (integer) among Three Numbers (integers) using IF and Logical && operator.

Solution:

if( n1>=n2 && n1>=n3 )
        printf("%d is the largest number.", n1);

    if( n2>=n1 && n2>=n3 )
        printf("%d is the largest number.", n2);

    if( n3>=n1 && n3>=n2 )
        printf("%d is the largest number.", n3);
}

These are Problem Solving Through Programming In C Assignment 3 Answers

See also  Problem Solving Through Programming In C | Week 1

More Weeks of Problem Solving Through Programming In C: Click Here

More Nptel courses: https://progiez.com/nptel


Problem Solving Through Programming In C Week 3 Answers (July-Dec 2022)

Course Name: Problem Solving Through Programming In C NPTEL

Link of course: Click Here

These are Problem Solving Through Programming In C Assignment 3 Answers


Q1. Find the output of the following C program

#include<stdio.h>
int main()
{
int a, z, x=10, y=12;
z=x*y++;
a=x*y;
printf(“%d, %d”, z, a);
return 0;
}

a) 120, 120
b) 120, 130
c) 130, 120
d) 130, 130

Answer: b) 120, 130


Q2. What will be the output of the following program?
#include<stdio.h>
int main()
{
int p=2;
int m=10;
int k;
k=!((p<2)&&(m>2));
printf(“n%d”, k);
return 0;
}

a) 1
b) 0
c) -1
d) 2

Answer: a) 1


These are Problem Solving Through Programming In C Assignment 3 Answers


Q3. Find the output of the following C code.

a) x1=4, x2=3
b) x1=-5, x2=-4
c) x1=2.5, x2=4.2
d) Roots are imaginary

Answer: d) Roots are imaginary


Q4. Find the output of the following code.

a) 6
b) 4
c) 10
d) 14

Answer: c) 10


Q5. Which of the following statements are correct?
I. The ‘else’ block is executed when condition inside if statement is false.
II. One ‘if statement can have multiple ‘else’ statement.

a) Only I
b) Only II
c) Both I and II
d) None of the above is correct

Answer: a) Only I


These are Problem Solving Through Programming In C Assignment 3 Answers


Q6. Cmodulo division operator %’ can be applied on
a) only float variables
b) only int variables
c) int and float combination
d) any data types in C

Answer: b) only int variables


Q7. The output of the following program will be
a) C programming
b) Java
Python
c) C programming
Java
d) Compilation error

Answer: b)


These are Problem Solving Through Programming In C Assignment 3 Answers


Q8. What will be the output?
a) 2
b) 8
c) 10
d) 12

Answer: c) 10


Q9. What will be the output?

a) Right
b) Wrong
c) 0
d) No output

Answer: a) Right


These are Problem Solving Through Programming In C Assignment 3 Answers


Q10. What will be the output of the program?
a) The answer will be 15
b) The answer will be 0
c) The answer will be 1
d) Compilation error

Answer: b) The answer will be 0


Assignment

Question 1

Write a C Program to calculates the area (floating point number with two decimal places) of a Circle given it’s radius (integer value). The value of Pi is 3.14

Solution:

Code

These are Problem Solving Through Programming In C Assignment 3 Answers


Question 2

Write a C program to check if a given Number is zero or Positive or Negative Using if…else statement.

Solution:

Code

These are Problem Solving Through Programming In C Assignment 3 Answers


Question 3

Write a C program to check whether a given number (integer) is Even or Odd.

Solution:

Code

These are Problem Solving Through Programming In C Assignment 3 Answers


Question 4

Write a C Program to find the Largest Number (integer) among Three Numbers (integers) using IF and Logical && operator.

Solution:

Code

These are Problem Solving Through Programming In C Assignment 3 Answers