Search here

Custom Search

Follow by Email

5/28/2012

Part 6: FRP Dumps | C Puzzle | C++ Puzzle | DataStructure Puzzle



PART 1          PART 2          PART 3           PART 4            PART 5            PART 6            PART 7



 Part 6:-

5. void main()
{
char a[]="123abcd";
clrscr();
printf("%d",strlen(a));
getch();
}

a.    6
b.     7
c.      8
d.      5
Ans::7


6. main()
{
static int var=5;
if(var--)
{
printf("%d",var);
main();
}
}

a. 4 3 2 1 0  
b. 4 3 2 1
c. 5 4 3 2 1
d. 5 4 3 2 1 0
ans::a
7. void main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("One"); break;
case j: printf("Two");  break;
default: printf(“Default”); break;
}
}
a. One
b. Two
c. Default
d. Compiler Error
ans::d
8. void main()
{
switch('a')
{
case 'A': printf("Zero");    break;
case 97: printf("One");      break;
default: printf("Error");     break;
}
}

a. Zero
b. One
c. Error
d. Compiler Error
ans::b
9. void main()
{
int p=1,sum=0;
clrscr();
while(p<20)
{
p++;
sum+=p++;
}
printf("\nsum=%d",sum);
}

a. 120
b. 100
c. 110
d. Error
ans::c
10. int x;
int modifyvalue()
{
return(x+=10);
}

int changevalue(int x)
{
return(x+=1);
}

void main()
{
int x=10;
x++;
changevalue(x);
x++;
modifyvalue();
printf("First output : %d",x);
changevalue(x);
printf("\nSecond output : %d",x);
}

a. 12 12
b. 11 12
c. 12 13
d. 13 13

11. main()
{
static i=3;
printf("%d",i--);
return i>0?main():0;
}

a. 3 2 1 0
b. 3 2 1
c. 2 1 0
d. 2 1

12. void main()
{
char *ptr="Hello World";
*ptr++;
printf("%s",ptr);
ptr++;
printf("%s",ptr);
}

a. Iello World     Iello World
b. Hello World    ello World
c. ello World       ello World
d. ello World       llo World

13. int const *p;
*p=5;
printf("%d",*p++);

a. 5
b. 6
c. Compiler Error
d. Garbage Value
ans::c
14. void main()
{
char *str1="abcd";
char str2[]="abcd";
printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("ab"));
}

a. 5  5  3
b. 4 5  3
c. 2 5  3
d. 1 5  3
ans::c
15. P is a character pointer variable then, what will be the output of the following statement.
printf("%d %d",sizeof(p),sizeof(*p));

a. 1   2
b. 2  1
c. 2  2
d. 1  1
ans::b
16. void main()
{
char *s[]={"dharma","hewlet-packard","siemens","ibm"};
char **p;
p=s;
printf("%s",++*p);
printf("\n%s",*p++);
printf("\n%s",++*p);
}

a. harma
   harma
   ewlet-packard
b. dharma
    harma
    ewlet-packard
c. harma
    hewlet-packard
    siemens
d. harma
    harma
    hewlet-packard
ans::a
17. void main()
{
char *ptr="Ramco Systems";
 (*ptr)++;
printf("%s\n",ptr);
ptr++;
printf("%s",ptr);
}

a. Samco Systems   Samco Systems
b. Samco Systems   amco Systems
c. amco Systems     amco Systems
d. amco Systems     mco Systems
ans::b
18. #define square(x) x*x
void main()
{
int i=7;
clrscr();
i=64/square(4);
printf("%d",i);
}

a. 7
b. 16
c. 64
d. 4
ans::c
19. #define man(x,y) (x)>(y)?(printf("%d",x)):(y)

void main()
{
int i=15,j=10,k=0;
k=man(i++,++j);
printf(" %d %d %d",i,j,k);
}

a. 16  17  11  2
b. 17  17  11  2
c. 16  16  11  2
d. 16  17  12  2
ans::a
20. struct one
{
int no:1;
int pl:2;
int x:3;
};

void main()
{
struct one a;
a.no=0;
a.pl=1;
a.x=3;
printf("%d %u",a.no,a.no);
printf("\n%d %u",a.pl,a.pl);
printf("\n%d %u",a.x,a.x);
}

a. 0  0
   1  1
   3  3
b. 0  0
    2  2
    3  3
c. 1  1
    2  2
    3  3
d. 1  1
    2  2
    2  2
Ans:a
21. void main()
{
 struct emp
 {
   struct e
   {
     int *a;
   }e1;
   int a;
 };

struct emp emp1;
printf("%d  %d",sizeof(emp1),sizeof(emp1.e1));
}

a. 2  4
b. 2  2
c. 4  4
d. 4  2
ans::d
22. struct emp emp1;
struct emp
 {
   int a;
 };
main()
{
printf("Enter 1 values:");
scanf("%d%d",&emp1.a,&emp1.a);
//The given input is 10 and 25
printf("a=%d  a=%d",emp1.a,emp1.a);
}

a. 10  25
b. 25  25
c. 10  10
d. Compiler Error
ans::b
23. Arrange the code in order to delete a node being pointer by temp.

            a)         free(temp)
            b)         temp->prev->next = temp->next
            c)         temp->next->prev = temp->prev;


            a) b c a   
            b) c b a
            c) a b c
            d) both a and b
ans::d
24. What does below code do, if temp is pointing to a node other than first and last node
           
            temp -> prev ->next = temp ->next;
            temp ->next -> prev = temp -> prev;

            a)         no effect
            b)         inserts a node
            c)         deletes a node
            d)         shuffling of pointers
ans::c
25. which  is the  faster traversable  dynamically growing list


            a)  Binary Search Tree      b)  Singly Linked List                  
            c)  Doubly Linked List   d)  Using Array

ans::c

1. void main()
{
   int a=1,b=2,c=3;
   c=(--a, b++)-c;
   printf("%d %d %d",a,b,c);
}
(a)0 3 -3                       (b)Compile-Time Error                        (c)0 3 -1                       (d)0 3 0
Ans::3
2.
#define swap(a,b) temp=a; a=b; b=temp;
void main()
{
   static int a=5,b=6,temp;
   if (a > b)
      swap(a,b);
   printf("a=%d b=%d",a,b);
}
(a)a=5 b=6                   (b)a=6 b=5                              (c)a=6 b=0                   (d)None of these
Ans::c
3.
void main()
{
  int i=5;
  printf("%d %d %d %d %d",++i,i++,i++,i++,++i);
}
(a)Compile-Time Error            (b)10 9 8 7 6                            (c)9 8 7 6 6                  (d)10 8 7 6 6
Ans:d
4.
void main()
{
  int i, n =10;
  for (i=1; i<n--; i+=2)
     printf("%d", n-i);
}
(a)84                            (b)840                                      (c)852                          (d)864
Ans:c
5.
What is the output of the program?
    #include <stdio.h>

    int main(int argc, char *argv[])
    {
        printf(" %d", printf("Hello Genesis"));
        return 0;
    }
  1. Hello Genesis
  2. 13 Hello Genesis
  3. Hello Genesis 13
  4. None of the above
6.
  #include <stdio.h>
   
    main()
    {
        switch (5)
        {
            case 5: printf(" 5 ");
            default: printf(" 10 ");
            case 6: printf(" 6 ");
        }
    }
  1. 5
  2. 5 10 6
  3. 5 10
  4. 5 6
Ans::b
7.
Which argument of function 'strncmp()' specifies number of characters to be compared?
  1. first
  2. second
  3. between 2 strings
  4. third
ans::d
8.
Which of the following is not a storage class in C?
  1. Stack
  2. Register
  3. Extern
  4. Static
Ans::a
9.
What is the significance of the free() function?
  1. It assigns the pointer a NULL value
  2. It erases the contents of any type and cleans the pointer
  3. It places the memory address with the pointer in free store
  4. It disables the memory address with the pointer
Ans::a
10.
What is the data type of FILE?
  1. integer
  2. union
  3. pointer
  4. structure
ans::d
11.
#include <stdio.h>
    #define sq(a) a * a      

    void main()    
    {
        printf("%d", sq(3 + 2));
    }        
  1. 25
  2. 11
  3. 10
  4. Compilation error 
Ans::b
12.
Which of the following is a non-linear data structure?
  1. Stack
  2. Queue
  3. Linked List
  4. Tree
Ans::d
13.
Which of the following function does not return an integer value?
  1. printf
  2. scanf
  3. strcpy
  4. strlen
ans:c
14.
Which of the following function does not support dynamic memory allocation?
  1. alloc
  2. realloc
  3. malloc
  4. free
ans::a
15.
What is the output of the program if the input is 103?

    main()
    {
        int p = 234;
        printf(" %d ", printf("%d", p), scanf("%d", &p));
    }
  1. 3 103
  2. 103
  3. 103 3
  4. 103 2
Ans::c
16.
Where do we use a 'continue' statement?
  1. In 'if' statement
  2. In 'switch' statement 
  3. In 'goto' labels 
  4. None of the above
Ans::d
17.
  1. Queue is  _________________

