Explore topic-wise MCQs in R Programming.

This section includes 29 Mcqs, each offering curated multiple-choice questions to sharpen your R Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

Can the break statement be used to abort a program?

A. Yes
B. Yes, but only if it is used within the global scope
C. No
D. Yes, but only for some Arduino Boards
Answer» D. Yes, but only for some Arduino Boards
2.

What is the output of the code given below if the input is 1101 to pin 10?

A. HIGH HIGH LOW HIGH
B. HIGH HIGH HIGH HIGH
C. HIGH HIGH HIGH
D. LOW LOW HIGH HGHView Answer
Answer» D. LOW LOW HIGH HGHView Answer
3.

What is the output of the code given below if there is a constant 5V supply to pin 10?

A. 1023
B. 1024
C. null
D. 1029View Answer
Answer» B. 1024
4.

Which one of the control structures is similar to the if-else statement?

A. Switch-case
B. For loop
C. While loop
D. Continue
Answer» B. For loop
5.

Is the code snippet given below wrong?

A. No
B. YesView Answer
Answer» B. YesView Answer
6.

What is the name of the control structure used to stop any loop prematurely and only exit out of the loop, not affecting the running of the rest of the program?

A. The continue statement
B. The break statement
C. The exit statement
D. The purge statement
Answer» C. The exit statement
7.

Which of the following control structures is an exit-controlled loop?

A. For loop
B. While loop
C. Const and Goto
D. Do-While loop
Answer» E.
8.

What is the output of the code given below?

A. 10
B. 12
C. 13
D. nullView Answer
Answer» D. nullView Answer
9.

Which of the following should be preferred for evaluation from list of alternatives?

A. subsett
B. eval
C. switch
D. set
Answer» C. switch
10.

Which of the following statement can be used to explicitly control looping?

A. if
B. while
C. break
D. for
Answer» D. for
11.

_______ is used to break the execution of a loop.

A. next
B. skip
C. break
D. delete
Answer» D. delete
12.

Which of the following R syntax is correct for while loop?

A. while ( statement1 ) statement2
B. while ( statement1 ) else statement2
C. while ( statement1 ) do statement2
D. while ( statement2 ) doelse statement2
Answer» B. while ( statement1 ) else statement2
13.

What will be printed if the following code is executed?void main(){int x=0;for( ; ; ){if( x++ == 4 ) break;continue;}printf("x=%d", x);}

A. 0
B. 5
C. 4
D. 1
E. rror
Answer» C. 4
14.

What will be the following code's output if choice = 'R'?switch(choice){case 'R' : printf("RED");case 'W' : printf("WHITE");case 'B' : printf("BLUE");default: printf("ERROR");break;}

A. ED
B. ED WHITE BLUE ERROR
C. ED ERROR
D. ED WHITE BLUE
E. RROR
Answer» C. ED ERROR
15.

What will be the final value of the digit?void main(){int digit = 0;for( ; digit <= 9; )digit++;digit*= 2;--digit;}

A. 1
B. 7
C. 9
D. 6
E. 0
Answer» D. 6
16.

What is the right choice, if the following loop is implemented?void main(){int num = 0;do{--num;printf("%d", num);}while( ++num >= 0 );}

A. run time error will be generated.
B. he program will not enter into the loop.
C. here will be a compilation error reported.
D. he loop will run infinitely many times.
E. rints the value of 0 one time only.
Answer» E. rints the value of 0 one time only.
17.

Find the output of the following program.#includevoid main(){int y=10;if(y++>9 && y++!=10 && y++>11)printf("%d", y);elseprintf("%d", y);}

A. 1
B. 2
C. 3
D. 4
E. ompilation error
Answer» D. 4
18.

What is the output of the following statements?for(i=10; i++; i<15)printf("%d ", i);

A. 0 11 12 13 14
B. 0 11 12 13 14 15
C. 10 11 12 13
D. nfinite loop
E. one of these
Answer» E. one of these
19.

What is the output of the following program?#includeint c[10] = {1,2,3,4,5,6,7,8,9,10};main(){int a, b=0;for(a=0;a<10;++a)if(c[a]%2 == 1)b+=c[a];printf("%d", b);}

A. 0
B. 4
C. 5
D. 0
E. one of these
Answer» D. 0
20.

What will be the output of the following code?#includevoid main(){int s=0;while(s++<10){if(s<4 && s<9)continue;printf("%dt", s);}}

A. 2 3 4 5 6 7 8 9
B. 2 3 10
C. 5 6 7 8 9 10
D. 5 6 7 8 9
E. one of these
Answer» D. 5 6 7 8 9
21.

What will be the output of given program?#includevoid main(){int i=1, j=-1;if((printf("%d", i)) < (printf("%d", j)))printf("%d", i);elseprintf("%d", j);}

A. -1 1
B. -1 -1
C.
D. 1
Answer» B. -1 -1
22.

What will be the output of the given program?#includevoid main(){ float num=5.6; switch(num){case 5:printf("5");case 6:printf("6");default : printf("0");break; } printf("%d", num);}

A. 5.600000
B. 5.600000
C. 5.600000
D. omplier error
Answer» E.
23.

What will be the output of the given program?#includevoid main(){int value=0;if(value)printf("well done ");printf("examveda");}

A. ell doneexamveda
B. xamveda
C. omplier error
D. one of these
Answer» C. omplier error
24.

What will be the value of i and j after execution of following program?#includevoid main(){ int i, j; for(i=0,j=0;i<10,j<20;i++,j++){printf("i=%d %t j=%d", i, j);}}

A. 0 10
B. 0 20
C. 0 20
D. un time error
Answer» D. un time error
25.

What will be the output of the given program?#includevoid main(){inti=10;printf("i=%d", i);{inti=20;printf("i=%d", i);i++;printf("i=%d", i);}printf("i=%d", i);}

A. 0 10 11 11
B. 0 20 21 21
C. 0 20 21 10
D. 0 20 21 20
Answer» D. 0 20 21 20
26.

What is the output of given program if user enter "xyz" ?#includevoid main(){ float age, AgeInSeconds; int value; printf("Enter your age:"); value=scanf("%f", &age); if(value==0){printf("\\nYour age is not valid"); } AgeInSeconds = 365 * 24 * 60 * 60 * age; printf("\\n You have lived for %f seconds", AgeInSeconds);}

A. nter your age : xyzYour age is not valid
B. nter your age: xyzYou have lived for 0 seconds
C. nter your age: xyzYour age is not valid
D. omplier error
Answer» D. omplier error
27.

What is the output of given program if user enter "xyz" ?#includevoid main(){ float age, AgeInSeconds; printf("Enter your age:"); scanf("%f", &age); AgeInSeconds = 365 * 24 * 60 * 60 * age; printf("You have lived for %f seconds", AgeInSeconds);}

A. nter your age: xyzYou have lived for 0 seconds
B. nter your age: xyzYou have lived for 0.00000 seconds
C. nter your age: xyz"after that program will stop"
D. un time error
Answer» C. nter your age: xyz"after that program will stop"
28.

What is the output of given program if user enter value 99?#includevoid main(){ int i; printf("Enter a number:"); scanf("%d", &i); // 99 is given as input. if(i%5 == 0){printf("nNumber entered is divisible by 5");}}

A. nter a number:99
B. nter a number:99Number is divisible by 5
C. omplier error
D. un time error
Answer» B. nter a number:99Number is divisible by 5
29.

Which of the following syntax is correct for while loop ?

A. while ( statement1 ) statement2
B. while ( statement1 ) else statement2
C. while ( statement1 ) do statement2
D. All of the mentioned
Answer» D. All of the mentioned