Alien head

C programming

Attempted 0/15 Correct 0 Score 0

Wild pointer in 'C' ____________.

  1. is initialized by constant

  2. is not initialized.

  3. does not exist in C language

  4. only takes 'int' values

  5. works like null pointer


Correct Option: B
Explanation:

A pointer which is not initialized in C, is known as Wild Pointer.

Find the output of the following expression.
#include<stdio.h>
#include<conio.h>
void main()
{

int x, y =3;

x= ++y + 7;

printf(" %d " , x)
}

  1. 10

  2. 11

  3. 8

  4. 12

  5. None of the above


Correct Option: B
Explanation:

x = (y+1) + 7 = 4+7 = 11

FInd the output of the following expression.
#include<stdio.h>
#include<conio.h>
void main()
{

int i;
for(i=1;i<5;i++)
printf(" %d ",i);
}

  1. 1 2 3 4 5

  2. 1 2 3 4

  3. 1 2 3 4 5 6

  4. 0 1 2 3 4 5

  5. None of the above


Correct Option: B
Explanation:

Due to this relational operator '<' for loop work till i=4.

Find the value of C.
C = (a>0 && a<1)? a : b given a =10 , b = 20

  1. 10

  2. 20

  3. C will take garbage value

  4. 0 or 1

  5. None of these


Correct Option: B
Explanation:

 (a>0 && a<1)? a : b  (10>0 && 10 <1)? a :b(10>0 && 10 <1)  generate false value and b is executed.    

Which of the following is/are correct statements for classes and objects in C++ language?

  1. Static keyword is used to preserve the value of a variable.

  2. Member functions of a class can also be declared as constants.

  3. The local class has no access permission to global variables as well as static variables.

  4. Both 1 and 3

  5. Both 1 and 2


Correct Option: E
Explanation:

Both 1 and 2 are true. So, this is the correct option.

Find the output of the following expression.
#include<stdio.h>
#iinclude<conio.h>
void main()
{
int x=5 , y;
y = ++x;
printf(%d , y);
}

  1. 6

  2. 5

  3. 7

  4. Wrong expression

  5. None of these


Correct Option: A
Explanation:

Increment operator works here, as per the prefix first value is incremented by one then stored in left hand side variable, i.e.,  x will become x+1 due to increment operator. y=x+1:y= 6.

In how many categories can the data types of C be classified?

  1. 5

  2. 4

  3. 3

  4. 2

  5. None of the above


Correct Option: C
Explanation:

C data types can be classified in following categories:-

1) Derived data types (pointer, function etc)
2) Basic data types ( float, int etc)
3) User defined data types ( structure, union, enum etc
So, this answer is correct.

Which of the following given standard functions accepts two arguments while calling?

  1. strspn();

  2. strnset();

  3. strnsetu();

  4. strdup();

  5. strncpyk();


Correct Option: A
Explanation:

This option is true because this function takes two arguments, and it returns the position of the string from where the source array doesn’t match with the target one. Format of this function is :-Strspn( string 1, string 2). For example, suppose we enter first string as “good morning” and second string as “good luck”. So, the function will return 5 because after 5 characters there is no match found in the strings. So, this is correct.

Which of the following is/are the valid rules for declaring a virtual function in C++?

  1. A virtual function must not be static.

  2. Destructor cannot be declared as virtual, but constructor can be declared as virtual.

  3. A virtual function may be declared as a friend for another class.

  4. Both 1 and 2

  5. Both 1 and 3


Correct Option: E
Explanation:

Options 1 and 3 are correct. Option 2 is not correct because destructor can be declared as virtual, but constructor cannot be declared as virtual.

How many valid categories of character sets are there in C language?

  1. 5

  2. 4

  3. 3

  4. 2

  5. None of these


Correct Option: B
Explanation:

C character set has four categories which are:-
1) Letters (capital A to Z and small a to z)
2) Digits (decimal digits 0-9)
3) White spaces (back space, new line etc)
4) Special characters (comma, colon etc)

Find out the output of the following program or error (if any).

#include<stdio.h>
#include<conio.h>
int main()
{
 const int num=12;
 ++num;
 printf("num=%d",num);
 getch();
}

  1. Num=12

  2. Num=13

  3. Garbage value

  4. Error in the program

  5. Blank screen (no output)


Correct Option: D
Explanation:

There is an error in the program. We have declared the num variable as constant by const keyword. So, in this program we cannot modify its value. The compiler will give an error that “ cannot modify the constant object” or “[error] increment of read only variable num”. So, this option is true.

Which of the following arithmetic operations is/are not possible in C language?

  1. Addition of two addresses

  2. Multiplication of two addresses

  3. Multiplication of an address with a constant

  4. Divison of an address with a constant

  5. All of the above


Correct Option: E
Explanation:

The reasons given in all of the options are correct. So, this option (All of the above) is the correct answer.

Find out the output of the given program or error (if any).

#include<stdio.h>

#include<conio.h>

int main()
{
 unsigned u=65535;
 printf("u=%d",u);
 getch();
}

  1. u=1

  2. u=2

  3. u=65535

  4. error in the program

  5. None of these


Correct Option: C
Explanation:

This is the correct answer. Unsigned integer has a maximum value range 0-65535. So, this is the maximum value. So, u=65535 will be printed. After reaching the last range compiler will start from beginning like for 65636, output will be 1, and for 65537, output will be 2. So, this option is true.

Which of the following is/are the standard header files in ANSII C?

  1. <assert.h>

  2. <complex.h>

  3. <limits.h>

  4. Both 1 and 3

  5. All 1, 2 and 3


Correct Option: E
Explanation:

All the header files are valid. So, this is a correct option.

What is the ASCII value of ESC character?

 #include<stdio.h>

#include<conio.h>

using namespace std;

class first

{

      int b;

      public:

             first()

             {

                    b=10;

                    }

                    void display()

                    {

                         cout<<\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n b=<

                         }

                         };

                         class second

                         {

                               int d;

                               public:

                                      second()

                                      { d=20;

                                      }

                                      void display()

                                      {

                                            cout<<\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n d=<

                                            }

                                            };

                                            int main()

                                            {

                                                first f,*p;

                                                second s,*i;

                                                p=&f;

                                                p->display();

                                                i=&s;

                                                p->display();

                                                getch();

                                                }

  1. 27

  2. 28

  3. 29

  4. 30

  5. None of these


Correct Option: A
Explanation:

This value is correct answer for the question. The ASCII value of ESC character is 27. This is a standard value known as AMERICAN STANDARD CODE FOR INFORMATION INTERCHANGE. This can be seen in any C language book. <strong> <!-- @page { margin: 0.79in } P { margin-bottom: 0.08in } --> </strong>

+ View questions