a)      LIFO
b)      LILO
c)      FIFO
d)     Both b & c
Ans::d
18.
What is the postfix expression for A + B * C / D – E * F / G
a)      ABC*D/+EFG*/-
b)      ABC*D/+EF*G/-
c)      ABCD/*+EF*G/-
d)     None of these.
Ans::b
19.
Write one statement equivalent to the following two statements:   x=sqr(a);  return(x);
 Choose from one of the alternatives
      (a) return(sqr(a));                                   
      (b) printf("sqr(a)");
      (c) return(a*a);                                   
      (d) printf("%d",sqr(a));
Ans::b
 20.
int i=5;

int abc(int z)
{
      return i/2;
}
main()
{
       int i=4;
       printf("%d",abc(i=i/4));
}

a)  error
b)  5
c)  2
d)  0
ans::c
21.
union U
{
int  x;
float y;
char s[2];
};
union U ob;

what is the size of ob in bytes,

a)  4
b)  2
c)  8
d)  7
ans::a
22.
The operation for adding  and deleting an entry to a stack is traditionally called:
a.add , delete
b.append , delete
c.insert , delete
d.push , pop
e. front , rear
ans::d
23.
What is the Infix expression for    - + A / * B C D / * E F G
a)      A + B * C / D – E / F * G
b)      A + B / C * D – E * F / G
c)      A + B * C / D – E * F / G
d)     A - B * C / D + E * F / G
Ans:c
24.
What would be the root node if we enter the following data set (in the respective order) into a standard program to construct a Binary search tree?

25, 72, 16, 11, 88, 26, 9, 36, 21, 45, 14, 69
a)  69
b)  25
c)  26
d) 9
Ans::b

25.

what does the code below do, where head is pointing to first node & temp is a temporary pointer. 10 be the number of nodes
           
            temp = head;
            while (temp->next->next!=NULL)
            {
                        temp = temp ->next;
            }
            temp -> prev -> next = temp -> next;
            temp -> next -> prev = temp -> prev;
            free(temp);

            a)         no effect
            b)         deletes some node
            c)         deletes 2nd last node
            d)         deletes last node

ans::c
1.
What will be the output of the following program :
int main()
{
             int val=5;
      printf("%d %d %d %d",val,--val,++val,val--);
             return(0);
}
(a)3 4 6 5  (b)5 5 6 5  (c)4 4 5 5  (d)None of these                            
Ans::c
2.
#define Compute(x,y,z) (x+y-z)
int main()
{
 int x=2,y=3,z=4;
             printf("%d",Compute(y,z,(-x+y)) * Compute(z,x,(-y+z)));
 return(0);
}
 (a)40 (b)30 (c)Compile-Time Error    (d)None of these                                
Ans::b
3.
What will be the output of the following program :
            int main()
{
 int val=5;
 val=printf("C") + printf("Skills");
             printf("%d",val);
 return(0);
}
(a)7 (b)C7 (c)Compile-Time Error(d)CSkills7           
Ans::d
4.
What will be the output of the following program :
int main()
{
             char str[]="Test";
 if ((printf("%s",str)) == 4)
       printf("Success");
      else
       printf("Failure");
 return(0);
}
a)Success b)TestSuccess c)Compile-Time Error(d)Failure                
ans::b
5.
What will be the output of the following program:
int main()
{
      int val=5;
      printf("%d",5+val++);
      return(0);
}
(a)Compile-Time Error    (b)Lvalue required Error    (c)10   (d)11                                                    
Ans::c
6.
void main()
{
      printf("%d",sizeof(int));
      return(0);
}
 (a)Data types not allowed (b)Compile-Time Error(c)3 (d)2                         
Ans::2
7.
In tree construction which is the suitable efficient data structure?
            (a) Array           (b) Linked list              (c) malloc           (d) Queue  
Ans:b
8.
Traverse the given tree using Inorder, Preorder and Postorder traversals.











a)Inorder :       D H B E A F C I G J
Preorder:         A B D H E C F G I J
Postorder:        H D E B F I J G C A

b)Inorder :       D H B E A F C I G J
Preorder:         D H E A B C F G I J
Postorder:        H D E B F I J G C A

c)Inorder :       D H B E A F C I G J
Preorder:         A B D H E C F G I J
Postorder:        H D E B F I J G A C

d)Inorder :       H D B E A F C I G J
Preorder:         A B D H E C F G I J
Postorder:        H D E B F I J G C A

Ans:a
9.
main()
            {
            static int var = 5;
            printf("%d ",var--);
            if(var)
                        main();
            }

a.       4 3 2 1      b. 4 3 2 1 0    c. 5 4 3 2 1   d. 0 0 0 0 0

Ans:c
10.
#include<stdio.h>
main()
{
struct xx
{
      int x=3;
      char name[]="hello";
 };
struct xx *s;

printf("%d",s->x);
printf("%s",s->name);
}

  1. 3   hello   b.  Compiler Error    c. Run time error   d. use dot (.) operator
Ans::s
11.
#include<stdio.h>
main()
 {
   const int i=4;
   float j;
   j = ++i;
   printf("%d  %f", i,++j);
 }

  1. 5   6.000000     b.  5   5.000000   c.  6   6.000000  d. compiler error
Ans::d
12.
void main()
{
            int k=ret(sizeof(float));
            printf("\n %d",++k);
}
int ret(int ret)
{
            ret += 2.5;
            return(ret);
}
  1. Compiler Error    b. 8       c. 6    d. 7
Ans::d
13.
int swap(int *a,int *b)
{
 *a=*a+*b;*b=*a-*b;*a=*a-*b;
}
main()
{
                        int x=10,y=20;
            swap(&x,&y);
                        printf("x= %d y = %d\n",x,y);
}
  1. 20  10   b.  10  20   c. 20  20   d. 10  10
Ans:a
14.
main()
{
char *p = “ayqm”;
char c;
c = ++*p++;
printf(“%c”,c);
}
  1. a       b. b     c. y    d. z
ans:b
15.
main()
{
                        float i=1.5;
            switch(i)
                        {
                        case 1: printf("1");
                                    case 2: printf("2");
                                    default : printf("0");
            }
}
  1. 0    b.  0  1  2     c. 1  2  0   d. Compiler Error   e. 2  0
Ans:d
16.
#define MESS junk
main()
{
printf(“MESS”);   
}
a.       Junk        b. Error      c.  MESS       d. MESS  junk
Ans:c
17.
main ()
{
            int i = 5;
            switch (i) {
            static int i;
            i = 3;
            i =  i * i;
            case 3:
                        i = i + i;
            case  4:
                        i = i + i;
case  5:
                        i = i + i;
                        printf (“%d”,i);
            }
            printf (“%d”,i);
}
  1. 9     b. 10  10    c.  0   5   d. 18   18   e.  18   5
Ans:c
18.
What would be the output of the following program.
Int fn(int);                    
 main()
                        {
                            int i=10;
                            fn(i);
                            printf("%d",i);
                        }
  fn(int i)
         {
          return ++i;
         }
           (a) 10                           (b) 11                           (c) 12                           (d) Compilation error
Ans:a
19.
main()
{
FILE *fp1,*fp2;
     
      fp1=fopen("one","w");
      fp2=fopen("one","w") ;
      fputc('A',fp1) ;
      fputc('B',fp2) ;
      fclose(fp1) ;
      fclose(fp2) ;
     }

     Find the Error, If Any?
a.       no error. But It will over writes on same file.
b.      no error. But It will create one more file.
c.       error. It will not allow.
d.      no error. The new content will append in existing file.
Ans:a
20.
void main()
            {
          int a=555,*ptr=&a,b=*ptr;
              printf("%d %d %d",++a,--b,*ptr++);
            }
(a)Compile-Time Error            (b)555 554 555                                    (c)556 554 555                        (d)557 554 555
Ans:c
21.
what type of Binary Tree is the following tree below

    1. binary tree
    2. strictly binary tree
    3. complete binary tree
    4. not a binary tree
ans:d
22.
If suppose root to be deleted then which node will be the root node


    1. B
    2. G
    3. Any node
    4. Both a and b are correct
Ans:a
23.
When fopen() fails to open a file it returns
a) NULL   b) –1   c) 1   d) None of the above
ans:a

24.
Which function is used to detect the end of file
a) EOF   b) feof( )   c) ferror( )   d) NULL
ans:b
25.
If the CPU fails to keep the variables in CPU registers, in that case the variables are assumed
 a) static   b) external   c) global   d) auto
ans::d


1.
 #include<stdio.h>

int x=40;
main()
{
            int x = 20;
            printf("\n %d",x);
}

Predict the output
20
40
20, 40
None of the above

2.
#include<stdio.h>
main()
{
            int x=40;
            {
                        int x = 20;
                        printf("\n %d",x);
            }
            printf("%d",x);           
}
Predict the output
20 40
40 20
40
20

3.
#include<stdio.h>
main()
{
            extern int a;
            printf("\n %d",a);       
           
}
int a=20;

Predict the output
20
0
Garbage value
Error

4.
#include<stdio.h>--------------------------------doubt
main()
{
           
            struct emp
            {
                        char name[20];
                        int age;
                        float sal;
            };

            struct emp e={"Raja"};
            printf("\n %d %f", e.age, e.sal);
}

0 0.000000
Garbage values
Error
None of the above

5.
#include<stdio.h>
main()
{
            int x=10, y=20, z=5, i;

            i= x < y < z;

            printf("%d", i);
}

o\p:
1

6. Which of the following definition is correct?

int length
char int
int long
float double
ans::1
7.  What will be the output
#include<stdio.h>

main()
{
            int i=4;
            switch (i)
            {
                        default:
                                    printf("Default Value \n");


                        case 1:
                                    printf("Value is 1 \n");
                                    break;

                        case 2:
                                    printf("Value is 2 \n");
                                    break;

                        case 3:
                                    printf("Value is 3 \n");
                                    break;             
            }
}
o\p:
default value

8.
#include<stdio.h>------------doubt

main()
{
            int i=1;

            while()
            {
                        printf("%d", i++);
           
                        if (i >10)
                        {
                                    break;
                        }
            }
}
Ans::Error
9.
#include<stdio.h>------------------------------doubt
main()
{
            int x=30, y =40;

            if (x==y)
                        printf("X is equal to Y");
            else if (x>y)
                        printf("x is greater than Y");
            else if (x<y)
                        printf("X is less than Y");
}

Ans: X is less than Y






10.
#include<stdio.h>
main()
{
            int i=10, j=15;

            if(i%2= = j%3)
            {
                        printf("Same");
            }
            else
            {
                        printf("Different err");
            }
o\p  same

11.
#include<stdio.h>------------doubt

main()
{
            int x=4, y, z;
            y=--x;
            z= x--;
            printf("%d %d %d", x,y,z);
}

Output:
4 3 3
4 3 2
3 3 2
2 3 3
2 2 3
   Ans::233      
12.
#include<stdio.h>
main()
{
            float a = 0.7;
            if (a<0.7)
            {
                        printf("C");
            }
            else
            {
                        printf("C++");
            }
}
Try with 0.7f   o\p  c++



13.
#include<stdio.h>

main()
{
            float fval=7.29;
            printf("%d" ,fval);
}

o\p 7   

14.
#include<stdio.h>-----------------------doubt

main()
{
            printf("Welcome");
            main();
}  

How many times the program will execute?

Ans:Infinte





15.
#include<stdio.h>----------------------doubt

void fun(char *);


void main()
{
            char a[100];
            a[0] = 'A',    a[1] = 'B';
            a[2] = 'C',    a[3] = 'D';
            fun(&a[0]);
}

void fun(char *a)
{
            a++;
            printf("%c", *a);
            a++;
            printf("%c", *a);
}

  o\p  b c

16.
#include<stdio.h>

#define MESS "Junk"

main()
{
            printf("MESS");
}
o\p    mess

                       

18.
#include<stdio.h>
main()
{
            char str[] = "Sales\0man\0";
            printf("%d", strlen(str));
}
o\p   5

19.
#include<stdio.h>
main()
{
            char str[] = "Sales\0man\0";
            printf("%d", sizeof(str));
}

o\p   11

20
#include<stdio.h>-------------doubt
#include<string.h>

main()
{

            char sentence[80];
            int i;
            printf("Enter the line of text");
            gets(sentence);
            for(i=strlen(sentence)-1;i>=0;i--)
            {
                        putchar(sentence[i]);
            }
}

21
#include<stdio.h>-----------------------doubt

main()
{
            float a=3.15529;
            printf("%6.2f \n",a);
            printf("%6.3f \n",a);
            printf("%5.4f \n",a);
            printf("%2.1f \n",a);
            printf("%0.0f \n",a);
}

1. Which of the following does not have an unary operator?

1) -7                                                     2) ++i
3) j                                                       4) all of the above

2. In printf(),the appearance of the output of the output can be affected by

1) field with                                        2) conversion character
3) flag                                                  4) all of the above

3. Any of the following programs in c has access to three standard files:

1) standard input file, standard output file, standard error file
2) stdin,stdout, stderr
3) keyboard,screen,screen
4) all the above

4. The comma operator(,) is used to

1) permit two different expressions to appear in situations where only one expression would ordinarily be used
2) Terminate loops or to exit from switch
3) alter the normal sequence of program execution by transferring control to some other part of the program
4) carry out a logical test and then take one of two possible actions, depending upon the outcome of the test

5) A variable can be declared static using the keyword.
1) extern                                              2) static
3) stat                                      4) auto

6) A program can be terminated at any time by calling the function

1) fflush()                                            2) ferror()
3) exit()                                               4) clearerr()


7) Heap

1) is a region from where memory is  allocated
2) lies between you program and the stack
3) is a finite area
4) all of the above

8) A function can

1) perform a task                     2) return a value
3) change value of actual arguments in call by reference
4) all of the above


9) Function definition void check(int i ,char*j) is
1) call by value                                    2)call by reference
3) both (1) and (2)                   4)in valid function definition

10) A union consists of a number of elements that

1) all occupy the same space in memory
2) must be structure
3) are grouped next to each other in memory
4) all have the same type


11) Which of the following array is defined in the statements
Char name[30]?

1)      name is one dimensiona,30-element integer array
2)      name is one dimensional,30-element floating point array
3)      name is one dimensional ,30-element character array
4)      name is one dimensional,30-elements string array


12) c program contains the following declaration:
Static float table[2][3]={ {1.1,1.2,1.3},
                                                 {2.1,2.2,2.3}
                                                };

What is the value of *(*(table+1)+1)?

1)      2.2                                    2) 1.2
3)      2.1                                    4) 2.3


13) A c program contains the following declarations and initial
Assignments:

 int i=8,j=5;  float x=0.0005,y=-0.01;
Char c=’c’,d=’d’;
What would be the value of the following expression?

(3*i-2*j)%(2*d-3)
 1)14                                                    2)18
 3) 1                                                     4) 0


14) The declaration : int  f(int 1); means

1) f accepts an integer argument and returns an integer quantity
2) f accepts two arguments and returns a double precision quantity, and the second is an integer
3) f accepts three arguments and returns nothing. The first arguments
is a double-precision quantity, and the second is an integer
4) f does not accepts any arguments but returns a single character

15) The c language was developed by

1) Marting Richards                            2) Dennis Ritchie
3) Ken Thompson                                           4) Smith Volt

16) The arguments  of  a function are included between
1) The parenthesis                               2) double quotes
3) curly braces                                     4) #

17) The int type of constraints are whole numbers in the range

1) -23677 to 23678                                         2) -32768 to 32767
3) -32767 to 32768                                         4) -32864 to 32864

18) If the variables i,j and k are assigned the values 5,3 and 2 respectively, then the expression i=j+(k++ =6)+7;

1) gives an error message                    2) assigns a value 16 to i
3) assigns a value 18 to i                                 4) assigns a value 19 to i

19) In  a relational expression involving characters, we actually
Compare

1)      the ASCII codes of the characters
2)      the characters themselves
3)      neither of the two
4)      binary code and hexadecimal code

20) The getchar function is used to

1) print the ASCII code of the character
2) to assign a character typed at the keyboard to a variable
3) to print a character on the screen
4) all of the above

21) The word case used in the switch statement represents a

1)      function in the c language
2)      data type in the c language
3)      keyword in the c language
4)      global variable in the c language

22)The logical  NOT operator represented by ! is a

1) unary operator                                             2) binary operator
3) ternary operator                              4) octal operator



23) The statement : scanf(“%d”,&i);

1)      assigns an integer to the variable i
2)      gives an error message;
3)      does not assign any value to i
4)      assigns an float to the variable i

24) A pointer is declared by using a statement such as

1) int *p;          2) point;           3) pointer *p;   4) int &p;

25)The null character is represented by

1) \n                             2)\0                  3)\o                              4)\t


26) The members in the union

1) have different memory locations
2) share the memory with a structure
3) have the same memory location
4) have different memory variable

27) The global variables by default belong to

1) the register type                  2) the static type
3) the auto type                                   4) the dynamic type

28) The bit fields are the members of a/an

1) array            2) structure                  3) union           4) inter section

29) In c, square brackets [ ] are used in
1) functions                 2) arrays          3) statements   4) all of the above







30) A fields width specifier in a printf() function

1) specifies the maximum value of a number
2) controls the size of type used to print numbers
3) controls the merging of the program listing
4) specifies how many characters positions will be used for a number

31) The two operators && and || are

1) arithmetic operators                                    2) equality operators
3) logical operators                              4) relational operators

32) The library files that come with c are

1) text editor for program development
2) the compiler and liker
3) program examples
4) files that contain functions which carry out various commonly
Used operations and calculations

33) precedence determines which operator

1) is evaluated first     2) is most important
3) is fastest                              4) operates on the largest number

34) The string containing certain required formatting information
is  called

1) argument                             2) character array       
3) character string                   4) control string

35) The advantage of a “switch” statement over an “else-if” construct is

1) a default condition can be used in the “switch”
2) the switch is easier to understand
3) several different conditions can cause one set of statements to executed in a switch
4) several different statements can be executed for each case in a switch


36) The header file “math.h” can  be used for

1) providing links to assembly-language for calls
2) providing diagnostic and debugging assistance
3) providing support for the string handling functions
4) none of the above


37) The malloc() function

1) returns a pointer to the allocated memory
2) returns a pointer to the first byte of region of memory
3) changes the size of the allocated memory
4) deallocates the memory

38) which of the following expressions will return a 1 if both bits have
A value of 1; otherwise will return a value of 0?

1) AND           2)OR               3)XOR            4)1’stderr complement

39) If an error occurs while opening a file the file pointer
is assigned a value

1) NULL                     2) stdout                      3) sstderr                     4) not defined

40) Which of the following backslash codes used for bell?

1) \b                 2) \a                 3) \r                  4) \s

41) One of the valid keywords in the c language is

1) printf                       2) CHAR                    3) auto             4) scanf


42) The comments in a c language program are placed between

1) \* and /*                  2) / and .*                    3) /*and*/                    4) # and #


43) If p and q are assigned the values 2 and 3 respectively then the statement p=q++

1) gives an error message                    2) assigns a value 4 to p
3) assigns a value 3 to p                                  4) assigns a value 5 to p
44) A compound statement is a group of statement included between a pair of

1) double quots                       2) curly braces
3) parentesis                4) / and/

45) The number of the relational operators in the c language is

1) four 2) six               3) three            4)one

46) In the c language, ‘3’ represents

1) a digit                      2)an integer                 3)a character    4)a word

47) In the c language, a hexadecimal number is represented by writing

1) x                  2) xo                3) 0x                4)h


48) A string in the c language is represented by enclosing a series of characters in

1) single quotes                                   2) double quotes
3) parenthesis                          4) / and /

49) One structure cannot be

1)      a member of some other structure
2)      a member of the same structure
3)      a member of a union
4)      all of the above





     50) Masking is used

1)      to copy a portion of a given bit pattern to a new variable,
while the remainder of the new variable is filled with 0’s(using the
bitwise AND)
2)      to copy a portion of a given bit pattern to a new variable,
while the reminder of the new variable is filled with 1’s (using the bitwise OR)
3) to copy a portion of a given bit pattern to a new variable, while the remainder of the original bit pattern is inverted within the new variable
4) all of the above

51) Almost every c program begins with the statement

1) main()    2) printf()        3) #include<stdio.h>   4) scanf()


52) A single character input from the keyboard can be obtained by using the function

1) printf( ) 2) getchar( )     3) putchar( )    4) scanf( )

53) An expression

1)      is a collection of data objects and operators that can be evaluated to a single value
2)      is a name that substitutes for a sequence of characters
3)      causes the computer to carry out some action
4)      all of the above

54) The expression c=i++ causes

1)      the value of I assigned to c and then I incremented by 1
2)      I to be incremented by 1 and then the value of I assigned to @
3)      Value of I assigned to c
4)      I to be incremented by 1



55)The single character input/output functions are

1) scanf( ) and printf( )                       2) getchar( ) and printf( )
3) scanf( ) and putchar( )        4) getchar( ) and putchar( )

56) The conversion character ‘I’ for data output means that the
Data item is displayed as

1)      a floating point value with an exponent
2)      an unsigned decimal integer
3)      a signed decimal integer
4)      an octal integer

57) The header file “ctype.h” can be used for

1)      providing links to assembly language for calls
2)      providing diagnostic and debugging assistance
3)      providing support for string handling functions
4)      providing character type identification (Boolean)
and translation

58) In a circular linked list

1)      components are all linked together in some sequential manner
2)      there is no beginning and no end
3)      components are arranged hierarchically
4)      forward and backward transversal within the list is permitted

59) The function ftell( )

1)      reads a character from a file
2)      reads an integer form a file
3)      gives the current position in the file
4)      sets the position to the beginning of the file

60) A c function contain

1)function body                      2)argument declaration
3)a function header     4)all of the above

1.int a=123.12;
  int b=-123.12;
   c=a+b;
   printf("%2f",c);

  a) 0.00
  b) 123.12
  c) 246.24
  d) None of these


2. struct emp
    {
       int a;
       char *name;
    };
   main()
    {
      struct emp *e;
      printf("%d",sizeof(e));
    }
ANs: 2

3.  which is the best thing for linked list than arrays?
    i) Insertion
    ii) Deletion
    iii) Traversal

   a)  (i)   only
   b) (i),(ii) only
   c)  ii,iii only
   d) iii only


4. consider the character array of size 10. When a string is more than 10
   
    a) Error
    b) Overwrites
    c) Nothing
    d) garbage value






5.  main()
    {
      char *str;
      char *fun();
       str=fun();
      printf("%s",str);
   }
   
   char * fun()
    {
      char *buffer;
      strcpy(buffer,"Hello world");
        return buffer;
    } 
             

  a) hello world
  b) Compiler error
  c) Runtime error
  d) None of the above
 
