Modern Education

Interview QA – III

Interview QA - III



Ques 1. what are storage classes and their scope?

The storage classes in C are auto, Register, static, extern.

auto: Local variables are by default auto variables.
      auto variables stored in stack memory
      the scope of auto variables is local to the funtion, it exists till the 
      program control present in the function.
      It is used for local variables declaration.

Register: The scope of this variable is local to the function.
          The variable is stored in controller registers, if the registers are full then 
           the variables are converted into auto variable .
          The life is present till the program control present in the funtion where it is declared.
          It is used for loop variables, since it is stored in register accessing it is fast.

static: The scope of static variable is local to the funtion where it is declared. If the variable is
        declared global then its scope is only in the file where it is declared.
	It is stored in data memory.
	Its life is till the program running.

extern : It is used for the global variables. if we want to access the global varible declared in 
         another file we use extern storage classifier to access it.
         scope is through out the file where it is declared.
         it stores in data memory.
        

Ques 2. what are the features of c language?

The most important features of c languages are:
 - portability  - c language is platform indpendent language.
 - modularity   - the larger program can be break down into smaller programmes. 
 - flexibility  - the language is flexible to write os, compilers and embedded system programmes.
 - speed        - the c language compile and executes high speed compared with other high level languages.
 - extensibilty - the possibility to add new features to the program.



Ques 3. what are the basic data types associated with c language?
  - int - it is used to store numbers
  - float - it is for numbers with fractional part
  - char - it is used for stor
  - double - it is for double precision floating point representation.
  - void - special purpose type without any value.




Ques 4. what is structure padding and packing?

when a structure is declared integers take 4 bytes of memory,
The char came in between the integers then it also takes 4 bytes, the data stored in 1 byte remaining
bytes are garbage values stored and this is called padding.
So save the memory storage all ints and floats has to be declared serially then chars has to be declared. 

to occupy all the memory without leaving space in between then packing has to be done.
this done by declaring 
#pragma pack(1)

above main funtion.


Ques 5. what is dangling pointer?
	A pointer is declared and memory is allocated with malloc or calloc and then it is freed.
The pointer is still pointing to same memory, but memory is not reservered for it.
This type of pointer is called dangling pointer.


Ques 6. what is wild pointer in c?

If a pointer is declared but memory is not allocated. then it is pointing some memory. 
it is bad programming practice and it leads to bad programming practice. this ponter is called wild pointer.


Ques 7. what is prototype of a function?
	Prototype of a function is a declaration of a funtion with the following information to the controller.
	-- the return type of the function. 
	-- the input parameters to the funtion
        -- name of the function
	
	ex: int fun(char, float);

Ques 8. what is the differance between == and = ?
        = is an assignment.
	== is a equality checking operator it gives true or false status.


Ques 9. what is the cyclic nature of datatypes in c?
	If the value of the variable is goes beyond its range then the value change according to cyclic nature.
there is no compiler error for this. the data types int, char long supports this feature, and float and double
not supporting it.

ex:
     char ch=129;
 then ch=-127 this called cyclic in nature.
 since the range of character is -127  -- 0 -- 128.


Ques 10. what is nested loops in c?

executing loop inside another loop is called nested loops.
ex:
    for(i=0;i<5 ; i++)
    {      
      for(j=0; j<5; j++)
      {
      }
    }

Ques 11. what is break and continue statement in c?
	the on executing break statement the program control goes out of the loop or switch statement.
        on executing continue in a loop statement, the control goes to the beginning of the loop.
	
 for (i=0; i<5; i++)
  {
   if(y == 0)
      break;
   else
      z=x/y;
  if (z > 23)
   continue;
  }



Ques 12. How data is stored in stack?
	The data stored in stack is of the form FILO, first in last out. The data stored last is retreived first.
for storing we use push() operation, for retriving we use pop() function.


Ques 13. what { } indicates in c language?

	This { } curly brackets indicates the block of code start and end.
	It can be used in for , while, do while loops. it is also used in if, else, switch structures. 


Ques 14. how to generate random number in c?
 The random numbers can be generated using rand() function.

void main()
{
int a;
a=rand();
}


Ques 15. what is indirect reference in c?
 
	If a variable is declared as pointer then it is called indirect reference to the variable, 
we cannot access the variable directly. If the variable is declared then it can be accessed directly.

C Pointers 2

C Pointers 2



Ques 1. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int (*fun)();
int disp()
{
printf("\n this is display function");
}

int main()
{
fun=disp;
fun;
return 0;
}

options:
A. runtime error
B. this is display funtion
C. compiler error
D. prints some garbage string.


Ques 2. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int (*fun)();
int disp()
{
printf("\n this is display function");
}

int main()
{
fun=disp;
fun();
return 0;
}

options:
A. runtime error
B. this is display funtion
C. compiler error
D. prints some garbage string.




Ques 3. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int (*fun)(int, int, char );
int math(int x, int y, char ch)
{
if(ch == '+')
return x+y;
}

int main()
{
int ans;
fun=math;
ans = fun(22,33,'+');
printf("\n ans= %d", ans);
return 0;
}



options:
A. 0 
B. runtime error
C. compiler error
D. 55


Ques 4. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int (*fun[4])(int, int, char );
int math(int x, int y, char ch)
{
if(ch == '+')
return x+y;
else
return 0;
}

int main()
{
int ans;
fun[0]=math;
ans = fun[0](22,33,'+');
printf("\n ans = %d", ans);
return 0;
}

options:
A. 55
B. compiler error
C. 0 
D. 155


Ques 5. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
typedef int (*f)(int, int, char);
f funptr[3];

int math(int x, int y, char ch)
{
if(ch == '+')
return x+y;
else
return 0;
}

int main()
{
int ans;
funptr[0] = math;
ans = funptr[0](2,3,'+');
printf("\n ans = %d", ans);
return 0;
}

options:
A. 55
B. 5
C. 0
D. compiler error


