Font size
WorksheetsC-programming(Theory)
Total questions: 146
Worksheet time: 7hrs 18mins
What will be the output of the following C code?
#include <stdio.h>
void main()
{
int x = 5;
if (x < 1)
printf("hello");
if (x == 5)
printf("hi");
else
printf("no");
}
hi
hello
no
error
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 0;
if (x == 1)
if (x == 0)
printf("inside if\n");
else
printf("inside else if\n");
else
printf("inside else\n");
}
inside if
inside else if
inside else
compile time error
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 0;
if (x == 1)
if (x >= 0)
printf("true\n");
else
printf("false\n");
}
Depends on the compiler
No print statement
True
False
The switch statement takes a given integer value then seeks a matching value among a number of _______ statements.
break
case
switch
goto
How many loops are there in C
1
3
2
4
Which of the following is an exit control statement
for
while
do while
continue
The value of i after the execution of the following segment is
i = 2;
for( i=0; i>10; i=i+1);
1
2
0
11
The output of the following segment is
int k, n=20;
k=(n>5?(n<=10?100:200):500);
printf("%d",n);
100
200
300
20
C language developed at _____?
AT & T's Bell Laboratories of USA in 1972
AT & T's Bell Laboratories of USA in 1970
Sun Microsystems in 1973
Cambridge University in 1972
which is the only function all C programs must contain?
start()
sys()
main()
scanf()
Which of the following is not a correct variable type?
float
real
int
double
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int a = 1, b = 1, c;
c = a++ + b;
printf("%d, %d", a, b);
}
a=1, b=1
a=2, b=1
a=1, b=2
a=2, b=2
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 0;
int j = i++ + i;
printf("%d\n", j);
}
0
1
2
compile time error
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int a = 1, b = 1;
switch (a)
{
case a*b:
printf("yes ");
case a-b:
printf("no\n");
break;
}
}
yes
no
yes no
compile time error
Library function pow() belongs to which header file?
math.h
square.h
stdio.h
conio.h
Is it possible to run program without main() function?
yes
no
may be
How many main() function we can have in our project?
1
2
no limit
depends on the program
int x = 10;
int main()
{
int x = 0;
printf("%d",x);
return 0;
}
10
0
compile error
undefined
What should be the output:
int main()
{
int a = 10/3;
printf("%d",a);
return 0;
}
3.33
3.0
3
0
#include "stdio.h"
int main()
{
int a = 10;
printf("%d", a);
int a = 20;
printf("%d",a);
return 0;
}
1020
1010
2020
Error: Redeclaration of a
Which of the following correctly shows the hierarchy of arithmetic operations in C?
/ + * -
* - / +
+ - / *
/ * + -
To print out 'a' as an integer and 'b' as a decimal, which of the following printf() statement will you use?
printf("%f %lf", a, b)
printf("%f %f", a, b)
printf("%d %f", a, b)
printf("%f %d", a, b)
Which of the following is not logical operator?
&
&&
||
!
When does the code block following while(x<100) execute?
When x is less than one hundred
When x is greater than one hundred
When x is equal to one hundred
while it wishes
Input/output function prototypes and macros are defined in which header file?
conio.h
stdlib.h
stdio.h
dos.h
which of the following is not a Looping statements?
For
While
Do while
Switch case
Which command is used to skip the rest of a loop and carry on from the top of the loop again?
break
continue
goto
resume
What will be the output of following program?
true
false
6
5
what will be output of following program?
6 7 7 8
6 6 7 8
6 6 8 8
6 7 8 8
What will happen when the following code is executed?
void main()
{
printf("MIET");
main();
}
Wrong statement
It will keep on printing MIET
It will print MIET once
None of these
What is the output of C Program.?
int main()
{
int a=5;
while(a >= 3);
{
printf("RABBIT\n");
break;
}
printf("GREEN");
return 0;
}
GREEN
RABBIT GREEN
RABBIT is printed infinite times
None of the above
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.
What is the output of C Program.?
int main()
{
int a=32;
do
{
printf("%d ", a);
a++;
if(a > 35)
break;
}
while(1);
return 0;
}
No Output
32 33 34
32 33 34 35
Compiler error
What is the output of C Program.?
int main()
{
int a=32;
do
{
printf("%d ", a);
a++;
}
while(a <= 30);
return 0;
}
32
33
30
No Output
Lines beginning with a hash sigh (#) are
namespace
directives
object
What does <= mean?
less than
less than or equal to
greater than
It is the point by where all C++ programs start their execution, independently of its location within the source code
main()
start()
system()
It represents the standard output stream of C++
cout
cin
clrscr()
The collective name given to spaces (blanks), horizontal and vertical tabs, newline characters, and comments
comment
new line
whitepsace
Tokens representing fixed numeric or character values.
identifier
constant
directives
Words reserved for special purposes and must not be used as normal identifier names
variable
namespace
keywords
Arbitrary names of any length given to classes, objects, functions, variables, user-defined data types, and so on
keywords
whitespace
identifier
A character used to mark the end of the statement
braces
semicolon
colon
C++ was originally developed by
Bjarne Stroustrup
Nicolas Wirth
Ken Thompson
Form a special category of constant used to handle fixed sequences of characters.
Character Constant
Escape Sequences
String Constant
It is a portion of memory to store a determined value
variable
constant
directive
Indicate the start and end of a compound statement
braces
comma
semicolon
Refer to the names of variables, functions, arrays, classes etc. created by the programmer.
keywords
constraints
identifiers
An identifiable region of memory that can hold a fixed or variable value
directive
identifier
objects
A sequence of operators, operands, and punctuators that specifies a computation.
expression
syntax
statement
It specify the flow of control as a program executes
statement
syntax
expression
It express numbers with decimals and/or exponents
integer numerals
floating point
character literals
A keyword used to execute a statement or block only if a condition is fulfilled
objects keyword
case keyword
if keyword
Which of the following is a correct C programming statement?
printf(“Programming”)
int num2=3
scanf(“&num”, %d);
printf(“ “);
Which of the following is a correct syntax of printf?
printf( strings );
Printf(“Strings”);
printf(“ strings “);
None of these
C programming is a case-sensitive?
True
False
The format specifier/placeholder (a) is used to print integers.
The format specifier/placeholder (a) is used to print floating points.
The format specifier/placeholder (a) is to used to print single character.
The format specifier/placeholder (a) is used to print string.
The symbol (a) is used to terminate the C statement .
The symbol (a) is used to address a variable.
The escape sequence (a) is used to create a new line.
The escape sequence (a) is used to create a horizontal tab.
Which of the following variable declaration is correct?
char char;
int void;
float _a;
Float a=0;
Given the code above, what is the expected output?
Null
Compilation Error
“ “
0
Given the code above, what is the expected output?
Syntax Error
Null
The value of a = -10
Compilation Error
Given the code above, Assumed that 5 was entered , what is the expected output?
Enter a value of a: 5
You entered the value of a: 5
Compilation error
nothing
Run time error
Given the code above, assumed that HELLO was entered, what is the expected output?
HELLO
Compilation Error
H
Syntax Error
The arithmetic (a) operator is to get the remainder of an integer.
The arithmetic (a) operator is used to add the variable value or to the operand.
The arithmetic (a) operator is used to subtract the value of the variable or to the operand.
What is stdio stands for? (a)
At the heart of computer is its central processing unit. The CPU's job is:
To fetch instructions
To carry out the operations commanded by the instructions
To produce some outcome or resultant information
All of these
An Integrated Development Environment typically consists of:
A text editor
A compiler
A debugger
All of these
___ is used to translate source code instructions into the appropriate machine language instructions
Module
Library routine
Compiler
Preprocessor directives
A ____ is a set of instructions that the computer follows to solve a problem.
Comipler
Linker
Program
Operator
The program written by the programmer with high level language is called:
Object Code
Syntax
Source Code
Runtime Library
Computer programs are also known as:
Hardware
Firmware
Software
Silverware
The primary purpose of an operating system is:
To make the most efficient use of the computer hardware
To make programming easier
To fetch instructions
To prevent multitask
What is the extension of C program source code?
.cpp
.py
.c
.java
What is machine language?
A language used by car
Machine language is made of 1's and 0's
Machine language is made of 7's and 8's
A language that only understands plain English
Which of the following is not a high level programming language?
Assembly
C++
Java
Python
Algorithm refers to a pictorial representation of a flowchart
True
False
Who is Father of C Language
Bjarne Stroustrup
James A. Gosling
Dennis Ritchie
Dr. E.F. Codd
C programs are converted into machine language with the help of
An Editor
A compiler
An operating system
None of these.
Which is the only function all C programs must contain?
start()
system()
printf()
main()
Which of the following is not a correct variable type?
float
real
int
char
Input/output function prototypes and macros are defined in which header file?
conio.h
stdlib.h
stdio.h
dos.h
Which of the following is the correct operator to compare two variables?
equal
=
:=
==
The "\n" character does which of the following operations?
Double line spacing
Character deletion
Character backspace
Places cursor on the next line
Which arithmetic operator in C returns the integer remainder of the result of dividing its first operand by its second?
%
/
\
*
What is the value of this expression using integer arithmetic:
7 / 4
1
2
1.75
What is the value of a in this code fragment
int a=3, b;
0
Nothing
3
Determine the value of this expression using integer arithmetic:
5 % 7
0
2
5
Determine the value of b in this code fragment:
int a=3, b;
b=++a;
3
4
2
Determine the value of the expression using integer arithmetic:
6 * 9 % 3 / 2
2
0
18
Determine the value of a in the second line of the code fragment:
int a=1, b=2;
a=b--;
1
0
2
Determine the value of b in the second line of the code fragment:
int a=1, b=2;
a=b--;
1
0
2
Which line of code is correct for the statement:
Add 1 variable to x.
x++;
x+1
x+x
Which line of code is incorrect for the statement:
Subtract 4 from the variable y.
y-4
y=y-4
y-=4
Which line of code is correct for the statement:
Read in a value for the integer variable num.
printf("%d", &num);
scanf("%d", num);
scanf("%d", &num);
What is the EXACT output from this code fragment:
float num=3.238;
printf("num=%.2f", num);
Number=3.2
num=3.238
num=3.24
What is the EXACT output from this code fragment:
int num=10;
if(num> 7 % 3 / 2 * 3)
printf("This is True");
else
printf("This is False");
This is True
This is False
What symbol is used in conditional operators for AND:
AND
&&
&
What will be printed on the screen from this fragment:
int num=0;
printf("%d", ++num)
0
1
2
What is the abbreviated way to write this assignment statement:
total=total+num;
t=t+n;
total+=num
total=(total+num)
The statement above refer to ........................ phase
The statement above refer to ................. phase
The statement above refer to
What is the output given by this C code?
3210
321
Compiler error
3
In C programming language, what is the symbol II?
Arithmetic operator
This symbol is unrecognised in C
Logical operator
This is the name typically given to an int variable
Fill the blank: instruction _____ is used to provide a value to the instruction that called a function
result
return
exit
break
In C variables can ONLY be declared as numeric?
TRUE
FALSE
Which instruction will print on the screen exactly the text \n?
printf(“n\”);
printf(“n”);
printf(“\\n”);
printf(“\n”);
a=5, b=3, 0
a=5, b=3, c=4
a=5, b=3
Compiler error
Which symbol always finalizes an instruction in C code?
(a)
Is this code correct? (no errors or warnings)
No, the name myprint is not correct
Yes, there is no problem at all
No, if it indicates int in the signature, a value should be returned
Yes, but k is printed as a double number
What is a pointer in C?
Any element in a C program
It refers to the memory address of a variable
It is exactly a regular variable
It is a specific kind of function
Which instruction is for choosing among multiple options depending on the value of a single variable? (Just one word in lowercase)
(a)
A single-line comment in C starts by...
/*
//
;
:
Fill the gap: A _______ variable, declared in a function, will only be available for that function
local
global
fake
lazy
Fill the gap: If a parameter received by a function could be changed, pass-by-__________ is necessary
value
reference
free
One _________ is a derived datatype, built using several elements which could be from distinct datatype
loop
array
include
struct
The collection of multiple elements of the same nature and linearly indexed under the same name is called...
struct
array
matrix
variable
Could we assign a float variable to a long integer in C?
YES
NO
When inside a function a call to itself is done we call it...
Iteration
Reiteration
Recursion
This is forbidden
One constant is…
Procedure/function which always does the same
Global variable all functions can use
Global variable all procedures can use
Value which can not be modified after its declaration
What is the term for ..."a sequence of logical instructions or steps needed to finish a task. Can be performed with or without a computer"?
design
coding
algorithm
program