6.  main()
    {
      char *str;
      char *fun();
        str=fun();
      printf("%s",str);
   }
   
   char * fun()
    {
      char *buffer;
      buffer=(char *) malloc(sizeof(char));
      strcpy(buffer,"Hello world");
        return buffer;
    } 
             

  a) hello world
  b) Compiler error
  c) Runtime error
  d) None of the above
ans::a



7) what is the prefix expression for the given Infix expression  A+B*C/D
Ans::+A/*BCD



8) int a;
   a=65536;
   printf("%d",a);
   
    a) 0
    b) Garbage
    c) 65535
    d) -32768       


9) main()
   {
     char p=65;
     printf("%c",p);
  }

  a) 65  b) p c) error d) none of the above

10) In a function call, _____________ is passed as arguments.
      a) variables
      b) constants
      c) Expressions
      d) All the above

11) The value of EOF is ___-1______.

12) () is used for __________
   
    a) function body
    b) Arguments
    c) Return type
    d) Declaration of function


13) How does the string ends?

            a) /n
            b) /t
            c) /0
            d) none

14) The range of Unsigned integer is

            a) 127 to -128
            b) 0 to 65535
            c) Depend up on the compiler
            d) -32768 to 32767

15)  which one of the following is a illegal real constants

            a) 32.535
            b) -1.5E25 to 3.5E65
            c) "53682"
            d) -6.583

16) main()
    {
      int i,a[5];               
        a[1]=5;
      for(i=0;i<5;i++)
            {
         printf("%d",a[i]);
            a++;
            }

            a) 0 0 0 0 0
            b) Garbage value
            c) 0 5 0 0 0
            d) Compiler error
ans:d…..base address can’t be changed a++

17) The size of int is 2 bytes,then what is the size of short int?
            a) 1
            b) 2
            c) 4
            d) 8

18) In a queue,what condition applies

            a) First In First Out
            b) Last in first out
            c) Elements are inserted and deleted at one end
            d) Elements can be inserted and deleted in different ends

19) which of the following statements are true in the case of doubly linked list
             i) Every node is connected to other node
        ii) We can traverse in both the directions

            a) i) only
            b)ii) only
            c) Both i and ii
            d) neither i nor ii
ans::c

20) main()
     {
       char str[]="Wipro Infotech";
            char *s;
       s=&str[13]-13;
       while(*s)
          printf("%c",*s++);
   }      
Ans:: Wipro Infotech

21) char *a="Malayalam";
    char *s;
    Char *str;
    str=a;
    s=str+8;
    for(;s>=str;s--)
      printf("%c",*s);

    a) Malayalam
    b) malayalaM
    c) error
   d) None of the above

22) struct main
     {
       int a;
       int b;
       struct main *e1;
     }
    printf("%d %d",sizeof(e1),sizeof(*e1));


23)  #define wipro Hai
      void main()
       {
         printf("wipro");
  
            }

24) Is allocating a block of  memory effectively the same as defining an array?
     a) True
     b) false


25)  the size of a node od doubly linked list is always greater than the single linked list
      a) True
      b) false

26) Queue is used for
        i) Expression Evaluation
        ii) Scheluding the job in First come First serve

                        a) i) only
                        b) ii only
                        c) both i & ii
                        d) neither i nor ii

27) what should be replace ????? in the program to get the output 25?

            ?????
            void main()
            {
              int x=2,y=3,j;
               j=SQRT(x+y);
             printf("%d",j);
        }
  
            a) #define SQRT(int) (int * int)
            b) #define SQRT(int) (int) * (int)
            c) #define SQRT(int) (int + int)
            d) #define SQRT(int) (int) + (int)


28) void fun()
            {
              static char p[]="Hello";
              return p;
            }
 
            main()
            {
              printf("%s",fun());
            }
       what will be the output?
            Ans::Error Void function do not return a value.
            a) Compiler Error  b) Hello  c) Garbage value   d) None


29) void main()
            {
          int *p;
               p=(int *)malloc(sizeof(int));
               for(i=0;i<5;i++)
                 printf("%d ",p[i]);
            }
    What is the output?
Ans:garbage value

30)  main()
            {
              int i,j;
               for(i=1,j=10;i<j;i++,j--);
                printf("%d %d",i,j);
            }
Ans:6,5
31)   Which of these will pass the address of the pointer *ptr to the function demofun()?

            a) demofun(ptr)   b) demofun(&ptr)  
            c) demofun(*ptr) d) demofun(*&*ptr);                        


32) which is not a valid expression
            a) x!=y   b) x!   c) !x   d) x!y


33)  If max=10,rear=max,front=0,then what will be my queue?

            a) Queue Empty
            b) Queue Full
            c) Queue has one element
        d) Queue has max-1 elements


34) which is an indefinite loop?
            a) do while(0);
            b) for(;0;);
            c) while(1);
            d) while(0);

35) int *ptr;
    ptr=(int *)malloc(10*sizeof(int));
which is correct?
       i) All Values are intialised to garbage values
            ii) Creates memory for 10 integer data

            a) i only
            b) ii only
            c) both i and ii
            d) neither i nor ii


36) int *ptr;
    ptr=(int *)calloc(10*sizeof(int));
which is correct?
       i) All Values are intialised to zero
            ii) Creates memory for 10 integer data

            a) i only
            b) ii only
            c) both i and ii
            d) neither i nor ii


37)   Struct queue
            {
           int rear;
               int front;
           int a[100];
            }
       struct queue *q;
  then  how will you add a new element called 'item' in the queue?


            a) q->rear[a]=item;                             
            b) q->a[q->rear]=item;
            c) q->a[rear]=item;
            d) q->rear[q->a]=item;



38) In which of the following we can sort the data without moving the data                      
            a) Array
            b) Single Linked list
            c) Doubly linked list
            d) Binary search trees

39)  Char d=128;
     printf("%c",d);

            a)128
            b)-128
            c) error
            d) Garbage values

           
40) In the following definition
            struct node *ptr;
            ptr=(struct node *)calloc(sizeof(ptr));

            a) ptr is allocated 4 bytes
            b) ptr will be allocated sizeof struct node
            c) Error
            d) ptr will have 8 bytes

41)   In a doubly linked list ,if the first node is first and the last node is end,what will be the output?

traverse(struct node*end)
{
  while(end!=NULL)
            traverse(end->prev);
   printf("%d",end->data);
}

if the input is 1,2,3,4,5 then the output will be

            a) 1,2,3,4,5
            b) 5,4,3,2,1
            c) compilation error
            d) none

42) void main()
            {
            int b=20;
            printf("%d"*&b++);
            }
what will be the output?
            a) 21   b)20 c) error  d) Garbage value
ANS::C

43) how will you refer the last node in the doubly linked list which is pointed by the pointer variable 'cursor'?
            a)cursor==NULL
            b)cursor->link=NULL
            c) Cursor->link=0
            d) cursor->data=NULL




44) how will you refer the previous node of the pointer 'cursor' in the doubly linked list (cursor is not in the first or in the last)?
            a)cursor->link++
            b)cursor=cursor->left
            c) Cursor++
            d) cursor->left++













1.
 #include<stdio.h>

int x=40;
main()
{
            int x = 20;
            printf("\n %d",x);
}

Predict the output
20
40
20, 40
None of the above

2.
#include<stdio.h>
main()
{
            int x=40;
            {
                        int x = 20;
                        printf("\n %d",x);
            }
            printf("%d",x);           
}
Predict the output
20 40
40 20
40
20

3.
#include<stdio.h>
main()
{
            extern int a;
            printf("\n %d",a);       
           
}
int a=20;

Predict the output
20
0
Garbage value
Error

4.
#include<stdio.h>--------------------------------doubt
main()
{
           
            struct emp
            {
                        char name[20];
                        int age;
                        float sal;
            };

            struct emp e={"Raja"};
            printf("\n %d %f", e.age, e.sal);
}

0 0.000000
Garbage values
Error
None of the above

5.
#include<stdio.h>
main()
{
            int x=10, y=20, z=5, i;

            i= x < y < z;

            printf("%d", i);
}o\p  1

6. Which of the following definition is correct?
int length
char int
int long
float double

7.  What will be the output
#include<stdio.h>

main()
{
            int i=4;

            switch (i)
            {

                        default:
                                    printf("Default Value \n");


                        case 1:
                                    printf("Value is 1 \n");
                                    break;

                        case 2:
                                    printf("Value is 2 \n");
                                    break;

                        case 3:
                                    printf("Value is 3 \n");
                                    break;

                       
            }
}o\p  default value

8.
#include<stdio.h>------------doubt

main()
{
            int i=1;

            while()
            {
                        printf("%d", i++);
           
                        if (i >10)
                        {
                                    break;
                        }
            }
}

9.
#include<stdio.h>------------------------------doubt
main()
{
            int x=30, y =40;

            if (x==y)
                        printf("X is equal to Y");
            elseif (x>y)
                        printf("x is greater than Y");
            elseif (x<y)
                        printf("X is less than Y");
}

Statement missing
Expression Syntax
Lvalue required
RValue required

10.
#include<stdio.h>
main()
{
            int i=10, j=15;

            if(i%2 = j%3)
            {
                        printf("Same");
            }
            else
            {
                        printf("Different err");
            }
o\p  same

11.
#include<stdio.h>------------doubt

main()
{
            int x=4, y, z;

            y=--x;

            z= x--;

            printf("%d %d %d", x,y,z);
}

Output:
4 3 3
4 3 2
3 3 2
2 3 3
2 2 3

12.
#include<stdio.h>

main()
{
            float a = 0.7;
            if (a<0.7)
            {
                        printf("C");
            }
            else
            {
                        printf("C++");
            }
} Try with 0.7f   o\p  c++




13.
#include<stdio.h>

main()
{
            float fval=7.29;

            printf("%d" ,fval);
}o\p 7 

14.
#include<stdio.h>-----------------------doubt

main()
{
            printf("Welcome");
            main();
}  

How many times the program will execute?

32767
65535
Till the stack doesn’t overflow

15.
#include<stdio.h>----------------------doubt

void fun(char *);


void main()
{
            char a[100];
            a[0] = 'A',    a[1] = 'B';
            a[2] = 'C',    a[3] = 'D';

            fun(&a[0]);
}

void fun(char *a)
{
            a++;
            printf("%c", *a);
           
            a++;
            printf("%c", *a);
o\p  b c

16.
#include<stdio.h>

#define MESS "Junk"

main()
{
            printf("MESS");
}o\p    mess

                       

18.
#include<stdio.h>
main()
{
            char str[] = "Sales\0man\0";
            printf("%d", strlen(str));
}o\p   5

19.
#include<stdio.h>
main()
{
            char str[] = "Sales\0man\0";
            printf("%d", sizeof(str));
}o\p   11

20
#include<stdio.h>-------------doubt
#include<string.h>

main()
{

            char sentence[80];
            int i;

            printf("Enter the line of text");
            gets(sentence);

            for(i=strlen(sentence)-1;i>=0;i--)
            {
                        putchar(sentence[i]);
            }
}

21
#include<stdio.h>-----------------------doubt

main()
{
            float a=3.15529;
            printf("%6.2f \n",a);
            printf("%6.3f \n",a);
            printf("%5.4f \n",a);
            printf("%2.1f \n",a);
            printf("%0.0f \n",a);
}
1. printf("%d  %d  %d",sizeof(25.75),sizeof(123),sizeof(‘p’))
a. 2 2 2   b. 4 2 2   c. 8 4 1  d. 8 2 2

2.         int i=5;
fun( )
            {
                        printf("%d\n", i * 3);
            }
            main( )
{
int i= 2;
{
                        int i = 3;
                        printf(" %d", i);
                        fun();
}
            }         
a.       3, 15
b.      3, 6
c.       3
d.      0

3. #define  xsq(x)  x*x
            main( )
            {
                        int i, j; 
            i = 5;
            j = xsq(i-2);
printf(“%d\n”, j);
            }
b.      –7
c.       9
d.      13
e.       29

4. main( )
           {
int a=35;
printf(“ %d  %d   %d\n”, a == 35,a=50,a>40);
          }
a.       1 50  1
b.      1 50   0
c.       0 50  0
d.      0 50 1

5. void main()
{
char a[]="123abcd";
clrscr();
printf("%d",strlen(a));
getch();
}

a.                                                                                                              6
b.                                                                                                              7
c.                                                                                                              8
d.                                                                                                             5

6. main()
{
static int var=5;
if(var--)
{
printf("%d",var);
main();
}
}

a. 4 3 2 1 0  
b. 4 3 2 1
c. 5 4 3 2 1
d. 5 4 3 2 1 0

7. void main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("One"); break;
case j: printf("Two");  break;
default: printf(“Default”); break;
}
}
a. One
b. Two
c. Default
d. Compiler Error

8. void main()
{
switch('a')
{
case 'A': printf("Zero");    break;
case 97: printf("One");      break;
default: printf("Error");     break;
}
}

a. Zero
b. One
c. Error
d. Compiler Error

9. void main()
{
int p=1,sum=0;
clrscr();
while(p<20)
{
p++;
sum+=p++;
}
printf("\nsum=%d",sum);
}

a. 120
b. 100
c. 110
d. Error

10. int x;
int modifyvalue()
{
return(x+=10);
}

int changevalue(int x)
{
return(x+=1);
}

void main()
{
int x=10;
x++;
changevalue(x);
x++;
modifyvalue();
printf("First output : %d",x);
changevalue(x);
printf("\nSecond output : %d",x);
}

a. 12 12
b. 11 12
c. 12 13
d. 13 13

11. main()
{
static i=3;
printf("%d",i--);
return i>0?main():0;
}

a. 3 2 1 0
b. 3 2 1
c. 2 1 0
d. 2 1

12. void main()
{
char *ptr="Hello World";
*ptr++;
printf("%s",ptr);
ptr++;
printf("%s",ptr);
}

a. Iello World     Iello World
b. Hello World    ello World
c. ello World       ello World
d. ello World       llo World

13. int const *p;
*p=5;
printf("%d",*p++);

a. 5
b. 6
c. Compiler Error
d. Garbage Value

14. void main()
{
char *str1="abcd";
char str2[]="abcd";
printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("ab"));
}

a. 5  5  3
b. 4 5  3
c. 2 5  3
d. 1 5  3

15. P is a character pointer variable then, what will be the output of the following statement.
printf("%d %d",sizeof(p),sizeof(*p));

a. 1   2
b. 2  1
c. 2  2
d. 1  1

16. void main()
{
char *s[]={"dharma","hewlet-packard","siemens","ibm"};
char **p;
p=s;
printf("%s",++*p);
printf("\n%s",*p++);
printf("\n%s",++*p);
}

a. harma
   harma
   ewlet-packard
b. dharma
    harma
    ewlet-packard
c. harma
    hewlet-packard
    siemens
d. harma
    harma
    hewlet-packard

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

a. Samco Systems   Samco Systems
b. Samco Systems   amco Systems
c. amco Systems     amco Systems
d. amco Systems     mco Systems

18. #define square(x) x*x
void main()
{
int i=7;
clrscr();
i=64/square(4);
printf("%d",i);
}

a. 7
b. 16
c. 64
d. 4

19. #define man(x,y) (x)>(y)?(printf("%d",x)):(y)

void main()
{
int i=15,j=10,k=0;
k=man(i++,++j);
printf(" %d %d %d",i,j,k);
}

a. 16  17  11  2
b. 17  17  11  2
c. 16  16  11  2
d. 16  17  12  2

20. struct one
{
int no:1;
int pl:2;
int x:3;
};

void main()
{
struct one a;
a.no=0;
a.pl=1;
a.x=3;
printf("%d %u",a.no,a.no);
printf("\n%d %u",a.pl,a.pl);
printf("\n%d %u",a.x,a.x);
}

a. 0  0
   1  1
   3  3
b. 0  0
    2  2
    3  3
c. 1  1
    2  2
    3  3
d. 1  1
    2  2
    2  2

21. void main()
{
 struct emp
 {
   struct e
   {
     int *a;
   }e1;
   int a;
 };

struct emp emp1;
printf("%d  %d",sizeof(emp1),sizeof(emp1.e1));
}

a. 2  4
b. 2  2
c. 4  4
d. 4  2

22. struct emp emp1;
struct emp
 {
   int a;
 };
main()
{
printf("Enter 1 values:");
scanf("%d%d",&emp1.a,&emp1.a);
//The given input is 10 and 25
printf("a=%d  a=%d",emp1.a,emp1.a);
}

a. 10  25
b. 25  25
c. 10  10
d. Compiler Error

23. Arrange the code in order to delete a node being pointer by temp.

            a)         free(temp)
            b)         temp->prev->next = temp->next
            c)         temp->next->prev = temp->prev;


            a) b c a   
            b) c b a
            c) a b c
            d) both a and b

24. What does below code do, if temp is pointing to a node other than first and last node
           
            temp -> prev ->next = temp ->next;
            temp ->next -> prev = temp -> prev;

            a)         no effect
            b)         inserts a node
            c)         deletes a node
            d)         shuffling of pointers

25. which  is the  faster traversable  dynamically growing list


            a)  Binary Search Tree      b)  Singly Linked List                  
            c)  Doubly Linked List   d)  Using Array






1. void main()
{
   int a=1,b=2,c=3;
   c=(--a, b++)-c;
   printf("%d %d %d",a,b,c);
}
(a)0 3 -3                       (b)Compile-Time Error                        (c)0 3 -1                       (d)0 3 0

2.
#define swap(a,b) temp=a; a=b; b=temp;
void main()
{
   static int a=5,b=6,temp;
   if (a > b)
      swap(a,b);
   printf("a=%d b=%d",a,b);
}
(a)a=5 b=6                   (b)a=6 b=5                              (c)a=6 b=0                   (d)None of these

3.
void main()
{
  int i=5;
  printf("%d %d %d %d %d",++i,i++,i++,i++,++i);
}
(a)Compile-Time Error            (b)10 9 8 7 6                            (c)9 8 7 6 6                  (d)10 8 7 6 6

4.
void main()
{
  int i, n =10;
  for (i=1; i<n--; i+=2)
     printf("%d", n-i);
}
(a)84                            (b)840                                      (c)852                          (d)864
5.
What is the output of the program?
    #include <stdio.h>

    int main(int argc, char *argv[])
    {
        printf(" %d", printf("Hello Genesis"));
        return 0;
    }
  1. Hello Genesis
  2. 13 Hello Genesis
  3. Hello Genesis 13
  4. None of the above
6.
  #include <stdio.h>
   
    main()
    {
        switch (5)
        {
            case 5: printf(" 5 ");
            default: printf(" 10 ");
            case 6: printf(" 6 ");
        }
    }
  1. 5
  2. 5 10 6
  3. 5 10
  4. 5 6
7.
Which argument of function 'strncmp()' specifies number of characters to be compared?
  1. first
  2. second
  3. between 2 strings
  4. third
8.
Which of the following is not a storage class in C?
  1. Stack
  2. Register
  3. Extern
  4. Static
9.
What is the significance of the free() function?
  1. It assigns the pointer a NULL value
  2. It erases the contents of any type and cleans the pointer
  3. It places the memory address with the pointer in free store
  4. It disables the memory address with the pointer
10.
What is the data type of FILE?
  1. integer
  2. union
  3. pointer
  4. structure
11.
#include <stdio.h>
    #define sq(a) a * a      

    void main()    
    {
        printf("%d", sq(3 + 2));
    }        
  1. 25
  2. 11
  3. 10
  4. Compilation error 
12.
Which of the following is a non-linear data structure?
  1. Stack
  2. Queue
  3. Linked List
  4. Tree
13.
Which of the following function does not return an integer value?
  1. printf
  2. scanf
  3. strcpy
  4. strlen
14.
Which of the following function does not support dynamic memory allocation?
  1. alloc
  2. realloc
  3. malloc
  4. free
15.
What is the output of the program if the input is 103?

    main()
    {
        int p = 234;
        printf(" %d ", printf("%d", p), scanf("%d", &p));
    }
  1. 3 103
  2. 103
  3. 103 3
  4. 103 2
16.
Where do we use a 'continue' statement?
  1. In 'if' statement
  2. In 'switch' statement 
  3. In 'goto' labels 
  4. None of the above
17.
  1. Queue is  _________________

a)      LIFO
b)      LILO
c)      FIFO
d)     Both b & c

18.
What is the postfix expression for A + B * C / D – E * F / G
e)      ABC*D/+EFG*/-
f)       ABC*D/+EF*G/-
g)      ABCD/*+EF*G/-
h)      None of these.

19.
Write one statement equivalent to the following two statements:   x=sqr(a);  return(x);
 Choose from one of the alternatives
      (a) return(sqr(a));                                   
      (b) printf("sqr(a)");
      (c) return(a*a);                                   
      (d) printf("%d",sqr(a));

 20.
int i=5;

int abc(int z)
{
      return i/2;
}
main()
{
       int i=4;
       printf("%d",abc(i=i/4));
}

a)  error
b)  5
c)  2
d)  0

21.
union U
{
int  x;
float y;
char s[2];
};
union U ob;

what is the size of ob in bytes,

a)  4
b)  2
c)  8
d)  7

22.
The operation for adding  and deleting an entry to a stack is traditionally called:
a.add , delete
b.append , delete
c.insert , delete
d.push , pop
e. front , rear
23.
What is the Infix expression for    - + A / * B C D / * E F G
a)      A + B * C / D – E / F * G
b)      A + B / C * D – E * F / G
c)      A + B * C / D – E * F / G
d)     A - B * C / D + E * F / G

24.
What would be the root node if we enter the following data set (in the respective order) into a standard program to construct a Binary search tree?

25, 72, 16, 11, 88, 26, 9, 36, 21, 45, 14, 69
e)  69
f)   25
g)  26
h)  9


25.

what does the code below do, where head is pointing to first node & temp is a temporary pointer. 10 be the number of nodes
           
            temp = head;
            while (temp->next->next!=NULL)
            {
                        temp = temp ->next;
            }
            temp -> prev -> next = temp -> next;
            temp -> next -> prev = temp -> prev;
            free(temp);

            a)         no effect
            b)         deletes some node
            c)         deletes 2nd last node
            d)         deletes last node








1.
What will be the output of the following program :
int main()
{
             int val=5;
      printf("%d %d %d %d",val,--val,++val,val--);
             return(0);
}
(a)3 4 6 5  (b)5 5 6 5  (c)4 4 5 5  (d)None of these                            

2.
#define Compute(x,y,z) (x+y-z)
int main()
{
 int x=2,y=3,z=4;
             printf("%d",Compute(y,z,(-x+y)) * Compute(z,x,(-y+z)));
 return(0);
}
 (a)40 (b)30 (c)Compile-Time Error    (d)None of these                                

3.
What will be the output of the following program :
            int main()
{
 int val=5;
 val=printf("C") + printf("Skills");
             printf("%d",val);
 return(0);
}
(a)7 (b)C7 (c)Compile-Time Error(d)CSkills7           

4.
What will be the output of the following program :
int main()
{
             char str[]="Test";
 if ((printf("%s",str)) == 4)
       printf("Success");
      else
       printf("Failure");
 return(0);
}
a)Success b)TestSuccess c)Compile-Time Error(d)Failure                

5.
What will be the output of the following program:
int main()
{
      int val=5;
      printf("%d",5+val++);
      return(0);
}
(a)Compile-Time Error    (b)Lvalue required Error    (c)10   (d)11                                                    

6.
void main()
{
      printf("%d",sizeof(int));
      return(0);
}
 (a)Data types not allowed (b)Compile-Time Error(c)3 (d)2                         
7.
In tree construction which is the suitable efficient data structure?
            (a) Array           (b) Linked list              (c) malloc           (d) Queue  
8.
Traverse the given tree using Inorder, Preorder and Postorder traversals.










a)Inorder :       D H B E A F C I G J
Preorder:         A B D H E C F G I J
Postorder:        H D E B F I J G C A

b)Inorder :       D H B E A F C I G J
Preorder:         D H E A B C F G I J
Postorder:        H D E B F I J G C A

c)Inorder :       D H B E A F C I G J
Preorder:         A B D H E C F G I J
Postorder:        H D E B F I J G A C

d)Inorder :       H D B E A F C I G J
Preorder:         A B D H E C F G I J
Postorder:        H D E B F I J G C A

9.
main()
            {
            static int var = 5;
            printf("%d ",var--);
            if(var)
                        main();
            }

b.      4 3 2 1      b. 4 3 2 1 0    c. 5 4 3 2 1   d. 0 0 0 0 0


10.
#include<stdio.h>
main()
{
struct xx
{
      int x=3;
      char name[]="hello";
 };
struct xx *s;

printf("%d",s->x);
printf("%s",s->name);
}

  1. 3   hello   b.  Compiler Error    c. Run time error   d. use dot (.) operator

11.
#include<stdio.h>
main()
 {
   const int i=4;
   float j;
   j = ++i;
   printf("%d  %f", i,++j);
 }

  1. 5   6.000000     b.  5   5.000000   c.  6   6.000000  d. compiler error
12.
void main()
{
            int k=ret(sizeof(float));
            printf("\n %d",++k);
}
int ret(int ret)
{
            ret += 2.5;
            return(ret);
}
  1. Compiler Error    b. 8       c. 6    d. 7
13.
int swap(int *a,int *b)
{
 *a=*a+*b;*b=*a-*b;*a=*a-*b;
}
main()
{
                        int x=10,y=20;
            swap(&x,&y);
                        printf("x= %d y = %d\n",x,y);
}
  1. 20  10   b.  10  20   c. 20  20   d. 10  10

14.
main()
{
char *p = “ayqm”;
char c;
c = ++*p++;
printf(“%c”,c);
}
  1. a       b. b     c. y    d. z

15.
main()
{
                        float i=1.5;
            switch(i)
                        {
                        case 1: printf("1");
                                    case 2: printf("2");
                                    default : printf("0");
            }
}
  1. 0    b.  0  1  2     c. 1  2  0   d. Compiler Error   e. 2  0

16.
#define MESS junk
main()
{
printf(“MESS”);   
}
b.      Junk        b. Error      c.  MESS       d. MESS  junk

17.
main ()
{
            int i = 5;
            switch (i) {
            static int i;
            i = 3;
            i =  i * i;
            case 3:
                        i = i + i;
            case  4:
                        i = i + i;
case  5:
                        i = i + i;
                        printf (“%d”,i);
            }
            printf (“%d”,i);
}
  1. 9     b. 10  10    c.  0   5   d. 18   18   e.  18   5

18.
What would be the output of the following program.
Int fn(int);                    
 main()
                        {
                            int i=10;
                            fn(i);
                            printf("%d",i);
                        }
  fn(int i)
         {
          return ++i;
         }
           (a) 10                           (b) 11                           (c) 12                           (d) Compilation error

19.
main()
{
FILE *fp1,*fp2;
     
      fp1=fopen("one","w");
      fp2=fopen("one","w") ;
      fputc('A',fp1) ;
      fputc('B',fp2) ;
      fclose(fp1) ;
      fclose(fp2) ;
     }

     Find the Error, If Any?
e.       no error. But It will over writes on same file.
f.       no error. But It will create one more file.
g.      error. It will not allow.
h.      no error. The new content will append in existing file.
20.
void main()
            {
          int a=555,*ptr=&a,b=*ptr;
              printf("%d %d %d",++a,--b,*ptr++);
            }
(a)Compile-Time Error            (b)555 554 555                                    (c)556 554 555                        (d)557 554 555

21.
what type of Binary Tree is the following tree below

    1. binary tree
    2. strictly binary tree
    3. complete binary tree
    4. not a binary tree

22.
If suppose root to be deleted then which node will be the root node


    1. B
    2. G
    3. Any node
    4. Both a and b are correct
23.
When fopen() fails to open a file it returns
a) NULL   b) –1   c) 1   d) None of the above

24.
Which function is used to detect the end of file
a) EOF   b) feof( )   c) ferror( )   d) NULL

25.
If the CPU fails to keep the variables in CPU registers, in that case the variables are assumed
 a) static   b) external   c) global   d) auto

1.main()
{
            int x,y,z;
            x=y=z=1;
            z=++x||++y&&++z;
            printf("%d %d %d",x,y,z);
}
2.13. main()
{
                        int i=5,j=10;
            i=i&=j&&10;
                        printf("%d %d",i,j);
}
ans::1 10
3.2. main()
{
            int i=-1,j=-1,k=0,l=2,m;
           
            m=i++&&j++&&k++||l++;
           
            printf("%d %d %d %d %d",i,j,k,l,m);
}
ans::0 0 1 3 1

3.28.  main()
{
                        int i=4,j=7;
            j = j || i++ && printf("YOU CAN");
                        printf("%d %d", i, j);
}
ans::4 1
3.29
main()
{
            int a=500,b=100,c=300,d=40,e=19;
            a+=b-=c*=d/=e%=5;
            printf("%d %d %d %d %d",a,b,c,d,e);
}

2.main( )
{
int k=35;
printf(“ %d  %d   %d\n”, k == 35,k=50,k>40);
}
ans::0 5 0
3.main( )
 {
        int x=4,y,z;
         y = --x;
         z = x--;
         printf(“%d %d %d\n”,x,y,z);
 }
ans:2 3 3
1.6. main()
             {
                        int i=10;
                        i=!i>14;
                        printf ("i=%d",i);
            }
ans::0
1.20. main()
            {
            int i=-1;
            +i;
            printf("i = %d, +i = %d \n",i,+i);
            }
ans -1,-1
1.34. #include<conio.h>
main()
{
            int x,y=2,z,a;
            if(x=y%2) z=2;
            a=2;
            printf("%d %d ",z,x);
}
1.42. main()
{
                        int i=10,j=20;
           
j = i, j?(i,j)?i:j:j;
                       
printf("%d %d",i,j);
}
3.4. main()
{
int i=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
}

int main()
{
 int x=5,y=6,z=2;
 clrscr();
 z/=y/z==3?y/z:x*y;
 printf("%d",z);
return 0;

}

int main()
{
 int a=1,b=2,c=3,d=4;
 clrscr();
 printf("%d\n",!a?b?!c:!d:a);
 printf("%d %d %d %d",a,b,c,d);
 return(0);
}

5.main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}


1. main()
            {
            char *p="hai friends",*p1;
            p1=p;
            while(*p!='\0') ++*p++;
            printf("%s   %s",p,p1);
            }

2.#include<stdio.h>
#include<conio.h>

void main()
{
  char a[]="abcdef";
  char *p=a;
  clrscr();
  p++;
 p++;
  p[2]='z';
  printf("%s",p);
  getch();
  }
ans::cdzf

2.6. main()
            {
            char *str1="abcd";
            char str2[]="abcd";
            printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd"));
            }
ans:: 2 5 5

2.1. main()
{
            char s[ ]="man";
            int i;
            for(i=0;s[ i ];i++)
            printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
ans:: m m m
          a  a  a
          n  n  n
1.7. #define square(x) x*x
            main()
            {
            int i;
            i = 64/square(4);
            printf("%d",i);
}
ans::64

1.7.2  #define cube(x) x*x*x
main()
{
            int b=3,a;
            a=cube(b++);
            printf("%d %d",a,b);
}
ans::27,6

1.8. #include <stdio.h>
#define a 10
main()
{
#define a 50
printf("%d",a);
}
ans::50

3.3. #include<stdio.h>
main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
}

3.6.  main()
{
   static char names[5][20]={"pascal","ada","cobol","fortran","perl"};
    int i;
    char *t;
    t=names[3];
    names[3]=names[4];
    names[4]=t;
    for (i=0;i<=4;i++)
            printf("%s",names[i]);
}
ans::Lvalue Required.....base address can't be changed     names[3]=names[4];


1)Allocating a 2 blocks of memory for 'n' intgers is by using
a) malloc
b) calloc
c) both malloc and calloc
d) none of the above

2) In queue using linked list, which is correct?
a) both insertion and deltionis made at the front end
b) insertion is made at the beginning and deletion is made at the last
c) insertion is made at the last and deletion is made at the beginning
d) both insertion and deltionis made at the back end

3) for(i=0;i<2;i++)
            {
            for(j=0;j<5;j++)
            {
            if(i==j)
            break;
            printf("wipro");
            }
}
how many times would wipro to be printed?
1 time

4) all the local variables are stored in -----------------
a) stack
b) heap
c) queue
d) none
ans::a

5) Once you call a function,all the return addresses are stored in ----------------
a) stack
b) heap
c) queue
d) none

6) Which of the following is true about binary tree
i) all nodes except leaf node has exactly two child
ii) root node is greater than the left sub tree and lesser than the right sub tree.
a) i only
b)ii only
c) both i and ii
d) neither i nor ii        

7) Which of the following is true about complete binary tree
i) all nodes except leaf node has exactly two child
ii) root node is greater than the left sub tree and lesser than the right sub tree.
a) i only
b)ii only
c) both i and ii
d) neither i nor ii        

8) struct node
{
int data;
struct node *left,*right;
};
suppose start and end are the pointers pointing to the beginning and ending node reapectively.then,what will be the output of the following snippet
front=start;
back=end;
while(back!=NULL)
{
printf("%d",back->data);
back=back->left;
}

Data Structure Questions & Answers


1)Consider the following structure
   struct node
    {
      int info;
      struct node *link;
    };

Suppose ptr is a pointer which is not pointing to the first or the last node. Then if we are going to delete a node after ptr, then the code will be

a) ptr=ptr->link;
b) ptr->link=ptr;
c) ptr->link=ptr->link->link;
d) ptr=ptr->link->link;



2)  Consider the following structure
   struct node
    {
      int info;
      struct node *link;
    };


Suppose start is a pointer pointing to the first node of the linked list.
s1 and ptr are the two pointers (they are not pointing to the first or last node). Then if we are going to execute the following code,

i)   start->link=s1;
ii)  s1->link=ptr;
iii) ptr->link=start;

then the list is

a)  It is having only 3 nodes with start, s1, ptr in the list, having start as the first node
b)  It is a circular linked list
c)  It is a doubly linked list
d)  None of the above



3) In a queue, if rear=front then what will be the queue
a)  Queue is empty
b)  Queue is full
c)  Queue has only one element
d)  None of the above


4) In a queue, if rear=0, front=0 then what will be the queue
a)  Queue is empty
b)  Queue is full
c)  Queue has only one element
d)  None of the above


5)  In a queue, if rear=0, front=1 then what will be the queue
a)  Queue is empty
b)  Queue is full
c)  Queue has only one element
d)  Queue is circular   

                         
6) In a queue,if rear=-1,front=-1 then what will be the queue
a)  Queue is empty
b)  Queue is full
c)  Queue has only one element
d)  None of the above
   
7) In a queue, if rear=max-1, front=0 then what will be the queue
a)  Queue is empty
b)  Queue is full
c)  Queue has only one element
d)  None of the above


8) The postfix expression is ab+c*d/e-.The values of a, b, c, d, e are 2, 4, 5, 2, 1 respectively. Then the output is

   a)  14
   b)  11
   c)  20
   d)  15


9) The infix expression is a+b*(c-d)/(e+f)*h then my postfix expression is
    a) ab+cd-*ef+h*/
    b) abcd-ef+*/h*
    c) abcd-*ef+/h*+
    d) abcdef+-*/h*+

10) In the stack, if top=0 then the stack is
a)  Stack is empty
b)  Stack is full
c)  Stack has only one element
d)  None of the above  



11)  Consider the structure
       struct node
            {
            int info;
             struct node *left;
            struct node *right;
            };

We have 10 elements in the list. If the following executes what will be the output?

            for(ptr=start; ptr; ptr=ptr->right)
            {
              if(ptr->data%2==0)
              printf("%d", ptr->data);
            }
  
a) Only even numbers are printed
b) Only odd numbers are printed
c) Compiler error
d) Only garbage values


12)      struct node
             {
               int data;
               struct node *left,*right;
            };

Suppose nd is a node which is not in the beginning and also not in the end. How will you delete a node after nd?

a) nd->right=nd->right->left;nd->right->left=nd->left->right;
b) nd->right=nd->right->right;nd->right->left=nd;
c) nd->right=nd->right->left;nd->right->left=nd->right;
d) nd->right=nd->left->right;nd->left->right=nd;



13)     struct node
            {
               int data;
               struct node *left,*right;
            };

Suppose nd is a node which is not in the beginning and also not in the end. How will you delete a node before nd?

a) nd->left=nd->right->left;nd->right->left=nd->left->right;
b) nd->left=nd->right->right;nd->left->right=nd->right;
c) nd->left=nd->left->left;nd->left->right=nd;
d) nd->left=nd->left->right;nd->left->right=nd;


