Class 6 Exam  >  Class 6 Tests  >  C Programming for Beginners  >  Test: Basics of Structures - Class 6 MCQ

Test: Basics of Structures - Class 6 MCQ


Test Description

10 Questions MCQ Test C Programming for Beginners - Test: Basics of Structures

Test: Basics of Structures for Class 6 2024 is part of C Programming for Beginners preparation. The Test: Basics of Structures questions and answers have been prepared according to the Class 6 exam syllabus.The Test: Basics of Structures MCQs are made for Class 6 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Basics of Structures below.
Solutions of Test: Basics of Structures questions in English are available as part of our C Programming for Beginners for Class 6 & Test: Basics of Structures solutions in Hindi for C Programming for Beginners course. Download more important topics, notes, lectures and mock test series for Class 6 Exam by signing up for free. Attempt Test: Basics of Structures | 10 questions in 10 minutes | Mock test for Class 6 preparation | Free important questions MCQ to study C Programming for Beginners for Class 6 Exam | Download free PDF with solutions
Test: Basics of Structures - Question 1

What is the output of given program if user enter value 99?

#include<stdio.h>
void 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");
        }
}

Detailed Solution for Test: Basics of Structures - Question 1

since this program isn't having any syntax error so program is executed. It is clearly seen that 99 is not divisible by 5. So if statement will not execute and program will terminate.

Test: Basics of Structures - Question 2

What is the output of given program if user enter "xyz" ?

#include
void 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);
}

Detailed Solution for Test: Basics of Structures - Question 2

When we give scanf() a "%f" format string, that means "We want you to try and get us a floating point number. When we provide input like 'xyz', it's not going to match anything, because 'xyz' is not a valid floating-point number.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Basics of Structures - Question 3

What will be the value of i and j after execution of following program?

#include<stdio.h>
void main()
{
    int i, j;
    for(i=0,j=0;i<10,j<20;i++,j++){
        printf("i=%d %t j=%d", i, j);
       }
}

Detailed Solution for Test: Basics of Structures - Question 3

comma operator is executed from left to right so until j<20 for loop statement is true, so both i and j are incremented.
So, i = 20 and j = 20.

Test: Basics of Structures - Question 4

What will be the output of the given program?

#include<stdio.h>
void main()
{
    int a=11,b=5;
    if(a=5) b++;
    printf("%d %d", ++a, b++);
}

Detailed Solution for Test: Basics of Structures - Question 4

Here if condition evaluates to true as a non-zero value i.e 5 is assigned to a.
So the value of a = 5 and after increment value of b = 6.
In printf statement due to pre-increment of a value of a printed will be 6 and due to post-increment of b value of b printed will be 6 and not 7.

Test: Basics of Structures - Question 5

What will be the output of the given program?

#include<stdio.h>
void main()
{
    int value1, value2=100, num=100;
    if(value1=value2%5) num=5;
    printf("%d %d %d", num, value1, value2);
}

Detailed Solution for Test: Basics of Structures - Question 5

Expression value2%5 is equal to 0 and this value assigned to value1.
Therefore if condition reduces to if(0) so it fails.
Therefore body of if will not be executed i.e num = 5 will not be assigned.
So at printf num = 100 , value1 = 0 and value2 = 100.

Test: Basics of Structures - Question 6

What will be the output of given program?

#include<stdio.h>
void main()
{
    int a=1;
    if("%d=hello", a);
}

Detailed Solution for Test: Basics of Structures - Question 6

the if is conditional and it checks for expression whether it is zero or non-zero so it doesn't print any data it is clear and it is clearly seen that there is not a single syntax error therefore no complier error.
After compling the program will be executed but there is not a single printf statement so it is executed but will not give any output.

Test: Basics of Structures - Question 7

What will be the output of given program?

#include<stdio.h>
void main()
{
      int i=1, j=-1;
      if((printf("%d", i)) < (printf("%d", j))) 
            printf("%d", i);
      else 
            printf("%d", j);
}

Detailed Solution for Test: Basics of Structures - Question 7

Here if statement is executed since we know that printf() function return the number of character print.
Here printf("%d", i) return 2 because it print 1 and newline i.e 2.
And, printf("%d', j) return 3 because it print -1 and newline i.e number of character is 3.
Therefore if statement look like if(2<3) yes its true.
So if statement will execute. And answer is 1 -1 1.

Test: Basics of Structures - Question 8

What is the output of the following program?

#include<stdio.h>
int 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);
}

Detailed Solution for Test: Basics of Structures - Question 8

Condition if(c[a]%2 == 1) forces only odd numbers to add in the sum.

Test: Basics of Structures - Question 9

Find the output of the following program.

#include<stdio.h>
void main()
{
   int y=10;
   if(y++>9 && y++!=10 && y++>11)
      printf("%d", y);
   else
      printf("%d", y);
}

Detailed Solution for Test: Basics of Structures - Question 9

Here if Statement is true and if statement executes left to right. Since its AND operator so all the condition should be check until it finds any false statement. Initially y = 10 In 1st condition: y++>9 which is true and y become 11 in next use. In 2nd condition: y++!=10 which is also true and y become 12 in next use In 3rd condition: y++>11 which is also true and y become 13 in next use After that printf statement will execute and print y = 13

Test: Basics of Structures - Question 10

What will be the final value of the digit?

void main()
{
   int digit = 0;
   for( ; digit <= 9; )
   digit++;
   digit  *= 2;
   --digit;
}

Detailed Solution for Test: Basics of Structures - Question 10

First of all for loop have no braces so for loop on have only next line in its body.
for( ; digit <= 9; )
digit++;
After completing for loop digit = 10;
next statement digit *= 2; i.e digit = digit * 2 = 20;
next statement digit--; i.e 20-- => 19
So final value of digit is 19

10 videos|13 docs|15 tests
Information about Test: Basics of Structures Page
In this test you can find the Exam questions for Test: Basics of Structures solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Basics of Structures, EduRev gives you an ample number of Online tests for practice

Top Courses for Class 6

10 videos|13 docs|15 tests
Download as PDF

Top Courses for Class 6