Ques 6. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
void fun()
{
printf("\n this is fun().");
}

void math(int (*fee)())
{
fee();
}

int main()
{
math(fun);
return 0;
}

options:
A. prints garbage string.
B. run time error
C. compiler error
D. this is fun().


Ques 7. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
void fun()
{
printf("\n this is fun().");
}
void fun2();

int main()
{
fun2=fun;
fun2();
return 0;
}

options:
A. run time error
B. this is fun().
C. compiler error
D. garbage string.


Ques 8. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int main ()
{
int arr[2][4] ={{4,1,3,4},{5,8,9,11}};
printf("%d, %d", ++(*arr[0]), *arr[0]);
return 0;
}

options:
A. 4 4
B. 5 5
C. 3 3
D. compiler error


Ques 9. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int arr[2][4] ={{4,1,3,4},{5,8,9,11}};
printf("%d, %d", *(arr+1)[0], *arr[0]);
return 0;
}

options:
A. compiler error
B. 4, 1
C. 1, 4
D. 5, 4


Ques 10. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int arr[2][4] ={{4,1,3,4},{5,8,9,11}};
arr++;
printf("%d, %d", *(arr+1)[0], *arr[0]);
return 0;
}
options:
A. 4, 1
B. 2, 3
C. Compiler error
D. 5, 8


Ques 11. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int arr[8] ={4,1,3,4,5,8,9,11};
int *p=arr;

printf("%d %d", *(p+1), *(arr+1));
return 0;
}

options:
A. 1 1
B. 4 4
C. 5 5
D. compiler error


Ques 12. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int arr[2][4] ={4,1,3,4,5,8,9,11};
int *p=arr[1];

printf("%d %d", *(p+1), *(arr[0]+2));
return 0;
}

options:
A. 1, 3
B. 8, 3
C. compiler error
D. 5, 9


Ques 13. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>

int main ()
{
int arr[2][4] ={4,1,3,4,5,8,9,11};
int *p=arr[0];

printf("%d %d", *(p+1), *(p+6));
return 0;
}

options:
A. 4, 8
B. compiler error
C. 1, 9 
D. 0, 0


Ques 14. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>

int main ()
{
int arr[2][4] ={4,1,3,4,5,8,9,11};
int *p=arr[0];

printf("%d %d", ++*(p+1), ++*(p+6));
return 0;
}
options:
A. 2, 10
B. compiler error
C. 3, 11
D. 0 , 0


Ques 15. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int main ()
{
int arr[2][4] ={7,1,44,4,5,8,9,11};
int *p=arr[0];

printf("%d %d", *p, ++(*p));
return 0;
}
options:
A. 8 8
B. 7 7
C. 1 1
D. 7 1



Answers

1. C 2. B 3. D 4. A 5. B 6. D 7. C 8. B 9. D 10. C 11. A 12. B 13. C 14. D 15. A

C Datatypes Q & A

C Datatypes Q & A


Ques 1. What is the output of following program. Assume that the numbers are stored in 2's complement form.

#include<stdio.h> 
int main()
{
   int m = -2;
   int n = ~1;

   printf("0x%x 0x%x ", m, n);

   return 0;
}

options:
A. 0xfffffffe 0xfffffffe
B. compiler error
C. -2 -2
D. -2 -1


Ques 2. which is invalid in the following code declaration in C?

1. short int q;
2. signed long a
3. long e;
4. unsigned short r;

options:
A. 1 & 2 valid 
B. 3 valid
C. 4 valid
D. all valid



Ques 3. what is the output for the below code?

#include<stdio.h>
int main()
{
   float x = 15.0,z;
   z = 9/5 * x+32;
   printf("z=%0.2f",z);
   return 0;
}


options:
A. 47.00
B. 59.00
C. 32.00
D. 45.00



Ques 4. what is the output for the below code?

#include<stdio.h>
int main()
{
   char d = '2';
   char e = 022;
    printf("%d %d", d,e);
    return 0;
}

options:
A. 50 18
B. 22 22
C. Compile time error
D. run time error



Ques 5. In C, sizes of an integer and a pointer always same.

options:
A. True
B. False


Ques 6. what is the output for the below code?
int main()
{
    void *gptr, g;
    g = 0;
    gptr = &g;
    printf("%v", *gptr);
    getchar();
    return 0;
}

options:
A. 0
B. runtime error
C. 48
D. Compile time error



Ques 7. what is the output for the below code?

#include<stdio.h>
int main()
{
    char m=0;
    char ch = 125;
    ch = ch+10;
    printf("%d\n ", ch);
    return 0;
}

options:
A. -121
B. 121 
C. 135 
D. compile time error



Ques 8. what is the output ?

#include<stdio.h>
int main()
{
    int x = -1;
    printf(" %x %x\n", x, sizeof(long));
    return 0;
}

options:
A. ffffffff 4
B. -1 4
C. compiler error
D. None of the above


Ques 9. what is the output for the below code?

#include<stdio.h>
int main()
{
    float x = 0.1;

    if ( x == 0.1 )
        printf("IF");
    else if (x == 0.1f)
        printf("ELSE IF");
    else
        printf("ELSE");
}


options:
A. ELSE IF
B. ELSE
C. IF
D. error


Ques 10. what is the output for the below code?

#include<stdio.h>
int main()
{
    char t = 125;
    int i;

    for(i=0; i<5; i++)
      printf("%d ", t++);

    return 0;
}

options:
A. 125 126 127 128 129
B. 125 126 127 -128 -127
C. infinete loop
D. none of the above 



Ques 11. what is the output for the below code?

#include<stdio.h>
int main()
{
    char t = 0;
    for(t=0; t<135; t++)
      printf("\n%d", t);
    return 0;
}

options:
A. prints 0 to 135
B. infinite loop
C. error
D. runtime error


Ques 12.  Which data type is most suitable for storing a number 65000 in a 32-bit system?

options:
A. signed short
B. unsigned short
C. long
D. int