14)     struct node
            {
               int data;
               struct node *left,*right;
            };

Suppose ptr is a node which is not in the beginning and also not in the end. How will you delete a node ptr?

a) ptr->left->right=ptr->right;ptr->right->left=ptr->left;free(ptr);
b) ptr->left->right=ptr->right->right;ptr->left->right=ptr->right;free(ptr);
c) ptr->left->right=ptr->left->left;ptr->left->right=ptr;free(ptr);
d) ptr->left->right=ptr->left;ptr->left->right=ptr->left;free(ptr);






15)     struct node
            {
               int data;
               struct node *left,*right;
            };

Suppose ptr is a node which is not in the beginning and also not in the end. nd is the new node.

Here is the coding:
 i)  ptr->right->left=nd;
 ii)  nd->left=ptr;
 iii)  ptr->right=nd;
 iv)  nd->right=ptr->right;

Then what sequence does it follows for inserting nd after ptr?

a) i,ii,iii,iv
b) ii,iv,i,iii
c)iv,iii,ii,i
d) ii,iii,i,iv


16) In the Given Infix expression which is the root node for your expression tree (A+B)-(C*D)+G/H*I

a) +
b) -
c) *
d) /



17) Consider a binary search tree

insert(10,root);
insert(25,root);
insert(5,root);
insert(8,root);
insert(13,root);
insert(45,root);
insert(70,root);
insert(32,root);
delete(13,root);
insert(66,root);
insert(13,root);
insert(36,root);


What will be the preorder traversal is  

a) 5,8,10,13,25,32,36,45,66,70
b) 10,5,8,25,13,45,32,36,70,66
c) 10,8,5,13,32,45,36,66,32,70
d) 8,5,32,36,10,66,45,70,25,13
           


19) The preorder traversal is 5, 3, 66, 30, 77, 70 .What will be the root node

a) 5
b) 66
c) 70
d) 30

20) Which one of the following is true for the binary tree
   i) root is greater than the left sub tree and lesser than the right sub tree
   ii) root is lesser than the left sub tree and greater than the right sub tree 


a) only i
b) only ii
c) both i and ii
d) Neither i nor ii


1. What will be the output of the following program :
            void main()
            {
          printf("%f",123);                               
            }
(a)123              (b)Compile-Time Error                        (c)123.00                     (d)123.000000
2.  What will be the output of the following program :
            void main()
            {
          int a = -1,b=2,c=3,d=4;
              d=++a||++b&&++c;
            printf(“%d %d %d %d”,a,b,c,d);
            }
(a) 0 3 4 1                    (b) 1 3 4 5                                (c)1 3 4 0    (d) 1 2 3 4
3. What will be the output of the following program :
            void main()
            {
              char line[80];  // Max. length=80 Chars
              scanf("%[^,]s",line);
              printf("\n%s",line);
            }
INPUT :Dear,how, are, you

(a)Compile Error         (b)Dear Friends           (c) dear   (d) runtime error
4.. main()
   {
    scanf(“%c%c%c”,&I,&j,&k);
}   
     Input is :  hello India hi                                 //  VARIABLES NOT DECLARED
What will be the values of i,j,k ?

a)  hello , India, hi       b)  h , e , l   (c ) compile time error   (d) run time error
5)  What will be the output of the following program :
            void main()
            {
           printf();
            }
(a)Run-Time Error       (b)Compile-Time Error            (c)No Output  (d)None of these

6)  What will be the output of the following program :
            void main()
            {
          printf("d%",8);
            }
(a)8      (b)Compile Error                     (c)%d              (d)None of these
7) void main()
            {        int val=5;
              printf("%*d",val);                 }
(a)     5             (b)5                  (c)Compile-Time Error            (d)None of these


8.  void main()
            {
              printf("Hi!");
              if (0 || -1)
                printf("Bye");
            }
(a)No Output              (b)Hi!                                      (c)Bye                         (d)Hi!Bye
9) void main()
            {
               printf("%d   %d",sizeof ( 4.56),sizeof(4.56f));
            }
(a)8, 4  (b)4,8               (c)8,8                           (d)4,4
10,.        main()
 {
 for( i=-2;i ; i++)
 printf(“hi\n”);
 }     here the loop is  performed how many times ?

   (a) 2    ( b)    1   ( c) 3   d) infinite
11. )  which of the following doesnot change value of  variable i  .
a) i++    (b)  i+1    (c)  i=i+1    (d)  i+=1
*12.  union u
       {  
        Int a;
        Char ch[2];
       }u1;
U1.a=5;
U1.ch[0]=4 ;   u1.ch[1]=2; 
Printf(“%d”,a);                                                //    IT SHOULD BE u1.a    ( ans: 516)
}
(a)  5     (b) 42    ( c) 1028   (d)  24 
13.  void main()
{
        int x, y, z;
       x = 27 ;
       y = x % 5;
      z = x / 5 ; }     what value y and z hold currently :

(a)  2,5       (b) 2,5.4    (c)  2,5.000000  (d) none of these
14.  int i=10,j=25;
       Double k;
            K = j/i;
  Printf(“%lf”,k);
(a)  2   (b) 2.5   (c) 2.499999   (d)  invalid type conversion
15.  static int choice;
              switch(++choice,choice+1,choice-2,choice+=1)//choice =2
      Currently choice will hold what value in Switch statement:
(a)  2   (b)  0    (c) invalid switch statement   (d) -1





16,. struct s
{   int rno=10;//cannot declare here
}s1;
printf(“%d”, s1.rno);

(a) compile error    (b) runtime error   (c)  10    (d)  0

16. void main()
            {
               int a=1,b=2,c=3;
               c=(--a,b++)-c;
               printf("%d %d %d",a,b,c);
            }
        (a)0 3 -3         (b)Compile-Time Error                  (c)0 3 -1                       (d)0 3 0
17.  #define swap(a,b) a=b ;temp=a; ; b=temp;
            void main()
            {             static int a=5,b=6,temp;
               if (a > b)
                  swap(a,b);
               printf("a=%d b=%d",a,b);
            }
(a)a=5 b=6       (b)a=6 b=5                  (c)a=5 b=5       (d)None of these
18. void main()
            {
              unsigned int val=5;
              printf("%u %u",val,val-21);
            }
(a)Compile-Time error (b)5 -6             (c)5 65520       (d)None of these
19.       a=5,b=6;
(++a<++b) ?—a:--b;
Printf(“%d  %d”,a,b);
}
(a)  5  6            (b)  6    7          (c)  5  7         (d)  6  6
20.       void main()
            {
              int x=4,y=3,z=2;
              *&z*=*&x**&y;
          printf("%d",z);
            }
(a)Compile-Time error (b)Run-Time Error      (c)24    (d)Unpredictable
21,.    char a[2][11]={“morning”,”India”)
          printf(“%s”, *(a[0]+3));
(a)  compile error     (b)  n     (c)  i    (d) none of these
*22. #define f(g,g2) g##g2

main()

{

int var12=100;

printf("%d",f(var,12));

}


a)compilation error                  b)runtime error    c)100                       d)var##12                         


23,.  int I=40;   
        Int *p= i;//there sud be p=&i;
            I++;
        Int *q = i;
       Printf(”%d  %d”, *p, *q);
}
(a)  40  41      (b)  41   41     (c)   40   40   (d) compile time error
24.  The syntax of a function call statement is
 
    a) function name (argument list);
    b) [storage class] function name (parameter list);
    c) function name (parameter list);
    d) [return type] function name (argument list);
25. int a[5] = { 1,2,3,4,5};
       a++;
       printf(“%d”,*a);
(a) 1    (b)  2    (c) address of a[0]    (d) none of these
26. feof ,NULL , EOF are used for the following commands respectively

(a) fgetc,fgets,fread       (b)  fread, fgetc,fgets     (c) fread, fgets,fgetc  (d) none of these//ans sud be c
27, . which of the following mode is useful for editing a file ?
     (a) w+    (b) r+   (c) a+   (d) a
28,   the term FILE is a
    (a) header file    (b)  Predefined function   (c) Predefined structure (d) none of these
29,.      int p[3][5] = {
                       { 2, 4, 6, 8, 10},         
                       { 3, 6, 9, 12, 15},
                       { 5, 10, 15, 20, 25}
                      };
What is the vlalue of *(*(p+1)+1)+1 , *(*(p+1)+2)//ans is 7 9 so none of these
(a) 6, 7   (b) 7,12   (c)  6 , 13  (d) none of these
30.to locate the position of file pointer in a file, which of the following function is used
(a)  ftell()     (b)  fseek ( )      (c)  fwrite( )    (d)  fread( )
  1. Which data structures used to perform recursion?
    1. FIFO Structure
    2. LIFO Structure
    3. LILO Structure
    4. NON Linear Structure
  1. The operation for adding an entry to a stack is traditionally called:
    1. add
    2. append
    3. insert
    4. push
  2. I have implemented the queue with a linked list, keeping track of a front pointer and a rear pointer. Which of these pointers will change during an insertion into a NONEMPTY queue?
    1.  Neither changes
    2.  Only front_ptr changes.
    3.  Only rear_ptr changes.
    4.  Both change.
  3. Suppose we have an array implementation of the Queue, with ten items in the Queue stored at Que[0] through Que[9]. The CAPACITY is 30. From where does the DeleteQue function  deletes item  in the array?
    1. Que[0]
    2. Que[1]
    3. Que[9]
    4. Que[10]
  4. If the characters 'D', 'C', 'B', 'A' are placed in a queue (in that order), and then removed one at a time, in what order will they be removed?
    1. ABDC
    2.  DCAB
    3. DCBA
    4. ABCD
*36.Here is an infix expression: 6+2*(1*5-9). Suppose that we are using the usual stack algorithm to convert the expression from infix to postfix notation. What is the maximum number of symbols that will appear on the stack AT ONE TIME during the conversion of this expression?
    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
  1. One difference between a queue and a stack is:
    1. Queues use two ends of the structure; stacks use only one.
    2. Queues require dynamic memory, but stacks do not.
    3. Stacks require dynamic memory, but queues do not.
    4. Stacks use two ends of the structure, queues use only one.
  2. If we draw a binary Tree for the expression : A * B - (C + D) * (P / Q) and traversed in Preorder, then we will get the following output.
    1. -*AB*+CD/PQ
    2. AB*CD+PQ/*-
    3. ABCDPQ-*+*/
    4. *-+*/ABCDPQ
  3. Suppose that p is a pointer variable that contains the NULL pointer. What happens if your program tries to read or write *p?
    1. A syntax error always occurs at compilation time.
    2. A run-time error always occurs when the program finishes.
    3. The results are unpredictable.
    4. A run-time error always occurs when *p is evaluated.
  4. Which of the following stack operations could result in stack Overflow flow?
    1. is_full

b.      pop

    1. push
    2. Two or more of the above answers
  1. Suppose think there is a linked list with 10 nodes and a pointer Ptr pointing to the Second node. Then which of the following statement will cause Ptr to point 5th node data.
    1. Ptr->next->next->data
    2. Ptr->next->data
    3. Ptr->next->next->next->data
    4. Ptr->next->next->next
  2. A Full Binary Search Tree contains, How many Nodes? (where ‘n’ is height)
    1. n nodes
    2. 2^(n-1) nodes
    3. 2^n nodes
    4. (2^n)-1 nodes 
  3. A Structure which can refer an another Structure of same type is called as:
    1. Structure within structure
    2. Nested structure
    3. Self referential structure
    4. Dynamic structure
  4. Suppose think there is a Double linked list with 15 nodes and a pointer Ptr pointing to the Fifth node. Then which of the following statement will cause Ptr to point 3th node data.
    1. Ptr->next->prior->prior
    2. Ptr->next->next->next
    3. Ptr->next->prior->prior->prior
    4. Ptr->next->prior->next->prior
  5. What kind of list is best to access the item at given position n?"
    1. Doubly-linked lists.
    2. Lists implemented with an array.
    3. Singly-linked lists.
    4. Doubly-linked or singly-linked lists are equally best
  6. Suppose Ptr points to a node in a linked list. What Boolean expression will be true when Ptr points to the tail node of the list?
    1. Ptr == NULL
    2. Ptr->link == NULL
    3. Ptr->data == NULL
    4. Ptr->data == 0.0
    5. None of the above.
  7. the given below is  login for Reverse traversal of a double linked list, replace the XXXXXXX with correct statements.
for( XXXXXXX )
{
  printf(“%d”, ptr->marks);
}
    1. ptr =first; (ptr); ptr = ptr->next
    2. ptr = last; (ptr); ptr = ptr->prior
    3. ptr = last; (ptr); ptr = ptr->next
    4. ptr = first; (ptr); ptr = ptr->prior

  1. In a Binary Search tree a new node is always inserted as:
    1. Right child
    2. Left child
    3. Leaf node
    4. Non leaf node
  2. Suppose Ptr needs to point last but one node in a Double linked list. Which of the statement will give me the result?
    1. Ptr=first->prior
    2. Ptr=last->prior
    3. Ptr=last->next
    4. Ptr=first->next->prior
  3. Which of the following applications may use a stack?
    1. A parentheses balancing program.
    2. Evolution of postfix expression.
    3. Syntax analyzer for a compiler.
    4. All of the above.





1.Consider the following statement :
s= fscanf(infile, “%c”, &nextChar);
what is true about the above statement?

A.    infile is the name of a file
B.     infile is the name of a variable of  type FILE*
C.     after the fscanf executes, s contains the next character read from the file (unless there is no data left on the file)

a.       A only
b.      B only
c.       C only
d.      All of A, B and C
e.       None of A, B, or C

Answer: b. B only


  1. Which of the following can be used across files
    1. extern
    2. volatile
    3. static
    4. const

Answer: a

  1. When fopen() fails to open a file it returns _______
    1. NULL
    2. -1
    3. 1
    4. None of the above

Answer:  a. NULL

  1. The EOF is equivalent to
    1. -1
    2. 1
    3. 0
    4. None of the above
Answer:  a

4.      What will be the output of following code assuming file already exists with some contents
   #include<stdio.h>
main()
{
FILE *ptr;
char i;
ptr=fopen("zzz.c","r");
while((i=fgetch(ptr))!=EOF);
printf("%c",i);
}

a.       contents of zzz.c
b.      error
c.       contents of zzz.c followed by an infinite loop
d.      prints some data after EOF
reaches.

                                    Answer: D
6. what is the output of the following
     
    #define assert(cond) if(!(cond)) \
  (fprintf(stderr, "assertion failed: %s, file %s, line %d \n",#cond,\
 __FILE__,__LINE__), abort())

void main()
{
int i = 10;
if(i==0)           
    assert(i < 100);
else
    printf("This statement becomes else for if in assert macro");
}
a.       no output
b.      error
c.       else part is printed
d.      prints assertion failed in the file

Answer: c




7.  What  will be the output of the following code segmet

            FILE *fp1,*fp2;
fp1=fopen("one","w") ;
fp2=fopen("one","w") ;
fputc('A',fp1) ;
fputc('B',fp2) ;
fclose(fp1) ;
fclose(fp2) ;
a.       No Error, but it will over writes on same file
b.      Error in pointer declaration
c.       Runs successfully
d.      None

Answer: C

  1. Considering the code
         Char x[20];
          ----
         -----
          fgets(x,20,fp);
      printf(“%s”,x);
                  where fp points to the file which contains the data in the following format
wipro
innovation
program

 what is the output?

  1. wipro
  2. wiproinnovationprogr
  3. ram
  4. wipro\ninnovation\npro

Answer: A


  1. When file opened in mode “ab”
    1. pointer is placed at the beginning of file
    2. end of the file
    3. error in opening
    4. none of the above

Answer: b

  1. Consider the following statement
fseek(fp,50,4);
which among the following is correct

    1. moves the file pointer to beginning of file
    2. moves the file pointer to the 50th byte from beginning of file
    3. moves file pointer to the 50th byte from end of file
    4. compilation error


Answer: d

No comments:

Post a Comment