You are on page 1of 14

7/14/2021 C-Test-24mcqs+8qs

Started on Wednesday, 14 July 2021, 3:51 PM


State Finished
Completed on Wednesday, 14 July 2021, 4:20 PM
Time taken 28 mins 43 secs
Marks 28.00/40.00
Grade 70.00 out of a maximum of 100.00

Question 1 What will be output when you execute the following C code?
Complete
#include<stdio.h>
Mark 1.00 out of
1.00 void main(){
int a=100;
Flag question if(a>100)
printf("M.S. Dhoni");
else if(a>20)
printf("M.E.K Hussey");
else if(a>30)
printf("A.B. de villiers");
}

Select one:
Compilation Error
M. S. Dhoni
M. E. K Hussey
A. B. de Villiers

Question 2 What will be the output of the following C program?


Complete #include<stdio.h>
Mark 1.00 out of int main()
1.00 {
Flag question
int arr[1]={10};
printf("%d", arr[0]);
return 0;
}

Select one:
1

https://onlinetest.spoken-tutorial.org/mod/quiz/review.php?attempt=1415591&showall=1 1/14
7/14/2021 C-Test-24mcqs+8qs

0
10
6

Question 3 Which format specifier is used for array of char?


Complete
Mark 0.00 out of Select one:
1.00 %f
Flag question %s
%d
%c

Question 4 Which of the following statements should NOT be used to increase the value of c by 1?
Complete
Mark 1.00 out of Select one:
1.00 c += 1
Flag question
c = c + 1;
c + 1 => c;
c++;

Question 5 What is the data-type of '9'?


Complete
Mark 0.00 out of Select one:
1.00 double
Flag question int
float
char

Question 6 Which keyword is used to transfer control from a function back to the calling function?
Complete
https://onlinetest.spoken-tutorial.org/mod/quiz/review.php?attempt=1415591&showall=1 2/14
7/14/2021 C-Test-24mcqs+8qs
Mark 1.00 out of Select one:
1.00
goto
Flag question
switch
return
go back

Question 7 What will be the output of the following C program?


Complete #include<stdio.h>
Mark 1.00 out of int sumdig(int);
1.00 int main()
Flag question
{
int a, b;
a = sumdig(123);
b = sumdig(123);
printf("%d, %d", a, b);
return 0;
}
int sumdig(int n)
{
int s, d;
if(n!=0)
{
d = n%10;
n = n/10;
s = d+sumdig(n);
}
else
return 0;
return s;
}

Select one:
12, 12
6, 6
3, 3
4, 4

https://onlinetest.spoken-tutorial.org/mod/quiz/review.php?attempt=1415591&showall=1 3/14
7/14/2021 C-Test-24mcqs+8qs

Question 8 What will be the output of the following program?


Complete #include<stdio.h>
Mark 1.00 out of int main()
1.00 {
Flag question
int i = 5;
while(i-- >= 0)
printf("%d,", i);
i = 5;
printf("\n");
while(i-- >= 0)
printf("%i,", i);
while(i-- >= 0)
printf("%d,", i);
return 0;
}

Select one:
Error
4, 3, 2, 1, 0, -1
4, 3, 2, 1, 0, -1
5, 4, 3, 2, 1, 0
5, 4, 3, 2, 1, 0
5, 4, 3, 2, 1, 0
5, 4, 3, 2, 1, 0
5, 4, 3, 2, 1, 0

Question 9 What will be the output of the following program?


Complete #include<stdio.h>
Mark 1.00 out of int main()
1.00 {
Flag question void fun(char*);
char a[100];
a[0] = 'A'; a[1] = 'B';
a[2] = 'C'; a[3] = 'D';
fun(&a[0]);
return 0;
}
void fun(char *a)
{
a++;
https://onlinetest.spoken-tutorial.org/mod/quiz/review.php?attempt=1415591&showall=1 4/14
7/14/2021 C-Test-24mcqs+8qs

printf("%c", *a);
a++;
printf("%c", *a);
}

Select one:
BC
CD
AB
No output

Question 10 Which of the following is the correct way of writing a comment in C?


Complete
Mark 1.00 out of Select one:
1.00 { Comment }
Flag question */ Comments */
/* Comment */
** Comment **

Question 11 Which one of the following declarations is correct?


