0% found this document useful (0 votes)
2K views

C Language Mutiple Choice Questions

The document contains the solutions to 10 questions from an assignment on C programming fundamentals. Some key points covered include: - Variables names in C can include alphanumeric characters and underscores but not special characters like @ - Functions can be called multiple times, have a name, and perform a specific task - Application software relies on system software to run - Syntax errors occur when the rules of a programming language's grammar are violated - The minimum value for a signed integer in C that uses 2 bytes of storage is -215

Uploaded by

vinith
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

C Language Mutiple Choice Questions

The document contains the solutions to 10 questions from an assignment on C programming fundamentals. Some key points covered include: - Variables names in C can include alphanumeric characters and underscores but not special characters like @ - Functions can be called multiple times, have a name, and perform a specific task - Application software relies on system software to run - Syntax errors occur when the rules of a programming language's grammar are violated - The minimum value for a signed integer in C that uses 2 bytes of storage is -215

Uploaded by

vinith
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ASSIGNMENT 2 SOLUTION

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


a) Count123
b) Count_123
c) Count@123
d) X_123_Count

Solution: (c) Only alphanumeric characters and few special characters like ‘_’ are allowed
in variable name is C. The special character @ is not allowed.

2. A function

a) is a block of statements to perform some specific task


b) is a fundamental modular unit to perform some task
c) has a name and can be used multiple times
d) All the above options are true

Solution: (d) All the above options are true

3. Which of the following statement is correct?


a) System software is dependent on application software.
b) Application software is dependent on system software.
c) Both are independent of each other.
d) None of the above.

Solution: (b) System software is independent of the application software. Application


software cannot run without the presence of system software.

4. Syntax error occurs when


a) The rules of grammar of the programming language is violated
b) The statements in the program have no meaning
c) The program gives wrong or undesired output
d) Some illegal operation(e.g. divide by zero) is done

Solution: (a) The rules of grammar of the language is violated

5. If integer needs two bytes of storage, then the minimum value of a signed integer in
C would be

a) −(216 − 1)
b) 0
𝑐𝑐) − (215 − 1)
𝑑𝑑) − 215

Solution: (d) The first bit is used to indicate whether it is signed or unsigned integer.
ASSIGNMENT 2 SOLUTION
6. Which of the following statement is correct?
I Keywords are those words whose meaning is already defined by Compiler.
II Keywords cannot be used as variable name.
III There are 32 keywords in C
IV C keywords are also called as reserved words.

a) I and II
b) II and III
c) I, II and IV
d) All of the above
Solution: (d) All of the above are correct.

7. What is the output?


#include<stdio.h>
#define fun(x) (x*x)
int main()
{
float i;
i = 64.0/fun(2);
printf("%.2f", i);
return 0;
}
a) 8.00
b) 4.00
c) 0.00
d) 16.00
Solution: (d) The pre-processing replaces fun(2) with (2*2). Thus fun(2)=4, so,
i=64.0/4=16.00

8. What will be the output?

#include <stdio.h>
int main()
{
float a = 6.0;
printf ("%.2f", (9/5)*a + 11);
return 0;
}

a) 21.00
ASSIGNMENT 2 SOLUTION
b) 19.00
c) 0.00
d) 17.00

Solution: (d) 17.00

Since 9 and 5 are integers, integer arithmetic happens in subexpression (9/5) and we get 1
as its value. To fix the above program, we can use 9.0 instead of 9 or 5.0 instead of 5 so that
floating point arithmetic happens.

9. The following C program converts the temperature from Celsius (C) to Fahrenheit
(F). Fill the blanks with the proper formula to do it.

#include <stdio.h>
int main()
{
float C = 37.5, F;
F = _____________;
printf("%.2f", F);
return 0;
}

a) 1.8*C +32
b) 1.8*(C + 32)
c) 1.8*C - 32
d) C/1.8 + 32

𝐶𝐶 𝐹𝐹−32
Solution: (a) 1.8*C +32. The formula is = , that is simplified to the given option (a).
5 9

10.The following C program swaps the value of two numbers without using any third
variable. What will be the correct option to fill up the blank?

#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;
ASSIGNMENT 2 SOLUTION
b) a=a%b; b=a+b; a=a/b;
c) a=a+b; b=a-b; a=a-b;
d) None of the above
Solution: (c) a=a+b; b=a-b; a=a-b;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy