Thursday, December 7, 2017

RGAN TT sample test questions 08-12-2017

(1)What will be output of the following program?
#include<stdio.h>
int main(){
    float a=0.7;
    if(a<0.7){
         printf("C");
    }
    else{
         printf("C++");
    }
    return 0;
}
A)    C     B)C++    C)ERROR   D)NONE
(2)What will be output of the following program?
   
#include<stdio.h>
int main(){
    int I=5,j;
    j=++I + ++I + ++I;
    printf("%d ",j);
    return 0;
}
A)18   B)21   C)24    D)15
(3)What will be output of the following program?
#include<stdio.h>
int main()
{
    int i=1;
    i=2+2*i++;
    printf("%d",i);
    return 0;
}

A)4    B) 5      C)6    D)NONE
(4)What will be output of the following program?
#include<stdio.h>
int main(){
    int a=2,b=7,c=10;
    c=a==b;
    printf("%d",c);
    return 0;
}
A)1   B)0   C)10   D)2
(5)What will be output of the following program?
#include<stdio.h>
void main(){
    int x;
    x=10,20,30;
    printf("%d",x);
    return 0;}
A)10  B)20   C)30  D)60
(6)What will be output of the following program?
#include<stdio.h>
int main(){
    int a=0,b=10;
    if(a=0){
         printf("true");
    }
    else{
         printf("false");
    }
    return 0;
}
A)    true   B) false   C) syntax error   D)none
(7)What will be output of the following program?
#include<stdio.h>
int main(){
    int a;
    a=015 + 0x71 +5;
    printf("%d",a);
    return 0;
}
    A) 91   B)131    C)Syntax error  D)20 
 (8)What will be output of the following program?
#include<stdio.h>
int main(){
    printf("%d %d %d", sizeof(3.14),sizeof(3.14f),sizeof(3.14L));
    return 0;
}
A) 8  4  10   B)4  4  4   C) 8  8  4   D)4  4  10
(9)What will be output of the following program?
#include<stdio.h>
int main(){
    int x=100,y=20,z=5;
    printf("%d %d %d");
    return 0;
}
A)100 20  5 B)5  20  100  C) error  D)20 100  5
(10)What will be output of the following program?
#include<stdio.h>       
int main(){
    int a=2;
    a=a++ + ~++a;
    printf("%d",a);
    return 0;
}
A) 0   B)  1  C)-1   D) 2

(11)What will be output of the following program?

#include<stdio.h>
int main(){
    int a;
    a=sizeof(!5.6);
    printf("%d",a);
    return 0;
}
A) 2    B)4   C)8   D)10
12) What will be output when you will execute following c code?
#include<stdio.h>
void main(){
     int movie=1;
     switch(movie<<2+movie){
        default:printf("3 Idiots");
        case 4: printf(" Ghajini");
        case 5: printf(" Krrish");
        case 8: printf(" Race");
     }
}


A)3 Idiots Ghajini Krrish Race    
B) Race

C) Krrish     D) Ghajini Krrish Race
(13)What will be output of the following program?

#include<stdio.h>
int main(){
     int i=7;
     int j=++i + i++ + ++i;
     printf("%d",j);
     return 0;
}
A)  27  B)28   C)21  D)24
(14)    By default a real number is treated as a
    A.
Float       B.double  
C.
long double    D.far double  

  15 What will be output of the following program?
int main(){     
char f=255;
             f++;
    printf("%d",sizeof(f));
return 0;
}
 (a)1 (b)2  (c)4  (d)Compiler error

16. What will be output of the following program?
#define value 10\2
int main(){
printf("%d",value);
return 0;
}
(a)5  (b)20  (c)102 (d)Compiler error
(17) What will be output of the following program?
#define max 5
#define a max*max
#define value a\a
int main(){
    const int aa=5;
    printf("%d",value+aa);
return 0;
}

(a)5 (b)6  (c)10 (d)Compiler error
18. What will be output of the following program?
#include<stdio.h>
int main(){
    int a=2,b=7,c;
    c=a==b==0;
    printf("%d",c);
    return 0;
}
}
A)    0  B)  1   C) error   D) none
19.     Which of the following are unary operators in C?
1.    !
2.    sizeof
3.    ~
4.    &&

A.1, 2        B.1,3      
C.2, 4        D.1,2,3      

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

A.&& operator    B.& operator
C.|| operator    D.! operator

/*  * C Program to Check if a given Bit Position is set to One or not */
#include <stdio.h>
void main()
{
    unsigned int number;
    int result, position;
     printf("Enter the unsigned integer:\n");
    scanf("%d", &number);
    printf("enter position to be searched\n");
    scanf("%d", &position);
    result = (number >> (position));
    if (result & 1)
        printf("TRUE\n");
    else
        printf("FALSE\n");  
}





No comments:

Post a Comment