Complete
Mark 1.00 out of Select one:
1.00 int long;
Flag question float double;
int length;
char int;

Question 12 If originally x=10, what is the value of the expression:


Complete --x;
Mark 0.00 out of
1.00
Select one:
Flag question 0

https://onlinetest.spoken-tutorial.org/mod/quiz/review.php?attempt=1415591&showall=1 5/14
7/14/2021 C-Test-24mcqs+8qs

9
10
11

Question 13 What will be the output of the following C program?


Complete #include<stdio.h>
Mark 1.00 out of
1.00
int main()
{
Flag question static char s[25] = "Hello world";
int i=0;
char ch;
ch = s[++i];
printf("%c", ch);
ch = s[i++];
printf("%c", ch);
ch = s[i++];
printf("%c", ch);
return 0;
}

Select one:
eee
eel
hel
ell

Question 14 Which of the following is used to comment a single-line in a C Program?


Complete
Mark 1.00 out of Select one:
1.00 +/
Flag question /*
*/
//

https://onlinetest.spoken-tutorial.org/mod/quiz/review.php?attempt=1415591&showall=1 6/14
7/14/2021 C-Test-24mcqs+8qs

Question 15 What is the output of the following statement?


Complete x=y=z=0;
Mark 1.00 out of
1.00 Select one:
Flag question x=0, y=NULL, z=NULL
x=0, y=0, z=0
x=0, y=1, z=2
The statement is incorrect

Question 16 The result of a relational operation is always:


Complete
Mark 1.00 out of Select one:
1.00 All of these
Flag question Always False
Always True
Either True or False

Question 17 What will be the output of the following C program?


Complete #include <stdio.h>
Mark 1.00 out of main(){
1.00 int i,a[10];
Flag question
int *j;
for(i=0;i<3;i++)a[i]=i*2;
j=a;
for(i=0;i<3;i++)
printf("%d", (*j)++);
}

Select one:
01
111
0
012

https://onlinetest.spoken-tutorial.org/mod/quiz/review.php?attempt=1415591&showall=1 7/14
7/14/2021 C-Test-24mcqs+8qs

Question 18 What is the purpose of namespace?


Complete
Mark 0.00 out of Select one:
1.00 To group functions
Flag question To execute a program
To create an object
To avoid name collisions

Question 19 What will be the output of the following C program?


Complete #include<stdio.h>
Mark 1.00 out of int main()
1.00 {
Flag question
char str[7] = "India";
printf("%s", str);
return 0;
}

Select one:
0
India
None of these
Error

Question 20 What will be the output of the following program?


Complete #include<stdio.h>
Mark 1.00 out of int main()
1.00 {
Flag question
int i=4;
switch(i)
{
default:
printf("This is default.");
case 1:
printf("This is case 1");
break;
case 2:

https://onlinetest.spoken-tutorial.org/mod/quiz/review.php?attempt=1415591&showall=1 8/14
7/14/2021 C-Test-24mcqs+8qs

printf("This is case 2");


break;
case 3:
printf("This is case 3");
}
return 0;
}

Select one:
This is default.This is case 1
This is case 1
This is default.
This is case 3

Question 21 If x=10 and sum=0, what is the value of sum after we execute sum=++x?
Complete
Mark 0.00 out of Select one:
1.00 10
Flag question 9
11
0

Question 22 How many time(s) the statement(s) in the do-while loop will be executed, if the condition is false?
Complete
Mark 1.00 out of Select one:
1.00 0
Flag question 1
Infinite
2

Question 23 Point out the error line in the following program.


Complete 1. #include<stdio.h>
2. struct emp
https://onlinetest.spoken-tutorial.org/mod/quiz/review.php?attempt=1415591&showall=1 9/14
7/14/2021 C-Test-24mcqs+8qs
Mark 1.00 out of 3. {
1.00
4. char name[20];
Flag question 5. int age;
6. };
7. int main()
8. {
9. emp int xx;
10. int a;
11. printf("%d\n", a);
12. return 0;
13. }

Select one:
Line number 9
None of these.
Line number 4
Line number 7

Question 24 Point out the error line in the following program.


Complete 1. #include<stdio.h>
Mark 1.00 out of 2. int main()
1.00 3. {
Flag question
4. void v = 0;
5. printf("%d", v);
6. return 0;
7. }

Select one:
None of these.
Line number 5
Line number 4
Line number 6

Question 25 Which of the following expression(s) changes the value of x? Tick all correct answer(s). No partial marks and no negative marks.
Complete
Mark 0.00 out of Select one or more:
2.00
https://onlinetest.spoken-tutorial.org/mod/quiz/review.php?attempt=1415591&showall=1 10/14
7/14/2021 C-Test-24mcqs+8qs

Flag question x
x++
++x
--x

Question 26 Which of the following statement(s) is/are correct? Tick all correct answer(s). No partial marks and no negative marks.
Complete Constants
Mark 0.00 out of
2.00
Select one or more:
Flag question Are fixed values
Are declared using 'const' keyword
Do not change during the execution of the program

Question 27 Which of the following statement(s) is/are correct about an array? Tick all correct answer(s). No partial marks and no negative
Complete marks.
Mark 2.00 out of
2.00 Select one or more:
Flag question The declaration num[SIZE] is allowed if SIZE is a macro.
The array int num[26]; can store 26 elements.
The expression num[1] designates the very first element in the array.
It is necessary to initialize the array at the time of declaration.

Question 28 Select the missing code lines from the dropdown provided.
Complete The C code given below should check whether the number entered by the user is Negative, Positive or Zero.
Mark 0.00 out of But, line numbers 9 and 11 are missing.
2.00

Flag question 1. #include <stdio.h>


2. int main()
3. {
4. int num;
5. printf("Enter a number: ");
6. scanf("%d",&num);
7. if (num<0)
https://onlinetest.spoken-tutorial.org/mod/quiz/review.php?attempt=1415591&showall=1 11/14
7/14/2021 C-Test-24mcqs+8qs

8. printf("%d is negative.",num);
9. ---------------Missing code -------------------
10. printf("%d is positive.",num);
11. ---------------Missing code -------------------
12. printf("You entered zero.");
13. return 0;
14. }

Line 9 scanf("%d",&num);

Line 11
scanf("%d",&num);

Question 29 Select the missing code lines from the dropdown provided.
Complete The C code given below should find the square of a given number.
Mark 1.00 out of But, line numbers 4 and 6 are missing.
2.00

Flag question

1. #include<stdio.h>
2. int main()
3. {
4. ---------------Missing code -------------------
5. printf("Enter the number\n");
6. ---------------Missing code -------------------
7. printf("Square of %d is %d \n", num, num*num);
8. return 0;
9. }

Line 4 int num;

Line 6 num = num*num;

Question 30 Select the missing code lines from the dropdown provided.
Complete
https://onlinetest.spoken-tutorial.org/mod/quiz/review.php?attempt=1415591&showall=1 12/14
7/14/2021 C-Test-24mcqs+8qs
Mark 2.00 out of The C code given below should print the sum of digits of a number entered by the user.
2.00
But, line numbers 6 and 10 are missing.
Flag question
1. #include<stdio.h>
2. int main()
3. {
4. int num, sum=0, rem;
5. printf("Enter a number\n");
6. ---------------Missing code -------------------
7. while(num>0)
8. {
9. rem = num%10;
10. ---------------Missing code -------------------
11. num = num/10;
12. }
13. printf("Sum is %d\n", sum);
14. return 0;
15. }

Line 6 scanf("%d", &num);

Line 10
sum = sum+rem;

Question 31 What will be the output of the program? Write the answer in digits not alphabets.
Complete #include<stdio.h>
Mark 2.00 out of int main()
2.00 {
Flag question
int a=2,b=6,c;
c = a%b;
printf("%d",c);
return 0;
}

Answer: 2

Question 32 What will be the output of the program? Write the answer in digits not alphabets.
Complete
https://onlinetest.spoken-tutorial.org/mod/quiz/review.php?attempt=1415591&showall=1 13/14
7/14/2021 C-Test-24mcqs+8qs
Mark 2.00 out of #include<stdio.h>
2.00
int main()
Flag question {
int a=6;
int b=-4;
int c=0;
if(b>a)
printf("%d",c);
printf("%d",(a-b));
return 0;
}

Answer: 10

https://onlinetest.spoken-tutorial.org/mod/quiz/review.php?attempt=1415591&showall=1 14/14

You might also like