Friday, November 13, 2009

HCL Question Paper

1) Given the following statement
enum day = { jan = 1 ,feb=4, april, may}
What is the value of may?

2) Find the output for the following C program

main( )
{
int x, j, k;
j=k=6; x=2;
x=j*k;
printf("%d", x);
}

3) main( )
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}

4) Find the output for the following C program
main( )
{
intx=20,y=35;
x = y++ + x++;
y = ++y + ++x;
printf("%d %d\n", x,y);
}

5) Find the output for the following C program
main( )
{
int x=5;
printf("%d %d %d\n",x, x<<2,x>>2);
}

6)  Find the output for the following C program

#define  swap1(a,b)  a=a+b;b=a-b;a=a-b;
main( )
{
int x=5,y=10;
swap1(x,y);
printf("%d %d\n",x,y);
swap2(x,y);
printf("%d %d\n",x,y);
}
//------------------------------
int swap2(int a,int b)
{
int temp;
temp=a;
b=a;
a=temp;
return;
}

7) Find the output for the following C program

main()
{
char *ptr = "Ramco Systems";
(*ptr)++;
printf("%s\n",ptr);
ptr++;
printf("%s\n",ptr);
}

8) Find the output for the following C program

#include< stdio.h>
main()
{
char s1[]="Ramco";
char s2[]="Systems";
s1=s2;
printf("%s",s1);
}

9) Find the output for the following C program

#include< stdio.h>
main()
{
char *p1;
char *p2;
p1=(char *) malloc(25);
p2=(char *) malloc(25);
strcpy(p1,"Ramco");
strcpy(p2,"Systems");
strcat(p1,p2);
printf("%s",p1);
}

10) The following variable is available in file1.c

static int average_float;

11) Find the output for the following C program

 # define TRUE 0
some code
while(TRUE)
{
some code
}

12) Find the output for the following C program

main( )
{
int x=10,y=15;
x=x++;
y=++y;
printf("%d %d\n" ,x ,y );
}

13) Find the output for the following C program

main( )
{
int a=0;
if(a=0) printf("Ramco Systems\n");
printf("Ramco Systems\n");
}

14) Display the Output
main( )
{
int x=2;
if(!x)
printf("Hello");
else
printf("Welcome");
}

15) Find the output for the below program
main( )
{
int x=10;
if(x==10);
printf("C programing");
printf("C tutor");
}

Tuesday, November 10, 2009

Examination questions on C introduction paper-2


1.  What is the error message/output in the following program?
                void main( )
                {
                clrscr( )
                    printf(“Welcome”);

a)   I don’t know
b)  Semicolon missing 
c)  Welcome
d)  Statement missing

2. Check the below program
main( )
                {
                     printf(“%d”,a/0));
                }
a)       Division by Zero (Warning)
b)       Undefined Symbol ‘a’ (Error)
c)       0 (Output)
d)       None of the above

3. Input function in ‘C’
a)       printf() & scanf( )                  
b)  scanf( ) & stdio.h                            
c)  scanf( )              
d)  All the Above

4. Display the output
                main( )
                {
                printf(“Welcoem to ‘C’ language”);
                }
a)       Welcome to ‘C’ language
b)       Welcome to “C” language
c)       Welcoem to ‘C’ language
d)       Welcoem to ‘C’ language.

5. “stdio.h” and “conio.h” are often called as
a)    Pre-defined functions          
 b)  Library functions             
c)  Library files      
d)  Only C compiler knows 


6. Which of the following is used to clear the output screen?
a)   clearscr()           
b) clearscreen()             
c) clrscr()           
d) clrscreen()

7. Division by 0 gives
a)  Compiler error   
b) Runtime error          
c) Assembler error     
d)None of the Above

8. Which of the following denote special operators in C?
a)      ?:                       
b)  ,                               
c)  >                              
d)  None of the Above

9. Which of the following denote invalid character constants in C?
a)      's'          
b). '$'                 
c). 'E'                
d). 'wer'

10. The long integer is denoted as
a)      l                        
b)  ld                  
c)  Any of A or B                       
d) None of the Above

