### Problem Solving Through Programming In C Assignment 3

Course Name: Problem Solving Through Programming In C NPTEL

### These are answers for Problem Solving Through Programming In C Assignment 3

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

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

These are answers for Problem Solving Through Programming In C Assignment 3

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

Q4. Find the output of the following code.

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

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

These are answers for Problem Solving Through Programming In C Assignment 3

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

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

These are answers for Problem Solving Through Programming In C Assignment 3

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

Q9. What will be the output?

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

These are answers for Problem Solving Through Programming In C Assignment 3

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

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:

``````#include <stdio.h>
#define PI 3.14
void main()
{
float area;
/* Enter the radius of a circle */
printf("Area of a circle = %5.2f", area);
}``````

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

Question 2

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

Solution:

``````#include <stdio.h>
int main()
{
double number;
scanf("%lf", &number);
if(number <= 0.0)
{
if (number == 0.0)
printf("The number is 0.");
else
printf("Negative number.");
}
else
printf("Positive number.");
}``````

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

Question 3

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

Solution:

``````#include <stdio.h>
int main()
{
int number;
scanf("%d", &number);
if(number % 2 == 0)
printf("%d is even.", number);
else
printf("%d is odd.", number);
}``````

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

Question 4

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

Solution:

``````#include <stdio.h>
int main()
{
int n1, n2, n3;
scanf("%d %d %d", &n1, &n2, &n3);
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 answers for Problem Solving Through Programming In C NPTEL Assignment 3

All weeks of Problem Solving Through Programming In C: https://progies.in/answers/nptel/problem-solving-through-programming-in-c

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

## More from PROGIEZ

### Programming Data Structure And Algorithms Using Python | Week 2
{"ft_lang_label":"__label__en","ft_lang_prob":0.6271449,"math_prob":0.9618342,"size":4172,"snap":"2022-40-2023-06","text_gpt3_token_len":1251,"char_repetition_ratio":0.15307102,"word_repetition_ratio":0.19246861,"special_character_ratio":0.30704698,"punctuation_ratio":0.14686099,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99599373,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-01-31T17:26:49Z\",\"WARC-Record-ID\":\"<urn:uuid:a23d27f4-030f-423e-aafb-b45f96cacdc8>\",\"Content-Length\":\"63435\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:156e4659-773a-4054-a87f-a391b507cd59>\",\"WARC-Concurrent-To\":\"<urn:uuid:070344da-9b91-497b-8bf6-46a66b156ffd>\",\"WARC-IP-Address\":\"13.234.228.63\",\"WARC-Target-URI\":\"https://progiez.com/problem-solving-through-programming-in-c-assignment-3\",\"WARC-Payload-Digest\":\"sha1:VGOI7TK34AQKSFOJUA22EMHCYKAGHTQW\",\"WARC-Block-Digest\":\"sha1:3P47DKDOTAMSRGK5AIKNZSL4SEHWBSVF\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764499888.62_warc_CC-MAIN-20230131154832-20230131184832-00802.warc.gz\"}"}