Font size
WorksheetsAQ Quiz 5
Total questions: 100
Worksheet time: 58mins
/* C program to check palindrome and check the input and output*/
#include <stdio.h>
int main()
{ int n, reverse = 0, temp;
printf("Enter a number you want to check\n");
scanf("%d",&n);
temp = n;
while( temp != 0 )
{ reverse = reverse * 10;
reverse = reverse + temp%10;
temp = temp/10;
} if ( n == reverse )
printf("%d is a palindrome number.\n", n);
else
printf("%d is not a palindrome number.\n", n);
return 0;
}
(a)
SYNTAX ERROR
LOGICAL ERROR
RUNTIME ERROR
ALL OF THE ABOVE
ERROR EXCEPTED COLON IN LINE11
ERROR EXCEPTED SEMICOLON IN LINE11
ERROR EXCEPTED COLON IN LINE12
ERROR EXCEPTED SEMICOLON IN LINE12
In which of the following cases the minimum no of insertions to form palindrome is maximum?
string with all same characters
string of length 1
palindromic string
non palindromic string
In the worst case, the minimum no of insertions to be made to convert the string into a palindrome is equal to the length of the string
TRUE
FALSE
NEITHER TRUE NOR FALSE
What does the following function print for n = 25?
void fun(int n)
{
if (n == 0)
return;
printf("%d", n%2);
fun(n/2);
}
11001
10011
11111
00000
What’s happen if base condition is not defined in recursion ?
Stack underflow
Stack Overflow
None of these
Both a and b
Iteration requires more system memory than recursion.
TRUE
FALSE
NONE OF THE ABOVE
BOTH A AND B
C program scenario based question to calculate electricity bill.
Write the algorithmic logic
(a)
WHICH OF THE FOLLOWING IS CORRECT
Any number is said to be a palindrome if the original number and the reverse of the original number are the same.
Any number is said to be a palindrome if the original number and the reverse of the original number are the not same.
Any number is said to be a palindrome if the original number and the non reverse of the original number are the different.
both a and c
find the output of this program
Logic Error
Run time Error
16
14
find the concept of the program
sum of the different n number and logic error
sum of the number and syntax error
multiplication of n number logic error
sum of the digit but logic error
PREDICT THE OUTPUT OF THIS PROGRAM
10
20
40
30
main() { int i = 2;
{ int i = 4, j = 5;
printf("%d %d", i, j);
}
printf("%d %d", i, j);
}
2545
4525
2554
4552
How many times will the following loop execute?
for(j = 1; j <= 10; j = j-1)
for ever
10
9
error
The format identifier ‘%i’ is also used for which data type?
char
int
float
double
What is the size of an int data type?
4 Bytes
8 Bytes
Depends on the system/compiler
Cannot determine.
Which is correct with respect to the size of the data types?
char > int > float
int > char > float
char < int < double
double > char > int
What is the precedence of arithmetic operators (from highest to lowest)?
%, *, /, +, –
%, +, /, *, –
+, -, %, *, /
%, +, -, *, /
Which of the following is a correct format for declaration of function?
return-type (argument type)function-name;
return-type function-name(argument type);
return-type function-name(argument type) {}
No idea!
What is the default return type if it is not specified in function definition?
void
int
double
short int
What are the different ways to initialize an array with all elements as zero?
int array[5] = {};
int array[5] = {0};
int a=0, b=0, c=0; int array[5] = {a, b, c};
All of the mentioned.
How many times i value is checked in the following C code?
#include <stdio.h>
int main()
{ int i = 0;
do {
i++;
printf("in while loop\n");
} while (i < 3); }
2
3
4
1
Who is the father of C language?
Steve Jobs
James Gosling
Dennis Ritchie
Rasmus Lerdorf
Which of the following is not a valid C variable name?
int number;
float rate;
int variable_count;
int $main;
All keywords in C are in ____________
LowerCase letters
UpperCase letters
CamelCase letters
None of the mentioned
Which is valid C expression?a) int my_num = 100,000;b) int my_num = 100000;c) int my num = 1000;d) int $my_num = 10000;
int my_num = 100,000;
int my_num = 100000;
int my num = 1000;
int $my_num = 10000;
Which keyword is used to prevent any changes in the variable within a C program?
immutable
mutable
const
volatile
What is an example of iteration in C?
for
while
do-while
all of the mentioned
What is #include <stdio.h>?
Preprocessor directive
Inclusion directive
File inclusion directive
None of the above
The C-preprocessors are specified with _________ symbol.
#
$
%
None of the above.
The standard header _______ is used for variable list arguments (…) in C.
<stdio.h >
<stdlib.h>
<math.h>
<stdarg.h>
What is the sizeof(char) in a 32-bit C compiler?
1 bit
2 bits
1 Byte
2 Bytes
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int y = 10000;
int y = 34;
printf("Hello World! %d\n", y);
return 0;
}
Compile time error
Hello World! 34
Hello World! 1000
Hello World! followed by a junk value
What will be the final value of x in the following C code?
#include <stdio.h>
void main()
{
int x = 5 * 9 / 3 + 9;
}
3.75
Depends upon compiler
24
3
What are the elements present in the array of the following C code?
int array[5] = {5};
5, 5, 5, 5, 5
5, 0, 0, 0, 0
5, (garbage), (garbage), (garbage), (garbage)
(garbage), (garbage), (garbage), (garbage), 5
What are true about Array in C language.?
A group of elements of same data type.
An array contains more than one element
Array elements are stored in memory in continuous or contiguous locations
All the above.
An array Index starts with.?
-1
0
1
2
What is the output of the following code snippet?
int main()
{ int sum = 2 + 4 / 2 + 6 * 2;
printf("%d", sum);
return 0;
}
2
15
16
18
What is the output of the following code?
#include <stdio.h>
int main()
{
int i = 3;
printf("%d", (++i)++);
return 0;
}
3
4
5
Compile time error
What is the output of this statement "printf("%d", (a++))"?
The value of (a + 1)
The current value of a
Error message
Garbage Value
What does this declaration mean?
int x: 4;
X is a four-digit integer.
X cannot be greater than a four-digit integer.
X is a four-bit integer.
None of the these
How many times will the following loop execute?
for(j = 1; j <= 10; j = j-1)
forever
never
0
1
Which one of the following is a loop construct that will always be executed once?
for
while
switch
do-while
How many characters can a string hold when declared as follows?
char name[20]:
19
20
Can't determine
18
What will the result of num1 variable after execution of the following statements?
int j = 1, num1 = 4;
while (++j <= 10)
{
num1++;
}
11
12
13
14
Let p1 be an integer pointer with a current value of 2000. What is the content of p1 after the expression p1++ has been evaluated?
2001
2002
2004
2008
What will be the output of this program?
int main()
{
int a=10, b=20;
printf("a=%d b=%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("a=%d b=%d",a,b);
return 0;
}
a = 20, b = 20
a = 10, b = 20
a = 20, b = 10
a = 10, b = 10
What does this statement mean?
x - = y + 1;
x = x - y + 1
x = -x - y - 1
x = x + y - 1
x = x - y - 1
Array is a _________ data structure.
Non-linear
Primary
Linear
Non-primary
Study the following statement
printf ("%d", 9/5);
What will be the output of this statement?
1.8
1.2
1.5
None of the aove
A global variable is declared __________.
Outside of the function
Inside of the function
With the function
Anywhere in the program
Who defines the user-defined function?
Computer
compiler
Users
None
The enum keyword is used to assign names to the ________ constants.
Integer
String
Character
All of the above
Which of the following is not an arithmetic operation?
x * = 65;
x / = 42;
x % = 2;
x ! = 56;
Which of the following operator is represented a relational operation?
==
++
||
&&
Which of the following keyword is used for union in c language?
un
uni
ion
union
Study the following program:
main ()
{
char x;
x = 'A' + 5;
printf("%c", x);
}
A+5
A
F
E
Which one of the following operators is a unary operator in c language?
&
&&
<<
sizeof()
How many types of variables are there in the C language?
2
4
5
3
Which level of a programming language is Machine Code?
Low
High
Which level would create the fastest code to execute?
Low
Assembly
High
Which level would create the easiest code for humans to understand?
Low
Assembly
High
Which generation?
Machine Code - Low
Assembly Code - Low
High Level
Computers must translate everything into binary
True
False
High Level Code is easier for humans to understand as it is written in English
True
False
__________ is a series of instructions that directs a computer to perform tasks
Programming language
Programmer
Program
Programmed
It is a computer program that links and merges various object files together in order to make an executable file.
Assembler
Compiler
Linker
Loader
Loops in C Language are implemented using?
While Block
For Block
Do While Block
All the above
Which loop is faster in C Language, for, while or Do While?
for
while
do while
All work at same speed
If block always need to be associated with a else block?
True
False
Choose a right C Statement.
Loops or Repetition block executes a group of statements repeatedly
Loop is usually executed as long as a condition is met
Loops usually take advantage of Loop Counter
All the above
The conditional operator are also known as
Relational operator
Binary operator
Ternary operator
Chary operator
If you have to make decision based on multiple choices, which of the following is best suited?
if
if-else
if-else-if
All the above
Can we use string inside switch statement?
Yes
No
In situations where we need to execute body of the loop before testing the condition, we should use __________.
for
while
do while
nested for loop
Choose a correct C Statement.
a++ is (a=a+1) POST INCREMENT Operator
a-- is (a=a-1) POST DECREMENT Opeartor
--a is (a=a-1) PRE DECREMENT Opeator
++a is (a=a+1) PRE INCREMENT Operator
All the above.
What is the way to suddenly come out of or Quit any Loop in C Language.?
continue; statement
leave; statement
break; statement
quit; statement