Ques 13: Which of the following is a User-defined data type?

options:
A. typedef int signedint32;
B. typedef enum {Jan, Feb, Mar, Apr, MAy} Months;
C. struct {char str[10], int age};
D. all of the mentioned


Ques 14: What is the size of an int data type?

Options:
A. 4 bytes
B. 8 bytes
C. Depends on the system /compiler
D. 2 bytes

Ques 15:  What is the output for the below program?
#include<stdio.h>
    int main()
    {
        char ch;
        int j = 0;
        FILE *file;
        file = fopen("test.txt", "w+");
        fprintf(file, "%c", 'd');
        fprintf(file, "%c", -1);
        fprintf(file, "%c", 'g');
        fclose(file);
        file = fopen("test.txt", "r");
        while ((ch = fgetc(file)) !=  -1)
            printf("%c", ch);
        return 0;
    }

options:

A. d
B. depends on what fgets returns
C. depends on compiler 
D. infinite loop


Ques 16: What is the output for the below program?
#include<stdio.h>
int main()
{
    void *gptr;
    int *g;
    gptr=(int *)malloc(4);
    g=(int* ) gptr;
    *g=43;
    *(int *)gptr=34;
    printf("%d %d", *g, *(int*)gptr);

    getchar();
    return 0;
}

options:
A. 34 34
B. 35 35
C. compiler error
D. run time error


Ques 17: What is the output for the below program?
#include<stdio.h>
int main()
{
     int x,y;
    double d;

    x=44, y=5;
    d=x/y;
    printf("%lf", d);

    return 0;
}

options:
A. 8.80000
B. 8.0000
C. compiler error
D. run time error


Ques 18: What is the output for the below program?
#include<stdio.h>

int main()
{
    float x,y;
    double d;

    x=4.0, y=5.0;
    d=x/y/x;
    printf("%lf", d);

    return 0;
}

options:
A. 0.8000
B. 3.2000
C. 0.2000
D. run time error


Ques 19: What is the output for the below program?
#include<stdio.h>

int main()
{
    unsigned int m=121;
    signed int i=225;
    char c=34;

    c=i+m;    
    printf("%d",c);
    return 0;
}
options:
A. runtime error
B. compiler error
C. 346
D. 90

Ques 20: What is the output for the below program?
#include<stdio.h>
int main()
{
    unsigned int m = 65632;
    signed short i=225;
    i = m;
    printf("%i",i);
    return 0;
}

options:
A. 65632
B. 65631 
C. 96
D. 97

Answers

1. A 2. D 3. A 4. A 5. B 6. D 7. A 8. A 9. A 10. B 11. B 12. B 13. D 14. C 15. A 16. A 17. B 18. C 19. D 20. C

Interview QA 2

Interview QA 2



Ques 1. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
#define DEBUG(x, %d) printf("DEBUG : %d", x) 
int main()
{
    int x=44;
    DEBUG(x,%d);
    return 0;
}

Explanation:
Here in DEBUG macro %d is not a variable, it gives compiler error.

Rules for naming identifiers
A valid identifier can have letters (both uppercase and lowercase letters), digits and underscores.
The first letter of an identifier should be either a letter or an underscore.
You cannot use keywords as identifiers.
There is no rule on how long an identifier can be. 
However, you may run into problems in some compilers if the identifier is longer than 31 characters.



Ques 2. what is the ouput?
#include <stdio.h>
#include <stdlib.h>
#define cube(x) x*x*x
int main()
{
    int x=2, y=4;
     y=y/cube(x) ;
     printf("%d",y);
    return 0;
}

Explanation:
after preprocessing  the statement  y=y/cube(x)
become   y=y/x*x*x;
         it evaluates as
         y= (y/x)*x*x = (4/2)*2*2= 2*2*2= 8



Ques 3. what is dirty bit?

Explanation:
 In computer dirty bit or modified bit indicates the block of memory is modified or not .
if the dirty bit is set then the block of memory is modified otherwise id not modified.
the operating system checks this bit before writing the block of memory to secondary storage
if the bit is set then the block of memory is written to secondary storage.


Ques 4. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int x=-2;
    printf("%x",x>>3);
    return 0;
}

Explanation:
-2 = fffffffe = 11111111 11111111 11111111 11111110
after  >> 3
 = ffffffff

if define the x as unsigned int
after right shift it becomes 1fffffff



Ques 5. which is efficient in switch or if else ?

Explanation:
    In if else each the condition has to be evaluated at run time,
in switch only evaluating the variable value is done at run time, 
remaining cases is fixed and it is evaluated at compile time.


Ques 6. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int ch =1, y=0;

    if(ch==1, y>ch )
    {
     printf("\n if is evaluated.");
    }
    else
    {
        printf("\n else is evaluated.");
    }

    return 0;
}

Explanation:
Here the if condition is correct in syntax,
however it will evaluate the the first condition, and it considers 
the last condition for control flow.


Ques 7. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int ch =1, y=0;

     printf("\n %d", scanf("%d %d", &ch, &ch));


    return 0;
}

Explanation:
Here the scanf funtion returns how many arguments it is reading.
The return value of scanf funtion is printed in printf funtion.


Ques 8. what are near, huge, far memory ?

Explanation:
near means the variable is stored in the current segment of 64 kb of memory
far means the variable is stored or can access within in the 128kb of memory,
here the segment register is fixed
huge means the variable is stored or can access more than 128kb of memory, 
here the segment register can change.


Ques 9. write a program for swap the bytes in the variable var1=0x4567 ?

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int var1 =0x3255;
    var1 = (var1 >> 8) | ((var1&0xff)<<8);
    printf("0x%x",var1);
    return 0;
}




Ques 10. difference between <> and "" in #include statement?

Explanation:
< > means the file is included from the library or predesignated by the compiler.
the compiler will search the included file in that directory. 
Normally this is used to include the standard header files.

