Programming Questions
Practice Programming MCQs with answers and explanations. Page 1 of 6.
Category
Technical Questions
Topic
Programming
Page
1 / 6
Mode
Practice
Questions
Open any question to view the answer and explanation.
Consider the following C program: main() { char s[] = "man"; int i; for (i = 0; s[i]; i++) printf("
%c%c%c%c", s[i], *(s + i), *(i + s), i[s]); } What is the output of this program?
Open
View answer
Consider the following C code: #include <stdio.h> int main() { int x = 123; int i = { printf("c""++") }; for (x = 0; x <= i; x++) { printf("%x ", x); } return 0; } What will be the output of this program?
Open
View answer
In programming language terminology, a source program is typically written in which level of language?
Open
View answer
Consider the C program: main() { char *p; p = "Hello"; printf("%c
", *&*p); } What will be the output when this program is executed?
Open
View answer
In the C programming language, which of the following is not a valid escape sequence in a string or character literal?
Open
View answer
Consider the following C code: #define clrscr() 100 int main() { clrscr(); printf("%d
", clrscr()); return 0; } What will be the output when this program is executed?
Open
View answer
In Android application development, which of the following Java code snippets correctly launches a new activity from the current activity?
Open
View answer
In information security and data communications, the coding or scrambling of data so that humans cannot read it directly is known as what?
Open
View answer
In Java, what is the meaning of the method header public static void main(String[] args) that appears in many programs?
Open
View answer
Given that the IEEE 754 single precision binary representation of 5.375 is 0100 0000 1010 1100 0000 0000 0000 0000, consider this C program on a little endian machine: main() { float a = 5.375; char *p; int i; p = (char *) &a; for (i = 0; i <= 3; i++) printf(" %02x", (unsigned char) p[i]); } What hexadecimal byte sequence will this program print?
Open
View answer
Consider the C code: enum colors { BLACK, BLUE, GREEN }; int main() { printf("%d..%d..%d", BLACK, BLUE, GREEN); return 1; } What output will this program produce?
Open
View answer
Consider the following C code: #include <stdio.h> void main() { signed int a = -1; unsigned int b = -1u; if (a == b) printf("The Lord of the Rings"); else printf("American Beauty"); } What will be the output when this program is executed on a typical 32 bit system?
Open
View answer
In C programming, what will be the output of the following program that passes a float argument to an external function and returns it as an int?
main()
{
extern int fun(float);
int a;
a = fun(3.14);
printf("%d", a);
}
int fun(float aa)
{
return ( (int) aa );
}
Open
View answer
In general programming terminology, repeating a group of statements multiple times in sequence or based on a condition is usually called what?
Open
View answer
In C programming, what will be the output when you execute the following code that uses the logical OR operator to compute an array index?
#include <stdio.h>
void main()
{
const int SIZE = 5;
int expr;
double value[SIZE] = { 2.0, 4.0, 6.0, 8.0, 10.0 };
expr = 1 || 2 || 3 || 4;
printf("%f", value[expr]);
}
Open
View answer
In standard C programming, is the statement "A function cannot be defined inside another function" true or false with respect to nested function definitions?
Open
View answer
In C programming, what will be the output of the following program that computes the average of a maximum and minimum value?
#include <stdio.h>
int main()
{
int max_val = 100;
int min_val = 10;
int avg_val;
avg_val = (max_val + min_val) / 2;
printf("%d", avg_val);
return 0;
}
Open
View answer
In programming language history, the language SNOBOL is mainly used for which type of operations?
Open
View answer
In C programming, what is the result when you compile the following code that uses variable expressions in switch case labels?
#include <stdio.h>
int main()
{
int a = 1, b = 1;
switch (a)
{
case a * b:
printf("yes ");
case a - b:
printf("non");
break;
}
return 0;
}
Open
View answer
In object oriented (OO) design, which statement best describes the concept of cohesion as it applies to the responsibilities of a single class?
Open
View answer
Practice smarter
Solve a few questions daily and revisit weak topics regularly to improve accuracy.