Compilation

Question 1
What error would the following function given on compilation?
f(int a, int b)
{
int a;
a=20;
return a;
}
A
Missing parenthesis is return statement
B
Function should be defined as int f(int a, int b)
C
Redeclaration of a
D
None of these
       Programming       Compilation       Nielit Scientist-B CS 2016 march
Question 1 Explanation: 
We are already declared variable name ‘a’ in function. Again we are declared inside the function. So, the compiler will raise a error “Redeclaration of a”
Question 2

What will be output if you will compile and execute the following C code?

void main()

{

char c=125;

c=c+10;

printf("%d",c);

}
A
135
B
115
C
-121
D
-8
       Programming       Compilation       Nielit Scientist-B CS 4-12-2016
Question 2 Explanation: 
As we know any data type shows cyclic properties
In our example the data type is char data type , so if you will increase or decrease the char
variables beyond its maximum or minimum value respectively it will repeat same value
according to following cyclic order
So,
125+1= 126
125+2= 127
125+3=-128
125+4=-127
125+5=-126
125+6=-125
125+7=-124
125+8=-123
125+9=-122
125+10=-121
Question 3

What will be output if you will compile and execute the following C code?

void main()

{

printf("%d",sizeof(5.2));
}
A
4
B
8
C
2
D
16
       Programming       Compilation       Nielit Scientist-B CS 4-12-2016
Question 3 Explanation: 
Size of is a special operator will return number of bytes of data types. By default system will take integer data type,if we are not specifying any data type. Total size is 4 bytes.
Question 4
Which of the following has the compilation error in C?
A
int n=17;
B
char c=99;
C
float f=(float)99.32;
D
#include
       Programming-for-Output-Problems       Compilation       ISRO CS 2015
Question 4 Explanation: 
Option A: General declaration of integer variable.
Option B: General declaration of character variable.
Option C: It is type casting. But given cast also same type.
Option D: We have to include a file otherwise it treated as compiler error.
Question 5
A condition that is caused by run time error in a computer program is known as
A
Exception
B
Syntax error
C
Semantic error
D
Fault
       Programming       Compilation       KVS DEC-2017
Question 5 Explanation: 
● An exception is an abnormal or unprecedented event that occurs after the execution of a software program or application. It is a runtime error of an undesired result or event affecting normal program flow.
● An exception is also known as a fault.
Question 6
Which of the following has compilation error in C ?
A
int n=32 ;
B
char ch=65 ;
C
float f=(float)3.2 ;
D
none of the above
       Programming       Compilation       UGC NET CS 2013 Dec-paper-2
Question 6 Explanation: 
Option-A: ‘n’ is a integer value and and value of ‘n’ is 32.
Option-B: ‘ch’ is a character variable and value of ‘ch’ is 65.
Option-C: ‘f’ is a floating point variable and it uses type casting.
Option-D is correct answer.
There are 6 questions to complete.
PHP Code Snippets Powered By : XYZScripts.com
error: Content is protected !!