" " means the the compiler searches the included header file in the current working directory.
normally it used to include the user defined header files.

Storage Classifiers

Storage Classifiers



Ques 1. what are stoagre classifiers in c?


options:
A. auto, static, register, extern 
B. auto, float, register, extern
C. char, static, register, extern
D. auto, static, register, int


Ques 2. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
void fun();
int main()
{
fun();
}

void fun()
{
    static int x=4;
  if(x-- != 0 )
  {
    fun();
    printf("%d ",x);
  }
}

options:
A.  0 0 0 0
B. -1 -1 -1 -1 
C.  4 3 2 1
D.  infinite loop


Ques 3. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
void fun();
int main()
{
fun();
}

void fun()
{
    static int x=4;
  if(x-- != 0 )
  {
    printf("%d ",x);
    fun();
  }
}

options:
A.  0 0 0 0
B. -1 -1 -1 -1 
C.  3 2 1 0
D.  infinite loo


Ques 4. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    auto int abc = 34;
    auto int * const ptr = &abc;
    *++ptr;
    printf("%d", abc);

    return 0;
}

options:
A. 34
B. 35
C. compiler error
D. run time error


Ques 5. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    auto int abc = 34;
    auto int * const ptr = &abc;
    ++*ptr;
    ++*ptr;
    --*ptr;
    printf("%d", abc);

    return 0;
}

options:
A. 34
B. 37
C. 36
D. 35


Ques 6. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    register int abc = 34;
    register int * const ptr = &abc;
    --*ptr;
    printf("%d", abc);

    return 0;
}

options:
A. 33
B. compiler error
C. 34
D. 35342


Ques 7. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    register int abc = 3;

    for(abc=3; ;)
    printf("%d", abc);

    return 0;
}

options:
A. infinite loop 
B. 3 3 3
C. compiler error
D. runtime error


Ques 8. what is the output for the below code?
int abc;
int main()
{
    int abc = 3;
    printf("%d\n ",abc);
    return 0;
}

options:
A. 0
B. 3
C. compiler error
D. runtime error


Ques 9. what is the output for the below code?
typedef static int abc ;

abc si=3;
int main()
{
    si++;
    printf("%d\n ",si);
    return 0;
}

options:
A. 4
B. runtime error
C. compiler error 
D. 3


Ques 10. what is the output for the below code?

typedef int abc ;

abc si=3;
int main()
{
    si++;
    si++;
    --si;
    printf("%d\n ",si);
    return 0;
}

options:
A. 6 
B. 5
C. 3
D. 4


Ques 11. what is the output for the below code?
int gi =332;
extern int gi ;

int main()
{
    printf("%d\n ",gi);
    return 0;
}

options:
A. 332
B. 0
C. compiler error
D. runtime error


Ques 12. what is the output for the below code?
volatile const int v =332;
int main()
{
    v += 4;
    printf("%d\n ",v);
    return 0;
}

options:
A. 336
B. compiler error
C. 332
D. runtime error


Ques 13. what is the output for the below code?
volatile int v =332;
int main()
{
    v += 4;
    printf("%d\n ",v);
    return 0;
}

options:
A. compiler error
B. 332
C. 336
D. runtime error


Ques 14. what is the output for the below code?
volatile int v =332;
int main()
{
    static int i=3;
    printf("%d ",v);

    {
     auto int p=89;
     i++;
     printf(" %d ", p);
    }
    {
        register int s=5;
        printf(" %d %d",s, i);
    }

    return 0;
}

options:
A. compiler error
B. run time error
C. 332 89 5 4
D. 332 89 5 3


Ques 15. what is the output for the below code?
volatile int v =32;
void fun();
int main()
{
    static int i=3;
    printf("%d ",v);

    {
     auto int p=89;
     i++;
     printf(" %d ", p);
    }
    {
        register int s=5;
        printf(" %d %d",s, i);
    }
fun();
    return 0;
}

void fun()
{
    v++;
 printf(" %d", v);
}

options:
A. 32 89 5 4 33
B. compiler error
C. run time error
D. 32 89 5 3 32


Answers

1. A 2. B 3. C 4. C 5. D 6. B 7. A 8. B 9. C 10. D 11. A 12. B 13. C 14. C 15. A

Dynamic Memory Allocation QA

Dynamic Memory Allocation QA



Ques 1. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char *s;
    s=malloc(26);
    strcpy(s, "ptinstitute.in");
    printf("%s\n",s);
    return 0;
}

options:
A. ptinstitute.in
B. 0
C.compiler error
D. runtime error


Ques 2. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    char *s;
    s=malloc(26);
    strcpy(s, "good morning");
    free(s);
    printf("%s\n",s);
    return 0;
}
options:
A. good morning
B. garbage string
C. comipler error
D. rutime error


Ques 3. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    char *s;
    s=malloc(26);
    s=NULL;
    strcpy(s,"good");
    printf("%s\n",s);
    return 0;
}

options:
A. runtime error
B. good
C. 0
D. compiler error


Ques 4. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    char *s;
    s='g';
    printf("%s\n",s);
    return 0;
}

options:
A. compiler error
B. 0
C. g
D. run time error


Ques 5. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int *foo(void)
{
    int x=22;
    return &x;
}

int main()
{
    int *w;
    *w=foo() ;
    printf("\n %d", *w);
    return 0;
}


options:
A. 0
B. 22
C. run time error
D. garbage value


Ques 6. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int foo(int *s)
{
    int *x=s;
    return *x;
}

int main()
{
    int w[1]={23};
    w[0]=foo(w) ;
    printf("\n %d", *w);
    return 0;
}


options:
A. run time error
B. 23
C. 0
D. garbage value


Ques 7. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int* foo(int *s)
{
    int *x=s;
    x++;
    return x;
}

int main()
{
    int w[4]={56,3,44,5};
    int *p;
    p=foo(&w[0]) ;
    printf("\n %d", *p);
    return 0;
}

options:
A. 44
B. 56
C. 3
D. run time error


