0% found this document useful (0 votes)
99 views4 pages

Raiway Exam

1. The C code prints 128. It declares a char variable chr, assigns it the value 128, and prints it using %d format specifier, which prints the integer value of chr. 2. The C code results in a runtime error. It declares a float variable x and assigns it the non-numeric value 'a', then tries to print it with %f format specifier, which expects a float value. 3. All keywords in C are in lowercase letters.

Uploaded by

mmj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views4 pages

Raiway Exam

1. The C code prints 128. It declares a char variable chr, assigns it the value 128, and prints it using %d format specifier, which prints the integer value of chr. 2. The C code results in a runtime error. It declares a float variable x and assigns it the non-numeric value 'a', then tries to print it with %f format specifier, which expects a float value. 3. All keywords in C are in lowercase letters.

Uploaded by

mmj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

What is the output of this C code?

#include <stdio.h>

int main()

char chr;

chr = 128;
printf(�%d\n�, chr);

return 0;

}
o A ) 128
o B ) -128
o C ) Depends on the compiler
o D ) None of the mentioned
2.
What is the output of this C code?

#include <stdio.h>

int main()

float x = �a�;

printf(�%f�, x);

return 0;

}
o A ) a
o B ) run time error
o C ) a.0000000
o D ) 97.000000
3.
All keywords in C are in
o A ) LowerCase letters
o B ) UpperCase letters
o C ) CamelCase letters
o D ) None
4.
Variable name resolving (number of significant characters for uniqueness of
variable) depends on
o A ) Compiler and linker implementations
o B ) Assemblers and loaders implementations
o C ) C language
o D ) None
5.
Which is valid C expression?
o A ) int my_num = 100,000;
o B ) int my_num = 100000;
o C ) int my num = 1000;
o D ) int $my_num = 10000;
6.
Which of the following is not a valid variable name declaration?
o A ) float PI = 3.14;
o B ) double PI = 3.14;
o C ) int PI = 3.14;
o D ) #define PI 3.14;
7.
Which data type is most suitable for storing a number 65000 in a 32-bit system?
o A ) short
o B ) int
o C ) long
o D ) double
8.
Comment on the output of this C code?

#include <stdio.h>

int main()

float f1 = 0.1;

if (f1 == 0.1)
printf(�equal\n�);

else

printf(�not equal\n�);

}
o A ) equal
o B ) not equal
o C ) Output depends on compiler
o D ) None of the mentioned
9.
Which of the following is true for variable names in C?
o A ) They can contain alphanumeric characters as well as special
characters
o B ) It is not an error to declare a variable to be one of the
keywords(like goto, static)
o C ) Variable names cannot start with a digit
o D ) Variable can be of any length
10.
What will happen if the below program is executed?

#include <stdio.h>

int main()

int main = 3;
printf(�%d�, main);

return 0;

}
o A ) It will cause a compile-time error
o B ) It will cause a run-time error
o C ) It will run without any error and prints 3
o D ) It will experience infinite looping
11.
Which of the following is not a valid C variable name?
o A ) int variable_count
o B ) int number
o C ) float rate
o D ) int $main
12.
The format identifier �%i� is also used for _____ data type?
o A ) char
o B ) int
o C ) float
o D ) double
13.
Consider on following declaration:

(i) short i=10;

(ii) static i=10;

(iii) unsigned i=10;


(iv) const i=10;
o A ) Only (iv) is incorrect
o B ) Only (ii) and (iv) are incorrect
o C ) Only (ii),(iii) and (iv) are correct
o D ) All are correct declaration
14.
What is the output of this C code?

#include <stdio.h>

int main()

printf(�Hello World! %d \n�, x);

return 0;

}
o A ) Hello World! x;
o B ) Hello World! followed by a junk value
o C ) Compile time error
o D ) Hello World!

15.
What is the output of this C code?

#include <stdio.h>

int main()

int y = 10000;
int y = 34;
printf(�Hello World! %d\n�, y);

return 0;

}
o A ) Compile time error
o B ) Hello World! 34
o C ) Hello World! 1000
o D ) Hello World! followed by a junk value
16.
Which is correct with respect to size of the datatypes?
A ) char > int > float
B ) int > char > float
C ) char < int < double
D ) double > char > int
17.
What is the size of an int data type?
A ) 4 Bytes
B ) 8 Bytes
C ) Depends on the system/compiler
D ) Cannot be determined

18. Literal means ?


A ) a string.
B ) a string constant.
C ) a character.
D ) an alphabet.
19.
Which of the following cannot be a variable name in C?
A ) Volatile
B ) true
C ) friend
D ) export
20.
Which of the following is a User-defined data type?
A ) typedef int Boolean;
B ) typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
C ) struct {char name[10], int age};
D ) all of the mentioned

You might also like