11. Relational operator in C compares two
a)   Operands           
b) operators       
c). Both A and B            
d). None of the Above

12. Which of the following functions can be used to enter an integer in C program?
a)    getche               
b). gets              
c). scanf            
d). None of the Above

13. What is the Boolean value of a false statement resulting in a C program?
a)     1                       
b)  0                 
 c)  -1                 
d)  None of the Above

14. What is the output of the following program?
main()
{
     int a=10,b=25;
     a=b++ + a++;
     b= ++b + ++a;
     printf(“%d%dn”,a,b);
}
a)    35 65                 
b)  36 64                        
c)  37 64                        
d)  34 64

15. What is the output of the following program?
main()
{
     char t1[]=“Exforsys”;
     char t2[]= “Training”;
     printf(“%s”,t1);
}
a)     E                     
b)  Exforsys                   
c). NULL                      
d). Exforsys Training

16. The modifier used for horizontal tab is
a)  h           
b) ht                 
c) t                   
d) th

17. What is the output of the statement?
printf("Exforsys Training \nis \n Very Good");

a)      Exforsys
            Training
             is Very Good
b)      Exforsys Training
             is Very Good
c)      Exforsys Training is Very Good
d)      Exforsys Training
             is
            Very Good
  
18. The code used for denoting unsigned decimal integer in scanf is
a)      %d                    
b)  %u                           
c)  %ud                                     
d)  None of the Above

19. Which takes the first precedence in evaluation among the following operators?
a)    ||                        
b)  !                               
c)  &&            
d)  All the Above has equal precedence

20. The unsigned char have maximum value of
a)     128                    
b)  300                           
c)  255               
d)  240




Online and Offline examination questions on C introduction paper-1

1. Is C Language High Level Language or Low level Language
a)High Level
b)Low Level
c)Middle Level
d)None of the above

2. Who invented the C Language
a)Dennis Ritchie
b)Brian Kernighan and Dennis Ritchie
c)Ken Thompson
d)Martin Richards

3.Each C statement gets terminated with the notation
a)None of the Above
b) ;
c) %
d) $

4.Which of the following denote primary data types in C program?
a)int
b) char
c) float
d) All the Above

5. The operation between float and int would give the result as
a)float
b)int
c)unsigned int
d)None of the Above

6. What is the output of the following C program?
main()
{
int a=10;
int b;
b=a++ + 20;
printf("a=%d b=%d",a,b);
}
a) None of the Above
b) a=11 b=30
c) a=10 b=30
d) a=11 b=31

7. Which of the following denote library functions in C?
a) scanf
b) printf
c) Both A and B
d)None of the Above

8. The left shift operator in C program is denoted by
a) << b) >>
c) < d). None of the Above 9. The conditional operator in C program is denoted by a) >:
b) ?:
c) ?
d) None of the Above

10. What is the output of the following program?
main()
{
int exf=25;
int test;
test=++exf++;
printf("exf=%d test=%d", exf, test);
}
a) exf=26 test=25
b) exf=27 test=26
c) Gives Error
d) exf=26 test=26

11. Which of the following reads a single character but does not display the character on screen?
a)getche
b)getch
c)Both A and B
d)None of the Above

12. Which of the following is not a BITWISE operator in C program?
a) None of the Above
b) ^
c) &
d) &&

13. What is the output of the following program?
main()
{
printf("%d",-5/-4);
}

a) 1
b) -1
c) -1.25
d) 1.25

14. The notation for preprocessor directive is
a) $
b) !
c) @
d) #

15. Which of the following denote preprocessor directives?
a) if else
b) malloc
c) static
d) #define

16. Which of the following denote invalid variable names in C?
a) exforsys
b) float
c) abcd
d) None of the Above

17. Which of the following denotes a new line character in C program?
a) n
b) /n
c) t
d) /t

18. Which of the following data type occupied 1 byte?
a) long double
b) char
c) float
d) double

19. Which of the following operating system was developed from ‘C’ ?
a)Windows
b)DOS
c)UNIX
d)None of the Above

20. Which of the following areas is C language used?
a)Operating Systems
b)Text Editors
c)Utilities
d)All the Above