Ques 8. what is the output for the below code?
int * foo(int *s)
{
    s=(int *)malloc(4);
    return s;
}

int main()
{
    int *p;
     p= foo(p);
    *p=283;
    printf("\n %d", *p);
    return 0;
}

options:
A. 283
B. 284
C. run time error
D. compiler error 


Ques 9. what is the output for the below code?
int main()
{
    int *p;
     p= (int *)malloc(4);
    *p=283;
    ++*p;

    printf("\n %d", *p++);
    return 0;
}


options:
A. 281 
B. 283
C. 285
D. 284


Ques 10. what is the output for the below code?
int main()
{
    int  *q;

     q=calloc(12,1);
    *q=54;
    *(++q)=78;

    printf("\n %d %d", *(--q), *(q));
    return 0;
}

options:
A. run time error
B. 54 78
C. 55 79
D. 53 77


Ques 11. what is the output for the below code?
int main()
{
    int  *q[2];

     q[0]=calloc(4,2);
     q[1]=calloc(4,2);
    **q=54;
    *q[1]=58;
     ++(*q[1]);

    printf("\n %d %d",  **q, *q[1]);
    return 0;
}

options:
A. 55 58
B. 54 58
C. 54 59
D. run time error


Ques 12. what is the output for the below code?
int main()
{
    int  *q[2];

     q[0]=(int *)calloc(4,2);
     q[0]=(int *)realloc(q[0], 20);

    **q=54;
    ++**q;
    *(q[0]+3) = 78;
    --(*(q[0]+3));

    printf("\n %d %d",  **q, *(*q +3));
    return 0;
}


options:
A. 54 78
B. 55 77
C. 54 78
D. run time error


Ques 13. what is the output for the below code?
int main()
{
    int  ****p;
    int  ***q;
    int  **r;
    int  *s;

   s=(int *)malloc(4);
   r=&s;
   q=&r;
   p=&q;

   *s=47;

    printf("\n %d %d %d %d",  *s, **r, ***q, ****p);
    return 0;
}


options:
A. run time error
B. 47 46 47 0
C. 46 45 0 0
D. 47 47 47 47


Ques 14. what is the output for the below code?
int main()
{
    int  ****p;
    int  ***q;
    int  **r;
    int  *s;

   s=(int *)malloc(4);
   r=&s;
   q=&r;
   p=&q;

   *s=47;
   ++**r;
   ++***q;
   ++****p;

    printf("\n %d %d %d %d",  *s, **r, ***q, ****p);
    return 0;
}

options:
A.47 47 48 47 
B.50 50 50 50
C. 47 46 50 47
D. 47 48 49 59


Ques 15. what is the output for the below code?
int main()
{
    int  *s;
    s=(int *)calloc(4, 5);
    *s=45;
    s++;
    *s=56;
    *s=++(*s);

    printf("\n %d %d ",  *s, *(s-1));
    return 0;
}
options:
A. 45 57
B. 56 45
C. 57 45
D. 45 56


Ques 16. what is the output for the below code?
int main()
{
    int  *s;
    s=(int *)calloc(4, 2);
    s=realloc(s, sizeof(int)*4);
    *s=45;
    s++;
    *s=56;
    *s=++(*s);
    *(++s) =78;
    *(++s) =97;

    printf("\n %d %d %d %d",  *s, *(s-1), *(s-2), *(s-3));
    return 0;
}

options:
A. 57 97 45 57
B. 78 97 45 57
C. 97 78 57 45
D. 45 57 78 97


Ques 17. what is the output for the below code?
int main()
{
    int  *s[1];
    *s = (int *)malloc(4);
    *s = realloc(*s, sizeof(int)*3);
    **s = 45;
    ++(*s);
    **s=56;
    *(++(*s)) =78;
    *(++(*s)) =97;

    printf("\n %d %d %d %d",  **s, *(*s-1), *(*s-2), *(*s-3));
    return 0;
}
options:
A. 45 56 78 97 
B. 97 78 56 45
C. 45 56 97 78
D. 56 45 78 97


Answers

1. A 2. B 3. A 4. D 5. C 6. B 7. C 8. A 9. D 10. B 11. C 12. B 13. D 14. B 15. C 16. C 17. B

Advanced Pointers

Advanced Pointers



Ques 1. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int * add(int *p, int *q)
{
 int sum;
  sum=*p+*q;
  return ∑
}

int main()
{
  int r = 20, s=3;
  int *sum;
  int *p = &r, *q=&s;

  sum=add(p, q);

  printf("%d ", *sum);
  return 0;
}

options:
A. runtime error
B. 23
C. 0
D. compiler error



Ques 2. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>

int * add(int *p, int *q)
{
 int *sum =(int*)malloc(4);
  *sum=*p+*q;
  return sum;
}

int main()
{
  int r = 20, s=3;
  int *sum;
  int *p = &r, *q=&s;

  sum=add(p, q);

  printf("%d ", *sum);
  return 0;
}

options:
A. compiler error
B. runtime error
C. 23
D. 0


Ques 3. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>

void swap(int *p, int *q)
{
 int t;
 t=*p;
 *p=*q;
 *q=t;
}

int main()
{
  int r = 20, s=3;
  int *p = &r, *q=&s;

  swap(p, q);

  printf("*p=%d *q=%d", *p, *q);
  return 0;
}

options:
A. *p=20 *q=3
B. runtime error
C. *p=3 *q=20
D. compiler error


Ques 4. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
void swap(int *p, int *q)
{
 int t;
 t=p;
 p=q;
 q=t;
}

int main()
{
  int r = 20, s=3;
  int *p = &r, *q=&s;

  swap(p, q);

  printf("*p=%d *q=%d", *p, *q);
  return 0;
}

options:
A. compiler error
B. *p=20 *q=3
C. *p=3 *q=20
D. run time error


Ques 5. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int r = 20, s=3;
  int *p = r, *q = s;

  printf("*p=%d *q=%d", *p, *q);
  return 0;
}

