Sunday, July 27, 2014

C Programming

1. 
How many times "IndiaBIX" is get printed?
#include<stdio.h>
int main()
{
    int x;
    for(x=-1; x<=10; x++)
    {
        if(x < 5)
            continue;
        else
            break;
        printf("IndiaBIX");
    }
    return 0;
}
A.Infinite timesB.11 times
C.0 timesD.10 times
2. 
How many times the while loop will get executed if a short int is 2 byte wide?
#include<stdio.h>
int main()
{
    int j=1;
    while(j <= 255)
    {
        printf("%c %d\n", j, j);
        j++;
    }
    return 0;
}
A.Infinite timesB.255 times
C.256 timesD.254 times
3. 
Which of the following is not logical operator?
A.&B.&&
C.||D.!
4. 
In mathematics and computer programming, which is the correct order of mathematical operators ?
A.Addition, Subtraction, Multiplication, Division
B.Division, Multiplication, Addition, Subtraction
C.Multiplication, Addition, Division, Subtraction
D.Addition, Division, Modulus, Subtraction
5. 
Which of the following cannot be checked in a switch-case statement?
A.CharacterB.Integer
C.FloatD.enum

6.What will be the output of the program?
#include<stdio.h>
int main()
{
    int i=0;
    for(; i<=5; i++);
        printf("%d", i);
    return 0;
}
A.0, 1, 2, 3, 4, 5B.5
C.1, 2, 3, 4D.6
7. 
What will be the output of the program?
#include<stdio.h>
int main()
{
    char str[]="C-program";
    int a = 5;
    printf(a >10?"Ps\n":"%s\n", str);
    return 0;
}
A.C-programB.Ps
C.ErrorD.None of above
8. 
What will be the output of the program?
#include<stdio.h>
int main()
{
    int a = 500, b = 100, c;
    if(!a >= 400)
        b = 300;
    c = 200;
    printf("b = %d c = %d\n", b, c);
    return 0;
}
A.b = 300 c = 200B.b = 100 c = garbage
C.b = 300 c = garbageD.b = 100 c = 200
9. 
What will be the output of the program?
#include<stdio.h>
int main()
{
    unsigned int i = 65535; /* Assume 2 byte integer*/
    while(i++ != 0)
        printf("%d",++i);
    printf("\n");
    return 0;
}
A.Infinite loop
B.0 1 2 ... 65535
C.0 1 2 ... 32767 - 32766 -32765 -1 0
D.No output
10. 
What will be the output of the program?
#include<stdio.h>
int main()
{
    int x = 3;
    float y = 3.0;
    if(x == y)
        printf("x and y are equal");
    else
        printf("x and y are not equal");
    return 0;
}
A.x and y are equalB.x and y are not equal
C.UnpredictableD.No output

No comments: