CNIT 105 QUESTIONS AND ANSWERS
Which of the following is the standard way to print a character variable c; char c = 'C';
printf("%d", c);
printf("%c", c);
printf("%s", c);
printf("%c", &c); - Answers -printf("%c", c);
What is the extension of the source file of 'c' program?
.exe
.obj
.c
.cpp - Answers -.c
Which of the following is the standard way to scan a float variable x?
float x;
scanf("%f", &x);
scanf("%.2f", &x);
scanf("%d", &x);
scanf("%f", x); - Answers -scanf("%f", &x);
In a C program, the execution begins with which function?
main ( ) function
Doesn't matter
First function in the program
There is no function in c program - Answers -main ( ) function
When you don't want the function to return anything which of the following return type
will you use?
int
void
Nothing
float - Answers -void
Which of the following option is a prototype of the given function?
int divide(int a, int b) {
return a / b
, }
int divide (int, int);
int divide ( );
int divide (int a, int b);
void divide (int a, int b); - Answers -int divide (int, int);
Identify the problem in the following code
float compute (int a, int b) {
float answer;
answer = a / b;
}
Variable answer should be of type int
There is nothing wrong with this function
Function doesn't return anything
Output type of the function should be int - Answers -Function doesn't return anything
How many times will the loop in the following code run
int main ( ) {
int n = 1;
int sum = 0;
while ( n <= 10 ) {
sum = sum + n;
}
printf("Sum of numbers from 1 to 10 is: %d", sum);
}
The loop will run infinite times
The loop will run 11 times
The loop will run 10 times
The loop will not execute - Answers -The loop will run infinite times
What is the scope of a variable
It is a data type of the variable
It is the segment of the code where the variable can be used
It is a location of the variable in RAM
It is the same as name of the variable - Answers -It is the segment of the code where
the variable can be used
What will be the output of the following code
Which of the following is the standard way to print a character variable c; char c = 'C';
printf("%d", c);
printf("%c", c);
printf("%s", c);
printf("%c", &c); - Answers -printf("%c", c);
What is the extension of the source file of 'c' program?
.exe
.obj
.c
.cpp - Answers -.c
Which of the following is the standard way to scan a float variable x?
float x;
scanf("%f", &x);
scanf("%.2f", &x);
scanf("%d", &x);
scanf("%f", x); - Answers -scanf("%f", &x);
In a C program, the execution begins with which function?
main ( ) function
Doesn't matter
First function in the program
There is no function in c program - Answers -main ( ) function
When you don't want the function to return anything which of the following return type
will you use?
int
void
Nothing
float - Answers -void
Which of the following option is a prototype of the given function?
int divide(int a, int b) {
return a / b
, }
int divide (int, int);
int divide ( );
int divide (int a, int b);
void divide (int a, int b); - Answers -int divide (int, int);
Identify the problem in the following code
float compute (int a, int b) {
float answer;
answer = a / b;
}
Variable answer should be of type int
There is nothing wrong with this function
Function doesn't return anything
Output type of the function should be int - Answers -Function doesn't return anything
How many times will the loop in the following code run
int main ( ) {
int n = 1;
int sum = 0;
while ( n <= 10 ) {
sum = sum + n;
}
printf("Sum of numbers from 1 to 10 is: %d", sum);
}
The loop will run infinite times
The loop will run 11 times
The loop will run 10 times
The loop will not execute - Answers -The loop will run infinite times
What is the scope of a variable
It is a data type of the variable
It is the segment of the code where the variable can be used
It is a location of the variable in RAM
It is the same as name of the variable - Answers -It is the segment of the code where
the variable can be used
What will be the output of the following code