options:
A. 3, 20
B. 20, 3
C. compiler error
D. runtime error


Ques 6. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
   int (*q)[5];
   printf("%d",  sizeof(*q));
   return 0;
}

options:
A. compiler eror
B. 4
C. 20
D. runtime error


Ques 7. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{

   int (**q)[4] ={3,4,5,6,7,6};
   printf("%d",  sizeof(**q));
   return 0;
}

options:
A. 4
B. 16
C. 24
D. runtime error



Ques 8. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int main()
{
   int q[2][3][2] ={3,4,5,6,7,6};
   printf("%d",  sizeof(q));
   return 0;
}

options:
A. 20
B. 24
C. 4
D. 48


Ques 9. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int main()
{

   int q[6] ={3,4,5,6,7,6};
   int *r=(q+1);
   printf("%d %d",  *(r+2), *r++);
   return 0;
}

options:
A.
B.
C.
D.


Ques 10. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int main()
{

   int q[6] ={3,4,5,6,7,6};
   int *r=(q+1);

   printf("%d %d",  *(r+2), *r++);
   return 0;
}

options:
A. 7, 4
B. 6, 4
C. 5, 4
D. 5, 6


Ques 11. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int main()
{

   int p =32;
   int *q=&p;
   int **r=&q;

   printf("%d %d",  **r, *q);
   return 0;
}

options:
A. 32 32
B. 0 0
C. grabage value
D. runtime error



Ques 12. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int main()
{

   int p =32;
   int *q=&p;
   int **r=q;

   printf("%d %d",  **r, *q);
   return 0;
}

options:
A. 32 32
B. 0 0
C. grabage value
D. runtime error



Ques 13. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int main()
{

   char *p[] ={"welcome", "good", "test", "computer", "ptinstitute.in" };
   int **q[]={ p+1, p+2, p+3};
   int ***r=q;

   printf("%s %s",  **r, **(r+1));
   return 0;
}

options:
A. good test
B. welcome good
C. welcome test
D. test good


Ques 14. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int main()
{
   char *p[] ={"welcome", "good", "test", "computer", "ptinstitute.in" };
   int **q[]={ p+1, p+4, p+3};
   int ***r=q;
   r++;
   printf("%s %s",  **r, **(r+1));

   return 0;
}

options:
A. computer ptinstitute.in
B. ptinstitute.in computer
C. welcome good
D. runtime error



Ques 15. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int main()
{
   char *p[] ={"welcome", "good", "test", "computer", "ptinstitute.in" };
   int **q[]={ p+1, p+4, p+3};

   printf("%s %s",  ++(*p), *(p+2));

   return 0;
}

options:
A. good test
B. welcome test
C. elcome test
D. ood test


Ques 16. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>

int main()
{
   char *p[] ={"welcome", "good", "test", "computer", "ptinstitute.in" };
   int **q[]={ p+1, p+4, p+3};

   printf("%s %s",  **q, **(q+2));

   return 0;
}

options:
A. test computer
B. welcome test
C. welcome good
D. good computer


Ques 17. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>

int main()
{
   char *p[] ={"welcome", "good", "test", "computer", "ptinstitute.in" };
   int **q[]={ p+1, p+4, p+3};

   printf("%s %s",  *(*q++), **(q+2));

   return 0;
}
options:
A. compiler error
B. runtime error
C. welcome good
D. good test


Ques 18. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>

int main()
{
   char *p[] ={"welcome", "good", "test", "computer", "ptinstitute.in" };
   int **q[]={ p+1, p+4, p+3};

   printf("%s %s",  *(*q)++, **(q+2));

   return 0;
}
options:
A. compiler error
B. runtime error
C. welcome good
D. good computer


Ques 19. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>

int main()
{
   char *p[] ={"welcome", "good", "test", "computer", "ptinstitute.in" };
   int **q[]={ p+1, p+4, p+3};
p[1]= p[1] + 2;
p[3]= p[0] + 4;
   printf("%s %s",  *(*q)++, **(q+2));

   return 0;
}

options:
A. od mputer 
B. runtime error
C. welcome good
D. od ome



Ques 20. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>

void fun( char *p)
{
    printf("\n %s", ++p);

}
int main()
{
   char *p[] ={"welcome", "good", "test", "computer", "ptinstitute.in" };
   fun(p[2]);
   return 0;
}


options:
A. est 
B. runtime error
C. compiler error
D. test



Answers

1. A 2. C 3. C 4. B 5. D 6. C 7. B 8. D 9. C 10. A 11. A 12. D 13. A 14. B 15. C 16. D 17. A 18. D 19. D 20. A

C Operator Q&A

C operators Q & A


Ques 1. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int m,n,p;

    m=(1,2,3);
    p =1,2,3;

    printf("i = %d\n",m+p);
    return 0;
}

options:
A. 4
B. 2
C. 6
D. compile time error



Ques 2. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int x=2,y=2,z=1,k=4, h=3;

    z+=x==y=k==h;

    printf("Hello world! %d\n",z);
    return 0;
}

options:
A. 2
B. compiler error lvalue required 
C. 3
D. 4


Ques 3. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int x=2,y=2,z=1,k=4, h=3;

    z+=x==(y=k==h);

    printf("%d\n",z);
    return 0;
}

options:
A. 2
B. 0
C. 1
D. compiler error


Ques 4. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int xyz=2,3,4;

    xyz+=5;
    printf("%d\n",xyz);
    return 0;
}

options:
A. 9
B. 8
C. 7
D. compiler error


Ques 5. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int xyz=(2,3,4);

    xyz+=5;
    printf("%d\n",xyz);
    return 0;
}

options:
A. 7
B. 9
C. 8
D. compiler error


Ques 6. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int mn=5;
    ++mn++;

    printf("%d\n",mn);
    return 0;
}

options:
A. 6
B. compiler error
C. 7
D. 8


