- Home
- Placement
- Programming
- Loop & Control Statements
- Array
- Data Types
- Functions
- Loop & Control Statements
- Operators & Expressions
- Pointer
- Preprocessor
- Storage Classes
- Structure & Union
- Variables & Constants
- Classes and Objects
- Consructors and Destructors
- Exception handling
- File Handling
- Function Overloading
- Inheritance
- Operator Overloading
- Polymorphism
- Templates
C Language
C++ language
JAVA
-
-
( 1 ) Consider the following program fragment:
for(c=1, sum=0; c <= 10; c++)
{
scanf("%d", &x);
if( x < 0 ) continue;
sum += x;
}
What would be the value of sum for the input 1, -1, 2, -2, 3, -3, 4, -4, 5, -5 - 1) 15
- 2) 30
- 3) 10
- 4) 1
-
-
-
( 2 ) Example of iteration in C.
- 1) for
- 2) while
- 3) do-while
- 4) All of the above
-
Show Answer Report Discussion in forumAnswer : 4) All of the above
Solution :
discussion
Answer : 4) All of the above
-
-
-
( 3 ) What is the output of this C code?
int main()
{
if (printf("%d", printf(")))
printf("We are Happy");
else if (printf("1"))
printf("We are Sad");
} - 1) 0We are Happy
- 2) 1We are Happy
- 3) 1We are Sad
- 4) Compile time error
-
Show Answer Report Discussion in forumAnswer : 4) Compile time error
Solution :
discussion
Answer : 4) Compile time error
-
-
-
( 4 ) What is the output of this C code?
int main()
{
int i = 0, j = 0;
l1: while (i < 2)
{
i++;
while (j < 3)
{
printf("booK\n");
goto l1;
}
}
} - 1) book book
- 2) Compile time error
- 3) book book book book
- 4) Infinite loop
-
Show Answer Report Discussion in forumAnswer : 1) book book
Solution :
discussion
Answer : 1) book book
-
-
-
( 5 ) What's wrong in the following statement, provided k is a variable of type int?
for(k = 2, k <=12, k++) - 1) The increment should always be ++k .
- 2) The commas should be semicolons
- 3) There should be a semicolon at the end of the statement.
- 4) The variable k can't be initialized.
-
Show Answer Report Discussion in forumAnswer : 2) The commas should be semicolons
Solution :
discussion
Answer : 2) The commas should be semicolons
-
-
-
( 6 ) Comment on the output of this C code?
switch (ch)
{
case 'a':
case 'A':
printf("true");
} - 1) if (ch == 'a' && ch == 'A') printf("true");
- 2) if (ch == 'a') if (ch == 'a') printf("true");
- 3) if (ch == 'a' || ch == 'A') printf("true");
- 4) Both 1 & 2
-
Show Answer Report Discussion in forumAnswer : 3) if (ch == 'a' || ch == 'A') printf("true");
Solution :
discussion
Answer : 3) if (ch == 'a' || ch == 'A') printf("true");
-
-
-
( 7 ) What is the output of this C code?
int main()
{
int x = 1;
if (x > 0)
printf("inside if\n");
else if (x > 0)
printf("inside elseif\n");
} - 1) inside if
- 2) inside elseif
- 3) inside if inside elseif
- 4) Compile time error
-
Show Answer Report Discussion in forumAnswer : 1) inside if
Solution :
discussion
Answer : 1) inside if
-
-
-
( 8 ) Which keyword can be used for coming out of recursion?
- 1) break
- 2) return
- 3) exit
- 4) Both 1 & 2
-
-
-
( 9 ) What is the right choice, if the following loop is implemented?
void main()
{
int num = 0;
do{
--num;
printf("%d", num);
}while( ++num >= 0 );
} - 1) A run time error will be generated.
- 2) The program will not enter into the loop.
- 3) There will be a compilation error reported.
- 4) The loop will run infinitely many times.
-
Show Answer Report Discussion in forumAnswer : 4) The loop will run infinitely many times.
Solution :
discussion
Answer : 4) The loop will run infinitely many times.
-
-
-
( 10 ) What is the output of this C code?
int main()
{
int i = 0;
while (i = 0)
printf("True\n");
printf("False\n");
} - 1) True (infinite time)
- 2) True (1 time) False
- 3) FALSE
- 4) Compiler dependent
-