CNIT 105 EXAM 1 QUESTIONS & ANSWERS
What is the extension of the source file of 'C' program? - Answers -.c
What is the standard way to scan a float variable x? - Answers -scanf("%f", &x);
What is the standard way to print a character variable c; char c = 'C' - Answers -
printf("%c", c);
In a C program, the execution begins with which function? - Answers -main( ) function
When you don't want the function to return anything, what return type will you use? -
Answers -void
Which of the following option is a prototype of the given function?
int divide(int a, int b){
return a / b;
} - Answers -int divide(int, int);
Identify the problem in the code:
float comput(int a, int b){
float answer;
answer = a / b;
} - Answers -Function doesn't return anything
How many times will the loop 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); - Answers -Infinite times
What is the scope of a variable? - Answers -It is the segment of the code where the
variable can be used
What is output of the code:
int n;
for(n = 1; n <= 10, n++){
printf("%d", n);
What is the extension of the source file of 'C' program? - Answers -.c
What is the standard way to scan a float variable x? - Answers -scanf("%f", &x);
What is the standard way to print a character variable c; char c = 'C' - Answers -
printf("%c", c);
In a C program, the execution begins with which function? - Answers -main( ) function
When you don't want the function to return anything, what return type will you use? -
Answers -void
Which of the following option is a prototype of the given function?
int divide(int a, int b){
return a / b;
} - Answers -int divide(int, int);
Identify the problem in the code:
float comput(int a, int b){
float answer;
answer = a / b;
} - Answers -Function doesn't return anything
How many times will the loop 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); - Answers -Infinite times
What is the scope of a variable? - Answers -It is the segment of the code where the
variable can be used
What is output of the code:
int n;
for(n = 1; n <= 10, n++){
printf("%d", n);