+44(0) 1234 567 890 info@domainname.com

Thursday, 10 July 2014

Interviwew Quction OF C

11:31

Share it Please


Interviwew Quction OF  C from Varibale
1)    void  sol(void *p);
int i;
int main()
{
                        void *ptr;
ptr = &i;
           sol(ptr);
    return 0
}
void sol(void *p)
{
                           int **q;
                        q = (int**)&p;
                         printf("%d\n", **q);
}
A)    0     B)  garbage   Value  C) Compiler  error  D) Run time  Error

Ans. A) 0
Because  The  Global Varible and Static variabel By Defult value  0 




Interviwew Quction OF  C from Loop

How many times the following loop be executed
{
...
ch = ‘b’;
while(ch >= ‘a’ && ch <= ‘z’)
ch++; }
(A)
0
(B)
25
(C)
26
(D)
1

 Ans: 25
 Because  The   asci value difference  a and  z is 25


 Interviwew Quction OF  C from  IF – switch For

What are the various types of control structures in programming?

- Mainly there are 3 types of control structures in programming: Sequence, Selection and Repetition.
- Sequential control follows a top- down flow in executing a program. This means that step 1 is first executed, followed by step 2 and so on.
- Selection means dealing with conditional statements. This means that the code is executed depending on the evaluation of conditions a TRUE or FALSE. It means that not all codes may be executed and there are alternative flows within.
- Repetitions are also called as loop structures. They will repeat one or two program statements as set by a counter.



Interviwew Quction OF  C from  Union
------------------------------
#include<stdio.h>
main()
{
    union d
      {
            unsigned int a:1;
            unsigned int b:2;

             unsigned int d:1;
     
      };
      union d aa;
      aa.a=1;
      aa.b=5;
      printf("d.aa.a=%d d.aa.b=%d",aa.a,aa.b);
      return 0;
}
A)   1  b)5  c)error d)Garbage value

Ans  A)1
Bit-field value of b is  2 so it is consider 2 bit value only..
5 binary =101 so take 2bit  01. so 01 convert into integer 1.

Interviwew Quction OF  C from  Array
-------------
In C, if you pass an array as an argument to a function, what actually gets passed?

A)Value of elements in array
B)First element of the array
C)Base address of the array
D)Address of the last element of array

           Ans..C)Base address of the array


#include<stdio.h>
int fn(void);
void print(int, int (*)());
int i=10;
void main(void)
{
    int i=20;
    print(i,fn);
}
void print(int i,int (*fn1)())
{
            printf("%d\n",(*fn1)());
}
int fn(void)
{
            return(i-=5);
}

A)5     B)10   C) Address  D) error
Ans)  A.5
Beause the fuction return value 5.


Interviwew Quction OF  C from Operator
#include<stdio.h>
int main()
{
    int i=4;
    int j=i^6;
            printf("\n%d",j);
}

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


Beause the operator  ^(xor ) make  xor between 4 nad 6.
100 ^110=010 so integer value2
















0 comments:

Post a Comment