Class 6 Exam  >  Class 6 Tests  >  Test: C Function Declaration - Class 6 MCQ

Test: C Function Declaration - Class 6 MCQ


Test Description

10 Questions MCQ Test - Test: C Function Declaration

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

What will be the output of the following C code?

#include <stdio.h>
    void foo(const int *);
    int main()
    {
        const int i = 10;
        printf("%d ", i);
        foo(&i);
        printf("%d", i);
 
    }
    void foo(const int *i)
    {
        *i = 20;
    }

Detailed Solution for Test: C Function Declaration - Question 1

Cannot change a const type value.
Output:
$ cc pgm1.c
pgm1.c: In function ‘foo’:
pgm1.c:13: error: assignment of read-only location ‘*i’

Test: C Function Declaration - Question 2

What will be the output of the following C code?

#include <stdio.h>
    int main()
    {
        const int i = 10;
        int *ptr = &i;
        *ptr = 20;
        printf("%d\n", i);
        return 0;
    }

Detailed Solution for Test: C Function Declaration - Question 2

Changing const variable through non-constant pointers invokes compiler warning.
Output:
$ cc pgm2.c
pgm2.c: In function ‘main’:
pgm2.c:5: warning: initialization discards qualifiers from pointer target type
$ a.out
20

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: C Function Declaration - Question 3

What will be the output of the following C code?

#include <stdio.h>
    int main()
    {
        j = 10;
        printf("%d\n", j++);
        return 0;
    }

Detailed Solution for Test: C Function Declaration - Question 3

Variable j is not defined.
Output:
$ cc pgm3.c
pgm3.c: In function ‘main’:
pgm3.c:4: error: ‘j’ undeclared (first use in this function)
pgm3.c:4: error: (Each undeclared identifier is reported only once
pgm3.c:4: error: for each function it appears in.)

Test: C Function Declaration - Question 4

Will the following C code compile without any error?

#include <stdio.h>
    int main()
    {
        for (int k = 0; k < 10; k++);
            return 0;
    }

Detailed Solution for Test: C Function Declaration - Question 4

Compilers implementing C90 do not allow this, but compilers implementing C99 allow it.
Output:
$ cc pgm4.c
pgm4.c: In function ‘main’:
pgm4.c:4: error: ‘for’ loop initial declarations are only allowed in C99 mode
pgm4.c:4: note: use option -std=c99 or -std=gnu99 to compile your code

Test: C Function Declaration - Question 5

Will the following C code compile without any error?

#include <stdio.h>
    int main()
    {
        int k;
        {
            int k;
            for (k = 0; k < 10; k++);
        }
    }

Detailed Solution for Test: C Function Declaration - Question 5

There can be blocks inside the block. But within a block, variables have only block scope.
Output:
$ cc pgm5.c

Test: C Function Declaration - Question 6

Which of the following declaration is not supported by C?

Detailed Solution for Test: C Function Declaration - Question 6

It is legal in Java, but not in C.

Test: C Function Declaration - Question 7

Which of the following format identifier can never be used for the variable var?

#include <stdio.h>
    int main()
    {
        char *var = "Advanced Training in C by Sanfoundry.com";
    }

Detailed Solution for Test: C Function Declaration - Question 7

%c can be used to print the indexed position.
%d can still be used to display its ASCII value.
%s is recommended.
%f cannot be used for the variable var.

Test: C Function Declaration - Question 8

Which of the following declaration is illegal?

Detailed Solution for Test: C Function Declaration - Question 8

char[] str is a declaration in Java, but not in C.

Test: C Function Declaration - Question 9

Which keyword is used to prevent any changes in the variable within a C program?

Detailed Solution for Test: C Function Declaration - Question 9

const is a keyword constant in C program.

Test: C Function Declaration - Question 10

Which of the following is not a pointer declaration?

Detailed Solution for Test: C Function Declaration - Question 10

Array declarations are pointer declarations.

Information about Test: C Function Declaration Page
In this test you can find the Exam questions for Test: C Function Declaration solved & explained in the simplest way possible. Besides giving Questions and answers for Test: C Function Declaration, EduRev gives you an ample number of Online tests for practice

Top Courses for Class 6

Download as PDF

Top Courses for Class 6