Ques 7. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int xyz;
    xyz=2,3,4;

    xyz+=5;
    printf("%d\n",xyz);
    return 0;
}

options:
A. 9
B. 8
C. 7
D. compiler error


Ques 8. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int mn=5;
    ++mn;

    printf("%d\n",mn++);
    return 0;
}

options:
A. 8
B. 7
C. 6
D. compiler error


Ques 9. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int mn=5,y,z,s;
    mn = (y=mn++) + (z=mn++) + (s=++mn);

    printf("%d\n",mn++);
    return 0;
}

options:
A. 19
B. 21
C. 22
D. compiler error


Ques 10. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int mn=5;
    mn = mn++ + mn-- + --mn;

    printf("%d\n",mn++);
    return 0;
}

options:
A. 16 
B. 14
C. 15
D. compiler error



Ques 11. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int mn=5, y=3;

    printf("%d\n",mn>y? 22:44);
    return 0;
}
options:
A. 44
B. 22
C. 5
D. 3



Ques 12. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>

int fun(int *m, int *n)
{
    int sub = *m-*n;
    *m=*n;
    return *m+*n;

}
int main()
{
    int *a,*b;
    int x=22,y=3;

    a=&x; b=&y;

    printf("%d\n",fun(a,b));
    return 0;
}

options:
A. 6
B. compiler error
C. 22
D. 8



Ques 13. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>

int fun(int *m, int *n)
{
    int sub = *m-*n;
    *m=*n;
    return *m+*n;

}
int main()
{
    int *a,*b;
    a=(int *)malloc(4);
    b=a;

    *a=3; *b=5;

    printf("%d\n",fun(a,b));
    return 0;
}
options:
A. 8
B. 10
C. 13
D. compiler error


Ques 14. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>

void fun(int **m, int **n)
{
    int t = *m;
    *m=*n;
    *n=t;
}
int main()
{
    int *a,*b;
    a=(int *)malloc(4);
    b=a;

    *a=3; *b=5;
    fun(&a,&b);

    printf("%d %d\n",*a, *b);
    return 0;
}

options:
A. 3 5
B. 5 3
C. 5 5
D. compiler error


Ques 15. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>

void fun(int **m, int **n)
{
    int t = *m;
    *m=*n;
    *n=t;
}
int main()
{
    int *a,*b;
    a=(int *)malloc(sizeof(int)*2);
    b=a;

    *a=3; *b=5;
    *a = *b && fun(&a,&b);

    printf("%d %d\n",*a, *b);
    return 0;
}

options:
A. compiler error
B. 1 5
C. 5 5
D. 5 1


Ques 16. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>

int fun(int **m, int **n)
{
    int t = *m;
    *m=*n;
    *n=t;
    return *m=*n;
}

int main()
{
    int *a,*b;
    a=(int *)malloc(sizeof(int)*2);
    b=a;

    *a=3; *b=5;
    *a = *b && fun(&a,&b);

    printf("%d %d\n",*a, *b);
    return 0;
}

options:
A. compiler error
B. 1 1
C. 5 5
D. 3 3 


Ques 17. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b;

    a=3; b=5;
    b = sizeof( a *= b+5);

    printf("%d %d\n",a, b);
    return 0;
}

options:
A. 3 5
B. 3 20
C. 3 4
D. compiler error

Ques 18. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c, d;
    a = 5; b=4; d=7;

    c=a & b | d;

    printf("%d \n", c);
    return 0;
}

options:
A. 7
B. 5
C. 4
D. compiler error



Ques 19. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c, d, e=6;
    a = 5; b=4; d=7;

    c=a & b | d ^ e;

    printf("%d \n", c);
    return 0;
}

options:
A. 4
B. 7
C. 5
D. compiler error

Ques 20. what is the output for the below code?

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c, d, e=2;
    a = 5; b=4; d=7;

    c=a >> b | d << e;

    printf("%d \n", c);
    return 0;
}

options:
A. 22
B. 28
C. 7
D. compiler error




Answers

1. A 2. B 3. C 4. D 5. B 6. B 7. C 8. C 9. A 10. C 11. B 12. A 13. B 14. C 15. A 16. B 17. C 18. A 19. C 20. B

Misc QA

MiSC QA



Ques 1. what is token? 

A. each and every units in c program are called tokens .
B. only variables
C. only constants
D. only function names


Ques 2. what are different types of token?




Ques 3. count number of tokens in the below code statement?

scanf("%d", &x);
options:
A. 7
B. 3
C. 6
D. 5


Ques 4. what type of language is c?

options:
A. it is high level language
B. it is low level language
C. it is a high level language with support to low level programming
D. it is super high language



Ques 5. if character size is 1 byte predict the output?

#include <stdio.h>
#include <stdlib.h>
char printchar()
{
  putchar('D');
  return 'D';
}
int main()
{
    printf("%d", sizeof(printchar()));

    return 0;
}

options:
A. 1
B. D 1
C. 1 D
D. compiler error


Ques 6. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int arr[][4] = {1,2,3,4,5,6,7,8} ;
int (*p)[4] = arr;

printf("%d, %d ", *((*p)+1), *((*p)+2));
++p;
printf("%d, %d ", (*p)[1], (*p)[2] );

    return 0;
}

options:
A. 2,3, 6,7
B. 1,2,3,4
C. 5,6,7,8
D. 1,2,5,6 


Ques 7. what is the answer for the for loop line in the below code?
#include <stdio.h>
#include <stdlib.h>

main()
{
 int index;
for(index=0, index<5, index++);
}

options:
A. lexical error
B. only syntax error
C. No compiler error
D. both lexical and syntax error


Ques 8. In C program when the macro defined is resolved?

options:
A. preprocessing time
B. compiling time
C. during linking
D. run time


Ques 9. In C program two files f1 and f2 are present, a funtion present in f2 is called in file f1.
when this is resolved?

options:
A. preprocessing time
B. compiling time
C. during linking
D. run time



Ques 10. In C program a variables declared defined, when this is resolved?

options:
A. preprocessing time
B. compiling time
C. during linking
D. run time


Ques 11. for the below code what is the right way of accessing the data?

int x,y,z;
int *mdn[4], xrg[2][3];

options:
A. mdn[1] = &x, xrg[1]=34
B. mdn[1] = &x, xrg[1][0]=34
C. mdn[4] = &x, xrg[3]=34
D. mdn[1] = &x, xrg[4]=34


Ques 12. what is the option correct for c language?

options:
A. it case insensitive language
B. a regular language
C. it case sensitive language
D. low level language


Ques 13. how the c language processing happen?

options:
A. preprocessing, compilation, linking
B. compilation, preprocessing, linking
C. linking, compilation, preprocessing
D. linking , preprocessing, compilation


Ques 14. what is the command for getting preprocessed file in linux?

options:
A. gcc -k filename.c
B. gcc -E filename.c
C. gcc -l filename.c
D. gcc -p filename.c


Ques 15. what is the command for getting object code file in linux?

options:
A. gcc -S filename.c
B. gcc -E filename.c
C. gcc -o filename.c
D. gcc -c filename.c


Ques 16. what is the command for getting assembly code file in linux?

options:
A. gcc -S filename.c
B. gcc -E filename.c
C. gcc -o filename.c
D. gcc -c filename.c


Ques 17. what is the command for getting outputfile after linking files in linux?

options:
A. gcc -S filename.c
B. gcc -E filename.c
C. gcc -o filename.c
D. gcc -c filename.c


Ques 18. what is the output for the following program?

#include <stdio.h>
#include <stdlib.h>

int disp(int m, int n)
{
    int p=m+n;
    printf("\n m = %d", m);
    return p;
}
int main()
{
    int p=3,q=4, k;
   int (*f)(int, int);
    f=disp;
    k=f(p,q);
printf("\n k= %d",k);
    return 0;
}

options:
A. 3 7
B. compiler error
C. runtime error 
D. 7 7 


Ques 19. what is the output for the following program?

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int p=0x55 ;
    p = 0xb>>1<<2;
    printf("\n p= %x",p);
    return 0;

}

options:
A. a8
B. compiler error
C. runtime error 
D. 14 


Ques 20. what is the output for the following program?

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int p=0x55 ;

     p = (p & 0xff) & (~(1<<2)) ;

     printf("\n p= %x",p);

    return 0;
}


options:
A. 51
B. 54
C. 58
D. 55 



Answers

1. A 2. the different types of tokens are Keywords (ex. int float while, case), Identifiers(ex. main, sum, total), Contants(ex, 44,67) strings (ex: "sum", "welcome", "ptinstitute.in" ) Special symbols (ex: (), {}) Operators (ex: +,-,/, *) 3. 7 4. C 5. 1 6. A 7. B 8. A 9. C 10. B 11. B 12. C 13. A 14. B 15. C 16. A 17. C 18. A 19. D 20. A

Interview Q & A

Interview QA



1. What is Recursion ? 
	A function calling to itself is called recursion. 
Some time stack may overflow if we are not properly exit the recursion function.
stack may overflow if the recursion function calling chain goes very long.
so the runtime error will occur.

ex:
main()
{
int sum;
sum=add(a,b);

}

add(int a, b)
{
int sum=0;
sum = a+b;
if (a>100)
return sum;

add();

}



2. What is stack overflow.?
	stack going outside its maximum range is called stack overflow.
say if stack size 1000 bytes, if the program is writing after 1000 bytes
memory reservered for stack is called stack overflow.
due to this runtime error will occur.



3. what is itoa() function?

  itoa() converts integer to character.

Ex: 
int x=222 
char buf[20]
iota(x,buf, 10); //decimal number to string
iota(x,buf, 2); //binary number to string
iota(x,buf, 16); //hexadecimal number to string


	
4. what is atoi() function?
  atoi function converts string to integer.

ex:
char str="32322";
num=atoi(str);



5. write your own funtion itoa(), atoi() ?



6. what is bigendian?

  	The  data present in the variable, if it stores Higher byte first in memory is called bigendian.
ex: var =0x44556677 

in memory it stores first 44 then --55 --66 --77
ex: 0xffff0000 = 44
    0xffff0001 = 55
    0xffff0002 = 66
    0xffff0003 = 77 



7. what is little endian?

  	The  data present in the variable, if it stores Lower byte first in memory is called little endian.
ex: var =0x44556677 

in memory it stores first 77 then --66 --55 --44

ex: 0xffff0000 = 77
    0xffff0001 = 66
    0xffff0002 = 55
    0xffff0003 = 44 



8. What is memory leak?
   If the memory is allocated using malloc, calloc etc after using it has to be freeed
if that memory is not used more.

if that memory is not freeed then it is called memory leakage.



9. Segmentation fault?
It is caused by the program writing and reading memory in illegal memory location is called segmentation fault.
say a read only location, or writing the non existing array element.
it causes the runtime error.



10. Dangling pointer?
   If a pointer is allocated a memory then after using it is deallocated. 
The pointer still pointing to the same meory location, but it is unreserved for it now.
if this pointer is accessed then unpredictable behavior accours, this is called dangling pointer .
it causes runtime error.



11. what is token?

each word say keyword, symbols, variables, ; , etc in a c program is called token.
there are 6 types of token
 
  - keywords  ex: int, float, switch, case, if, else etc
  - operators ex: +, -, *, /, %, |, &, ^, || etc
  - strings  ex: "sum = %d, avg= %f", "total = " 
  - Identifiers(ex. main, sum, total), 
  - Contants(ex, 44,67)
  - Special symbols (ex: (), {})



12. what is forward reference?

    Refering to the label before its declaration is called forward reference.


goto SUM;

SUM:
 ------
 -----

En-Query

Your Name*
Subject*
Phone Number*
Email Address*

Message*