Walk In Drive : Bengalore , Hyderabad , Delhi , Chennai , Mumbai , Kolkata ->Books : Let Us C (Yashavant P.Kanetkar) , Quantitative Aptittude(RS Agrawal) , Verbal Reasoning(RS Agrawal) , SQL

C Programming Question Paper


                                             C Programming Question Paper


1.
What will be the output of the program ?
#include<stdio.h>
void swap(char *, char *);

int main()
{
    char *pstr[2] = {"Hello", "InterviewShala"};
    swap(pstr[0], pstr[1]);
    printf("%s\n%s", pstr[0], pstr[1]);
    return 0;
}
void swap(char *t1, char *t2)
{
    char *t;
    t=t1;
    t1=t2;
    t2=t;
}

A.
InterviewShala
Hello

B.
Address of "Hello" and "InterviewShala"

C.
Hello
InterviewShala

D.
Iello
Interviewshala
2.
 What will be the output of the program ?
#include<stdio.h>

int main()
{
    printf("Interview", "Shala\n");
    return 0;
}

A.
Error

B.Interview Shala

C.Interview

D.Shala
3. 
Which bitwise operator is suitable for checking whether a particular bit is on or off?

A.
&& operator

B.
& operator

C.
|| operator

D.
! operator
4.
What will be the output of the program?
#include<stdio.h>
int main()
{
    int i=4;
    switch(i)
    {
        default:
           printf("This is default\n");
        case 1:
           printf("This is case 1\n");
           break;
        case 2:
           printf("This is case 2\n");
           break;
        case 3:
           printf("This is case 3\n");
    }
    return 0;
}

A.
This is default
This is case 1

B.
This is case 3
This is default

C.
This is case 1
This is case 3

D.
This is default
5.
Which of the following statements correctly assigns 12 to month using pointer variable pdt?
#include<stdio.h>

    struct date
    {
        int day;
        int month;
        int year;
    };
int main()
{
    struct date d;
    struct date *pdt;
    pdt = &d;
    return 0;
}

A.
pdt.month = 12

B.
&pdt.month = 12

C.
d.month = 12

D.
pdt->month = 12
6.
What will be the output of the program?
#include<stdio.h>

int main()
{
    char huge *near *far *ptr1;
    char near *far *huge *ptr2;
    char far *huge *near *ptr3;
    printf("%d, %d, %d\n", sizeof(**ptr1), sizeof(ptr2), sizeof(*ptr3));
    return 0;
}

A.
4, 4, 4

B.
2, 2, 2

C.
2, 8, 4

D.
2, 4, 8
7.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    enum status {pass, fail, absent};
    enum status stud1, stud2, stud3;
    stud1 = pass;
    stud2 = absent;
    stud3 = fail;
    printf("%d %d %d\n", stud1, stud2, stud3);
    return 0;
}

A.
0, 1, 2

B.
1, 2, 3

C.
0, 2, 1

D.
1, 3, 2
8.
What will be the output of the program?
#include<stdio.h>

int main()
{
    const int x=5;
    const int *ptrx;
    ptrx = &x;
    *ptrx = 10;
    printf("%d\n", x);
    return 0;
}

A.
5

B.
10

C.
Error

D.
Garbage value
9.
Point out the error in the program?
struct emp
{
    int ecode;
    struct emp e;
};

A.
Error: in structure declaration

B.
Linker Error

C.
No Error

D.
None of above
10.
Point out the error in the program?
#include<stdio.h>

int main()
{
    struct emp
    {
        char name[25];
        int age;
        float bs;
    };
    struct emp e;
    e.name = "Suresh";
    e.age = 25;
    printf("%s %d\n", e.name, e.age);
    return 0;
}

A.
Error: Lvalue required/incompatible types in assignment

B.
Error: invalid constant expression

C.
Error: Rvalue required

D.
No error, Output: Suresh 25
11.
Which of the following sentences are correct about a switch loop in a C program?
1:switch is useful when we wish to check the value of variable against a particular set of values.
2:switch is useful when we wish to check whether a value falls in different ranges.
3:Compiler implements a jump table for cases used in switch.
4:It is not necessary to use a break in every switch statement.

A.
1,2

B.
1,3,4

C.
2,4

D.
2
12.
In the following code, the P2 is Integer Pointer or Integer?
typedef int *ptr;
ptr p1, p2;

A.
Integer

B.
Integer pointer

C.
Error in declaration

D.
None of above
13.
A char variable can store either an ASCII character or a Unicode character.

A.
True

B.
False
14.
What will be the output of the program ?
#include<stdio.h>
char *str = "char *str = %c%s%c; main(){ printf(str, 34, str, 34);}";

int main()
{
    printf(str, 34, str, 34);
    return 0;
}

A.
char *str = "char *str = %c%s%c; main(){ printf(str, 34, str, 34);}"; main(){ printf(str, 34, str, 34);}

B.
char *str = %c%s%c; main(){ printf(str, 34, str, 34);}

C.
No output

D.
Error in program

16.
It is necessary that for the string functions to work safely the strings must be terminated with '\0'.

A.
True

B.
False

18.
Functions cannot return a floating point number
A.
Yes
B.
No
19.
Bitwise | can be used to set a bit in number.
A.
Yes
B.
No
20.
Bitwise can be used to generate a random number.
A.
Yes
B.
No

No comments:

Post a Comment