Advertisements

Search results for int

Example:[1]

            Is the following function my_func reentrant?
int func(int x)
{
	return x * 5;
}
int my_func()
{
	return func() * 5;
}
          
Option A:

            Yes
            
Option B:

            No
            
Option C:

            Can't say, compiler dependent
            
Option D:

            Compilation error
            
Correct Answer: option A
Example:[2]

            Is the following function my_func reentrant?
int var;
int func()
{
	return var * 5;
}
int my_func()
{
	return func() * 5;
}
          
Option A:

            Yes
            
Option B:

            No
            
Option C:

            Can't say, compiler dependent
            
Option D:

            Compilation error
            
Correct Answer: option B
Example:[3]

            Is the following function my_func reentrant?
int my_func(int var)
{
	return var * 5;
}
          
Option A:

            Yes
            
Option B:

            No
            
Option C:

            Can't say, compiler dependent
            
Option D:

            Compilation error
            
Correct Answer: option A
Example:[4]

            What is the warning/error in the following program?
#include <stdio.h>
int Sum(int );
void main()
{
	int n1 =20,n2 =30,res;
	res = Sum(n1,n2);
	printf("The sum:%d\n", res);
}
int Sum(int a,int b)
{
	return a + b;
}
          
Option A:

            error: too many arguments to function Sum
            
Option B:

            warning:  implicit declaration of function Sum
            
Option C:

            warning: return with a value, in function returning void
            
Option D:

            error: a,b undeclared inside function Sum
            
Correct Answer: option A
Example:[5]

            What is the error/warning in the following program?
#include <stdio.h>
int Sum(int ,int );
void main()
{
	int n1 =20,n2 =30,res;
	res = Sum(n1,n2);
	printf("The sum:%d\n", res);
}
int Sum(int a,int b)
{
	return a + b + n1;
}
          
Option A:

            warning:  implicit declaration of function Sum 
            
Option B:

            error: n1 undeclared inside function Sum
            
Option C:

            error: conflicting types for Sum
            
Option D:

            All of the above
            
Correct Answer: option B
Example:[6]

            What is the error/warning in the following program?
#include <stdio.h>
void Sum(int ,int );
void main()
{
	int n1 =20,n2 =30;
	Sum(n1,n2);
}
int Sum(int a,int b)
{
	printf("Sum is %d\n", a+b);
}
          
Option A:

            warning:  implicit declaration of function Sum
            
Option B:

            warning: return with a value, in function returning void
            
Option C:

            error: conflicting types for Sum
            
Option D:

            All of the above
            
Correct Answer: option C
Example:[7]

            What is wrong in the following program?
#include <stdio.h>
void main()
{
	int n1 =20,n2 =30;
	Add(n1,n2);
}
void Add(int a,int b)
{
	printf("Sum is %d\n", a+b);
}

          
Option A:

            No warning
            
Option B:

            error: conflicting types for Add
            
Option C:

            implicit declaration of function Add
            
Option D:

            All of the above.
            
Correct Answer: option C
Example:[8]

            What is reentrant function in embedded systems?
          
Option A:

            A reentrant function is one that can be used by more than one task concurrently without fear of data corruption.
            
Option B:

            A reentrant function can be interrupted at any time and resumed at a later time without loss of data.
            
Option C:

            Reentrant functions either use local variables or protect their data when global variables are used
            
Option D:

            All of the above
            
Correct Answer: option D
Example:[9]

            What is a void function?
          
Option A:

            A function that returns a pointer to any datatype.
            
Option B:

            A function that does not return anything.
            
Option C:

            A function that returns an integer datatype.
            
Option D:

            A function that does not take any datatype as its argument.
            
Correct Answer: option B
Example:[10]

            In the following c program identify the inbuilt function and user defined function?
#include <stdio.h>
#include <math.h>
int square(int );
void main()
{
	printf("The square of 5 is: %d and square root of 25 is %.2f\n",square(5), sqrt(25));
}
int square(int a)
{
	return a * a;
}
          
Option A:

            square is user defined function and sqrt is inbuilt function.
            
Option B:

            sqrt is user defined function and square is inbuilt function.
            
Option C:

            Both square and sqrt are inbuilt functions.
            
Option D:

            Both square and sqrt are user defined functions.
            
Correct Answer: option A
Example:[11]

            What is the output of the following program?
#include <stdio.h>
int func(unsigned int );
void main( void )
{
	unsigned int num = 5;
	int res;
	res = func(num);
	printf("The result is:%d\n", res);
}
int func(unsigned int i)
{
	if(i <= 1)
	{
		return 1;		
	}else
	{
		return i * func(i-1);
	}
}
          
Option A:

            240
            
Option B:

            60
            
Option C:

            120
            
Option D:

            10
            
Correct Answer: option C
Example:[12]

            What is the output of the following program?
#include <stdio.h>
int func(int );
void main()
{
  int d = 1,res;
  res = func(d);
  printf("%d\n", res);
} 
int func(int x)
{
  do
  {
    res += x;
    x++;  
  }while(x <= 5);
  return res;
}

          
Option A:

            16
            
Option B:

            13
            
Option C:

            15
            
Option D:

            Compile error
            
Correct Answer: option D
Example:[13]

            What is the output of the following program?
#include <stdio.h>
int func1()
{
  int x = 0;
  x++;
  return x;
}
int func2()
{
  static int y = 0;
  y++;
  return y;
}
void main()
{
  int count = 0,r1,r2;
  for(count = 0; count < 4; count++)
  {
    r1 = func1();
    r2 = func2();
  }
  printf("r1 is:%d,r2 is:%d\n", r1,r2);
}

          
Option A:

            r1 is:1,r2 is:1
            
Option B:

            r1 is:4,r2 is:4
            
Option C:

            r1 is:2,r2 is:2
            
Option D:

            r1 is:1,r2 is:4
            
Correct Answer: option D
Example:[14]

            What is the output of the following c program?
#include <stdio.h>
void main()
{
    register int i = 10;
    int *p = &i;
    *p = 11;
    printf("%d %d\n", i, *p);
}

          
Option A:

            11,11
            
Option B:

            10,11
            
Option C:

            10,10
            
Option D:

            Compile error
            
Correct Answer: option D
Example:[15]

            What is true about the following program segment
#include <stdio.h>
int var2;
void main()
{
    int var1;
}
          
Option A:

            var1 is a local variable, var2 is a global variable
            
Option B:

            var2 is a local variable, var1 is a global variable
            
Option C:

            var1,var2 are local variables
            
Option D:

            var1,var2 are global variables
            
Correct Answer: option A
Example:[16]

            What is the output of the following c program?
#include <stdio.h> 
void main() 
{ 
    int i = 10; 
    register int *a = &i; 
    *a = 11;
    printf("%d,%d",i, *a);  
} 
          
Option A:

            10,10
            
Option B:

            11,11
            
Option C:

            11,10
            
Option D:

            10,11
            
Correct Answer: option B
Example:[17]

            What is the output of the following c program?
#include <stdio.h>
register int var2 = 10;
void main()
{
    int var1 = 10;
    var1++;
    var2++;
    printf("%d,%d\n", var1,var2);
}
          
Option A:

            10,10
            
Option B:

            11,11
            
Option C:

            11,10
            
Option D:

            Compile error
            
Correct Answer: option D
Example:[18]

            What is the output of the following program?
#include <stdio.h>
void main()
{
    int x = 6,y = 8,z;
    y = x++;
    z = ++x;
    printf("%d,%d,%d\n", x,y,z);
}
          
Option A:

            8,7,8
            
Option B:

            8,6,8
            
Option C:

            8,8,8
            
Option D:

            6,7,8
            
Correct Answer: option B
Example:[19]

            #include <stdio.h> 
void main ()  
{  
    int i;  
    for(i = 0;i < 10;i++)  
    {    
        if(i == 5)  
        break;  
    }  
    printf("%d",i);  
}
          
Option A:

            9
            
Option B:

            8
            
Option C:

            10
            
Option D:

            5
            
Correct Answer: option D
Example:[20]

            What would be the output of following program?
#include <stdio.h>
int func(int );
int main()
{
    int res;
    res = func(123);
    printf("%d\n", res);
    return 0;
}
int func(int num)
{
    int s = 0,rem;
    while(num > 9)
    {
        rem = num%10;
        s += rem;
        num /= 10;
    }
    s += num;
    return s;
}
          
Option A:

            2
            
Option B:

            1
            
Option C:

            6
            
Option D:

            3
            
Correct Answer: option C
Example:[21]

            What is the output of the following c program?
#include <stdio.h>
int main()
{
	int a = 5,b = 5,c = 10;
	if((a == b) && (c > b))
	{
		printf("Hello\n");
	}
	if((a != b) || (b < c))
	{
		printf("World\n");
	}
	return 0;
}
          
Option A:

            Hello
World
            
Option B:

            Hello

            
Option C:

            World
            
Option D:

            Compile error
            
Correct Answer: option A
Example:[22]

            What is the output of the following c program?
#include <stdio.h>
int main()
{
	int j;
	for(j = 0;j <= 8;j++)
	{
		if (j==4)
	    {
			continue;
	    }
		printf("%d",j);
	}
	return 0;
}
          
Option A:

            012345678
            
Option B:

            0123
            
Option C:

            45678
            
Option D:

            01235678
            
Correct Answer: option D
Example:[23]

            What is the output of the following c program?
#include <stdio.h>
void main()
{
	int i;
	for(i = 0;i < 8;i++)
	{
		if(i == 5)
		{
			goto out;
		}
	}
	out:
	printf("%d\n", i);
}
          
Option A:

            0
            
Option B:

            1
            
Option C:

            7
            
Option D:

            5
            
Correct Answer: option D
Example:[24]

            #include <stdio.h>
int func(int );
void main()
{
    int a;
    a = func(123);
    printf("%d",a);
}
int func(int n)
{
    n = n%10;
    return n;
}
          
Option A:

            6
            
Option B:

            1
            
Option C:

            2
            
Option D:

            3
            
Correct Answer: option D
Example:[25]

            What is the output of the following program?
#include <stdio.h>
int func(int );
int main()
{
    int res;
    res = func(123);
    printf("%d\n", res);
    return 0;
}
int func(int num)
{
    int rem;
    while(num > 9)
    {
        rem = num%10;
        num /= 10;
    }
    return num;
}
          
Option A:

            6
            
Option B:

            1
            
Option C:

            2
            
Option D:

            3
            
Correct Answer: option B
Example:[26]

            #include <stdio.h>
int func(int ,int );
int main()
{
    int res;
    res = func(1,5);
    printf("%d\n", res);
    return 0;
}
int func(int n1,int n2)
{
    int i,r = 0;
    for(i = n1;i < n2;i++)
    {
    	r += i;
    }
    return r;
}
          
Option A:

            15
            
Option B:

            10
            
Option C:

            6
            
Option D:

            1
            
Correct Answer: option B
Example:[27]

            What is the output of the following program?
#include <stdio.h>
int func(int ,int );
int main()
{
    int res;
    res = func(2,6);
    printf("%d\n", res);
    return 0;
}
int func(int n1,int n2)
{
	int i,r = 0;
	do{
		r += n1;
        n1++;
	}while(n1 < n2);
    return r;
}
          
Option A:

            14
            
Option B:

            20
            
Option C:

            8
            
Option D:

            12
            
Correct Answer: option A
Example:[28]

            Array is a collection of variables of

          
Option A:

            same data type
            
Option B:

            any data type
            
Option C:

            int and float data type
            
Option D:

            int and double data type
            
Correct Answer: option A
Example:[29]

            What is the output of the following program?
#include <stdio.h>
int main()
{
	int array[5] = {0,1,2,3,4};
	printf("%d,%d\n",array[1],array[3]);
}
          
Option A:

            0,2
            
Option B:

            1,3
            
Option C:

            2,4
            
Option D:

            0,3
            
Correct Answer: option B
Example:[30]

            What is the output of the following program if array starts with address 6980 and int is of 4bytes?
#include <stdio.h>
int main()
{
	int array[5] = {0,1,2,3,4};
	printf("%u,%u\n",&array[1],&array[3]);
}

          
Option A:

            6980,6988
            
Option B:

            6980,6981
            
Option C:

            6984,6992
            
Option D:

            6988,6996
            
Correct Answer: option C
Example:[31]

            What is the output of the following program if array starts with address 8432 and char is of 1byte?
#include <stdio.h>
int main()
{
	char array[5] = {'A','B','C','D','E'};
	printf("%u,%u\n",&array[1],&array[3]);
}

          
Option A:

            8433,8435
            
Option B:

            8432,8434
            
Option C:

            8434,8436
            
Option D:

            8431,8433
            
Correct Answer: option A
Example:[32]

            Which of the following array declaration is wrong?
char array[5] = {'A','B','C','D','E'};
int ar[5] = {1,2,3,4,5,6};
char a[] = {'a','b','c','d','e','f'};

          
Option A:

            char array[5] = {'A','B','C','D','E'};
            
Option B:

            int ar[5] = {1,2,3,4,5,6};
            
Option C:

            char a[] = {'a','b','c','d','e','f'};
            
Option D:

            All array declarations are correct.
            
Correct Answer: option B
Example:[33]

            Which of the following declaration is a string?
char array[5] = {'A','B','C','D','E'};
int ar[5] = {1,2,3,4,5};
char a[] = {'a','b','c','d','e','f'};
char arr[] = {'a','b','c','d','e','f','\0'};

          
Option A:

            char array[5] = {'A','B','C','D','E'};
            
Option B:

            int ar[5] = {1,2,3,4,5};
            
Option C:

            char a[] = {'a','b','c','d','e','f'};
            
Option D:

            char arr[] = {'a','b','c','d','e','f','\0'};
            
Correct Answer: option D
Example:[34]

            What is the output of the following program if array starts with address 4980 and int is of 4bytes?
#include <stdio.h>
int main()
{
	int array[5] = {0,1,2,3,4};
	printf("%u,%u\n",array + 1,array + 3);
}

          
Option A:

            4980,4988
            
Option B:

            4980,4981
            
Option C:

            4984,4992 
            
Option D:

            4988,4996
            
Correct Answer: option C
Example:[35]

            What is the output of the following program?
#include <stdio.h>
int Arr(int a[]);
int main()
{
	int array[5] = {0,1,2,3,4};
	int res;
	res = Arr(array);
	printf("Result:%d\n", res);
}
int Arr(int a[])
{
	int i,sum = 0;
	for(i = 0;i < 5;i++)
	{
		sum += a[i];
		i++;
	}
	return sum;
}

          
Option A:

            10
            
Option B:

            11
            
Option C:

            9
            
Option D:

            6
            
Correct Answer: option D
Example:[36]

            What is the output of the following program?
#include <stdio.h>
int main()
{
	const int array[5] = {0,1,2,3};
	for(int i = 0;i < 4;i++)
	{
		array[i] += 1;
		printf("%d\n", array[i]);	
	}
}

          
Option A:

            1,2,3,4
            
Option B:

            0,1,2,3
            
Option C:

            2,3,4,5
            
Option D:

            Compile error
            
Correct Answer: option D
Example:[37]

            What is the output of the following program?
#include <stdio.h>
int Arr(int a[]);
int main()
{
	int array[5] = {0,1,2,3,4};
	int res;
	res = Arr(array);
	printf("Result:%d\n", res);
}
int Arr(int a[])
{
	int i,sum = 0;
	for(i = 1;i < 5;i++)
	{
		sum += a[i];
		i++;
	}
	return sum;
}

          
Option A:

            10
            
Option B:

            4
            
Option C:

            9
            
Option D:

            6
            
Correct Answer: option B
Example:[38]

            Which of the following is an incorrect 2-dimensional array declaration?

          
Option A:

            int arr1[2][2] = {11, 22, 33 ,44};
            
Option B:

            int arr2[][2] = {11, 22, 33 ,44};
            
Option C:

            int arr3[2][] = {11, 22, 33 ,44};
            
Option D:

            All declarations are correct.
            
Correct Answer: option C
Example:[39]

            What is the output of the following program?
#include <stdio.h>
int Arr(int a[2][3]);
int main()
{
  int res;
  int ar[2][3] = 
    {
      {1,2,3},
      {4,5,6}
    };
  res = Arr(ar);
  printf("%d\n", res);
  return 0;
}
int Arr(int a[2][3])
{
  int i,j,r = 0;
  for(i = 0;i < 2;i++)
  {
    for(j = 0;j < 3;j++)
    {
      r += a[i][j];
    }
  }
  return r;
}
          
Option A:

            6
            
Option B:

            15
            
Option C:

            21
            
Option D:

            20
            
Correct Answer: option C
Example:[40]

            What will be the output of the following program if first character w of two dimensional array arr starts at memory location 2000?
#include<stdio.h>
int main(){
char arr[5][10] = {
"white",
"red",
"green",
"yellow",
"blue"
};
printf("%s and %u",arr[2],&arr[2][2]);
}
          
Option A:

            green and 2022
            
Option B:

            green and 2012
            
Option C:

            blue and 2002
            
Option D:

            yellow and 2052
            
Correct Answer: option A
Example:[41]

            What will be the output of the following program?
#include <stdio.h>
int main(){
char arr[5][10] = {
"white",
"red",
"green",
"yellow",
"blue"
};
printf("%d",sizeof(arr));
}
          
Option A:

            10
            
Option B:

            5
            
Option C:

            50
            
Option D:

            38
            
Correct Answer: option C
Example:[42]

            What is the following declaration all about?
	char Arr[2][32] = 
	{
	    {"Sibal"},
	    {"Srikant"}
   	};
          
Option A:

            Arr is an array of strings and it will occupy a fixed size of 64 bytes in memory.
            
Option B:

            Arr is an array of strings and it will occupy a fixed size of 14 bytes in memory.
            
Option C:

            Arr is an array of pointers to strings and it will occupy a fixed size of 64 bytes in memory.
            
Option D:

            Arr is an array of pointers to strings and it will occupy a fixed size of 14 bytes in memory.
            
Correct Answer: option A
Example:[43]

            What is the output of the following program?
#include <stdio.h> 
#include <string.h> 
char func(char *);
void main ()  
{  
    char res;
    res = func("Hello");
    printf("%c\n", res);
}  
char func(char *s)
{
  return s[strlen(s)-1];
}
          
Option A:

            l
            
Option B:

            o
            
Option C:

            H
            
Option D:

            '\0'
            
Correct Answer: option B
Example:[44]

            What is the output of the following program?
#include <stdio.h> 
int func(char *);
void main ()  
{  
    int res;
    res = func("Hello");
    printf("%d\n", res);
}  
int func(char *s)
{
  int len = 0;
  for(int i = 0;s[i] != '\0';i++)
  {
    len++;
  }
  return len;
}
          
Option A:

            4
            
Option B:

            6
            
Option C:

            5
            
Option D:

            3
            
Correct Answer: option C
Example:[45]

            What is the output of the following program?
#include <stdio.h> 
#include <string.h> 
void main ()  
{  
    char s[10];
    strcpy(s,"friend");
    printf("%d,%d\n", strlen(s),sizeof(s));
}
          
Option A:

            6,6
            
Option B:

            5,9
            
Option C:

            7,10
            
Option D:

            6,10
            
Correct Answer: option D
Example:[46]

            What is the error on the following program, currently it returns garbage value as output?
#include <stdio.h>
#include <string.h>
char *fun();
void main()
{
    char *s;
    char *fun();
    s = fun();
    printf("%s\n", s);
}
char *fun()
{
    char buffer[30];
    strcpy(buffer, "RAM");
    return (buffer);
}
          
Option A:

            Declare buffer as a global variable.
            
Option B:

            Declare char *s outside main function.
            
Option C:

            Include header file stdlib.h.
            
Option D:

            Allocate memory using malloc inside main()
            
Correct Answer: option A
Example:[47]

            What is the output of the following program?
#include <stdio.h> 
void main ()  
{  
    char a[] = "Hello";
    printf("%s\n", 'a');
}  
          
Option A:

            a
            
Option B:

            H
            
Option C:

            Hello
            
Option D:

            Segmentation fault during execution
            
Correct Answer: option D
Example:[48]

            What will strcmp() library function do?
          
Option A:

            compares the first n characters of the object
            
Option B:

            compares two strings and returns an integer
            
Option C:

            compares two integers and returns a string
            
Option D:

            copies one string to other
            
Correct Answer: option B
Example:[49]

            What is the output of the following program?
#include <stdio.h>
#include <string.h>
int main()
{
    char str1[] = "abc", str2[] = "Abc", str3[] = "abc";
    int result1,result2;
    result1 = strcmp(str1, str2);
    result2 = strcmp(str1, str3);
    printf("%d,%d\n", result1,result2);
    return 0;
}
          
Option A:

            32,0
            
Option B:

            0,32
            
Option C:

            32,32
            
Option D:

            0,0
            
Correct Answer: option A
Example:[50]

            What will strcat() library function do?
          
Option A:

            compares the first n characters of the object
            
Option B:

            compares two strings and returns an integer
            
Option C:

            concatenates two strings and returns the concatenated string
            
Option D:

            copies one string to other
            
Correct Answer: option C
Example:[51]

            #include <stdio.h>
#include <string.h>
int main()
{
    char str1[10] = "Mbed", str2[] = "Tech";
    strcat(str1,str2);
    printf("%s,%s\n", str1,str2);
    return 0;
}
          
Option A:

            MbedTech,Tech
            
Option B:

            Tech,Tech
            
Option C:

            MbedTech,MbedTech
            
Option D:

            Compilation error
            
Correct Answer: option A
Example:[52]

            What is the output of the following program?
#include <stdio.h>
char *func(char *);
void main()
{
    char str1[] = "MbedTechnologies";
    char *res;
    res = func(str1);
	printf("%s", res);
}
char *func(char *s)
{
	s[4] = '\0';
	return s;
}
          
Option A:

            MbedTechnologies
            
Option B:

            Technologies
            
Option C:

            Mbed
            
Option D:

            Compilation error
            
Correct Answer: option C
Example:[53]

            What is the output of the following program?
#include <stdio.h>
#include <string.h>
void main()
{
    char str1[] = "Mbed";
    char *res;
    strcpy(res,str1);
    printf("%s", res);
}
          
Option A:

            Machine dependent
            
Option B:

            Compilation error
            
Option C:

            Mbed
            
Option D:

            Compilation ok, Segmentation fault during execution
            
Correct Answer: option D
Example:[54]

            What is the output of the following program?
#include "stdio.h"
#include "string.h"
int main() {
  char strs[] = "Bangalore-2134";
  char *strd = strs + 5;
  strcat(strd, strs);
  printf("strd is %s\n",strd);
  return 0;
}
          
Option A:

            Segmentation fault
            
Option B:

            Bangalore-2134Banga
            
Option C:

            BangaBangalore-2134
            
Option D:

            Bangalore-2134
            
Correct Answer: option A
Example:[55]

            What is the output of the following program?
#include <stdio.h>
void main ()
{
	char str[] = "Mbed Technologies";
	printf("%c,%s\n", str[1], str);
}
          
Option A:

            M,MbedTechnologies
            
Option B:

            M,Mbed
            
Option C:

            b,Mbed Technologies
            
Option D:

            M,Mbed Technologies
            
Correct Answer: option C
Example:[56]

            What is the output of the following program?
#include <stdio.h>
int main ()
{
	char s1[] = "Mbed";
	char s2[] = {'M','b','e','d',0};
	printf("%s,%s\n", s1,s2);
	return 0;
}
          
Option A:

            Mbed,Mbed
            
Option B:

            Mbed,''Mbed''
            
Option C:

            Mbed
            
Option D:

            Mbed,'Mbed'
            
Correct Answer: option A
Example:[57]

            What is the output of the following program?
#include <stdio.h>
int main ()
{
	char s[] = "Mbed";
	printf("%s,%s,%s,%c\n", s,&s[2],&s,s[2]);
	return 0;
}
          
Option A:

            Mbed,ed,Mbed,b
            
Option B:

            Mbed,ed,1e4d55e0,e
            
Option C:

            Mbed,Mbed,Mbed,e
            
Option D:

            Mbed,ed,Mbed,e
            
Correct Answer: option D
Example:[58]

            What is the output of the following program?
#include <stdio.h>
int main ()
{
        char s[] = "Mbed";
        int i = 0;
        while(s[i] != 0)
        {
                printf("%c %c %c\n", s[i], *(s + i), *(i + s));
                i++;
        }
        return 0;
}
          
Option A:

            b  b  b
e  e  e
d  d  d
M  M  M
            
Option B:

            M  M  M
b  b  b
e  e  e
d  d  d
            
Option C:

            M  M  M
b  b  b
d  d  d
e  e  e
            
Option D:

            M  M  M
e  e  e
b  b  b
d  d  d
            
Correct Answer: option B
Example:[59]

            What is the output of the following program?
#include "stdio.h"
int main(void)
{
  char str[2][15] =
  {
    "Mbed",
    "Technologies"
  };
  printf("%d,%s,%c\n",sizeof(str),str[1],str[0][0]);
}
          
Option A:

            30,M,Technologies
            
Option B:

            30,Technologies,M
            
Option C:

            30,T,M
            
Option D:

            30,e,M
            
Correct Answer: option B
Example:[60]

            What is the output of the following program?
#include "stdio.h"
int main(void)
{
  char *str[] =
  {
    "Mbed",
    "Technologies"
  };
  printf("%d,%s,%c\n",sizeof(str),str[1],str[0][0]);
}
          
Option A:

            18,Technologies,M
            
Option B:

            8,Technologies,M
            
Option C:

            8,T,M
            
Option D:

            30,e,M
            
Correct Answer: option B
Example:[61]

            What is the output of the following program?
#include "stdio.h"
#include "string.h"
int main() {
  char strs[] = "Bangalore-2134";
  char strd[10] = "\0";
  strncpy(strd, strs, 9);
  printf("strd is %s\n",strd);
  return 0;
}
          
Option A:

            strd is 2134
            
Option B:

            strd is Bangalore
            
Option C:

            strd is 2134Bangalore
            
Option D:

            strd is Bangalore2134
            
Correct Answer: option B
Example:[62]

            What is the output of the following program?
#include "stdio.h"
#include "string.h"
int main() {
  char strs[] = "Bangalore-2134";
  char strd[10];
  strd[0] = '\0';
  strncat(strd, strs, 9);
  printf("strd is %s\n",strd);
  return 0;
}
          
Option A:

            strd is 2134
            
Option B:

            strd is Bangalore
            
Option C:

            strd is 2134Bangalore
            
Option D:

            strd is Bangalore2134
            
Correct Answer: option B
Example:[63]

            What is the output of the following program?
#include "stdio.h"
#include "string.h"
int main() {
  char strs[] = "Bangalore";
  char strd[] = "2134";
  strcat(strd, strs);
  printf("strd is %s\n",strd);
  return 0;
}
          
Option A:

            strd is 2134
            
Option B:

            strd is Bangalore
            
Option C:

            strd is 2134Bangalore
            
Option D:

            strd is Bangalore2134
            
Correct Answer: option C
Example:[64]

            What is the output of the following program?
#include "stdio.h"
#include "string.h"
int main() {
  char str1[] = "Mbed Technologies";
  char str2[] = "Mbed Articles";  
  int i1 = strcmp(str1, str1);
  int i2 = strcmp(str1, str2);
  int i3 = strcmp(str2, str1);
  printf("%d, %d, %d\n", i1, i2, i3);  
  return 0;
}
          
Option A:

            19, 0, -19
            
Option B:

            19, -19, 0
            
Option C:

            0, 19, 0
            
Option D:

            0, 19, -19
            
Correct Answer: option D
Example:[65]

            What is the output of the following program?
#include "stdio.h"
#include "string.h"
int main() {
  char str1[] = "Mbed Technologies";
  char str2[] = "Mbed Articles";
  int i1 = strncmp(str1, str2, 4);
  int i2 = strncmp(str1, str2, 9);
  int i3 = strncmp(str2, str1, 9);
  printf("%d, %d, %d\n", i1, i2, i3);  
  return 0;
}
          
Option A:

            19, 0, -19
            
Option B:

            19, -19, 0
            
Option C:

            0, 19, 0
            
Option D:

            0, 19, -19
            
Correct Answer: option D
Example:[66]

            What is the output of the following program?
#include "stdio.h"
#include "string.h"
void main() {
	char *ptr;
	char str[] = "Mbed Technologies";
	char ch = 'e';
	ptr = strrchr(str, ch);
	printf( "%c %s %s\n",ch, str, ptr);
}
          
Option A:

            e Mbed Technologies es
            
Option B:

            e Mbed Technologies echnologies
            
Option C:

            e Mbed Technologies e
            
Option D:

            e Mbed Technologies ed Technologies
            
Correct Answer: option A
Example:[67]

            What is the output of the following program?
#include "stdio.h"
#include "string.h"
void main() {
	char *ptr;
	char str[] = "Mbed Technologies";
	char ch = 'e';
	ptr = strchr(str, ch);
	printf( "%c %s %s\n",ch, str, ptr);
}
          
Option A:

            e Mbed Technologies es
            
Option B:

            e Mbed Technologies echnologies
            
Option C:

            e Mbed Technologies e
            
Option D:

            e Mbed Technologies ed Technologies
            
Correct Answer: option D
Example:[68]

            What is a pointer in C?
          
Option A:

            Pointers in C language is a variable that stores/points the address of another variable.
            
Option B:

            A Pointer in C is used to allocate memory dynamically i.e. at run time.
            
Option C:

            The pointer variable might be belonging to any of the data type such as int, float, char, double, short etc.
            
Option D:

            All of the above.
            
Correct Answer: option D
Example:[69]

            What is the output of the following program?
#include <stdio.h>
int Change(int *,int *);
void main()
{
  int res, a1 = 20,a2 =30;
  res = Change(&a1,&a2);
  printf("%d\n", res);
}
int Change(int *a,int *b)
{
  int r;
  r = *a + *b;
  return r;
}
          
Option A:

            20
            
Option B:

            30
            
Option C:

            50
            
Option D:

            None of the above
            
Correct Answer: option C
Example:[70]

            What is the following pointer declaration all about?
int *a[10];
          
Option A:

            a is a pointer to an array of 10 integers.
            
Option B:

            a is a pointer to a function that takes 10 integers.
            
Option C:

            a is an array of 10 pointers to integer.
            
Option D:

            a is an array of 10 integers.
            
Correct Answer: option C
Example:[71]

            What is the following pointer declaration all about?
int *a();
          
Option A:

            a is a function returning a pointer to any data type.
            
Option B:

            a is a function returning a pointer to integer.
            
Option C:

            a is a pointer to a function that returns an integer.
            
Option D:

            a is a pointer to an integer.
            
Correct Answer: option B
Example:[72]

            What is the following pointer declaration all about?
int (*a)(int);
          
Option A:

            a is a function returning a pointer to an integer.
            
Option B:

            a is a func that takes an integer and returns an integer.
            
Option C:

            a is a pointer to a function that takes an integer argument and returns an integer.
            
Option D:

            a is a pointer to an integer.
            
Correct Answer: option C
Example:[73]

            What is the following pointer declaration all about?
int **a;
          
Option A:

            a is a function returning a pointer to an integer.
            
Option B:

            a is a pointer to another pointer to an integer.
            
Option C:

            a is a pointer to a function that returns an integer argument.
            
Option D:

            a is a pointer to an integer.
            
Correct Answer: option B
Example:[74]

            What is the following pointer declaration all about?
int (*a)[10];
          
Option A:

            a is a pointer to a function that takes an integer array and returns an integer.
            
Option B:

            a is a pointer to a function that takes 10 integers.
            
Option C:

            a is an array of 10 pointers to integer.
            
Option D:

            a is a pointer to an array of 10 integers.
            
Correct Answer: option D
Example:[75]

            Which of the following statement is incorrect about void pointer?
          
Option A:

            A void pointer is a type of pointer, void*
            
Option B:

            A void pointer is used to indicate that the storage location pointed to by the pointer has no specific type.
            
Option C:

            A void pointer is a special reserved value used to indicate that the pointer is not pointing to anything conceptually.
            
Option D:

            A  void * in function argument means that the function can take a pointer that doesn't need to be a specific type.
            
Correct Answer: option C
Example:[76]

            Which of the following statement is incorrect about NULL pointer?
          
Option A:

            NULL pointer is used to initialize a pointer variable when that pointer variable isn't assigned any valid memory address yet.
            
Option B:

            NULL pointer is used to denote the end of a memory search or processing event.
            
Option C:

            NULL pointer is used to indicate that the storage location pointed to by the pointer has no specific type.
            
Option D:

            NULL pointer is a pointer which points nothing.
            
Correct Answer: option C
Example:[77]

            What would be the output of following program?
#include <stdio.h>
int main()
{
    char str[20] = "Master";
    char *p = str;
    *p = 'F';
    p++;p++;
    *p = 'S';
    p++;p++;
    *p = 'E';
    printf("%s\n", str);
    return 0;
}
          
Option A:

            Master
            
Option B:

            MaStEr
            
Option C:

            FaStEr
            
Option D:

            FastEr
            
Correct Answer: option C
Example:[78]

            What would be the output of following program?
#include <stdio.h>
int main()
{
     int aa = 10,bb = 6;
     int *bptr;
     bptr = &aa;
     printf("%d", aa + bb  **bptr);
     return 0;
}
          
Option A:

            60
            
Option B:

            70
            
Option C:

            16
            
Option D:

            Compile Error
            
Correct Answer: option B
Example:[79]

            What would be the output of following program?
#include <stdio.h>
int fun(int *f)
{
    *f = 10;
    return 0;
}
int main()
{
    int arr[5] = {1, 2, 3, 4, 5};
    printf("Before modification arr[3] = %d", arr[3]);
    fun(&arr[3]);
    printf("\nAfter modification arr[3] = %d", arr[3]);
    return 0;
}
          
Option A:

            Before Modification 3, After Modification 3
            
Option B:

            Before Modification 3, After Modification 10
            
Option C:

            Before Modification 4, After Modification 4
            
Option D:

            Before Modification 4, After Modification 10
            
Correct Answer: option D
Example:[80]

            If a function is declared as void func(int *p), then which of the following statements is valid to call function func?
          
Option A:

            func(x) where x is defined as int x;
            
Option B:

            func(x) where x is defined as int *x;
            
Option C:

            func(&x) where x is defined as int *x;
            
Option D:

             func(*x) where x is defined as int *x;
            
Correct Answer: option B
Example:[81]

            What would be the output of following program?
#include <stdio.h>
void fun(int **p);
void main()
{
    int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0};
    int *ptr;
    ptr = &a[2][1];
    fun(&ptr);
}
void fun(int **p)
{
    printf("%d\n", **p);
}
          
Option A:

            3
            
Option B:

            4
            
Option C:

            8
            
Option D:

            9
            
Correct Answer: option C
Example:[82]

            What is the following declaration all about?
char *Arr[] = 
   {
   		"Jena",
   		"Kumar"	
   };
          
Option A:

            Arr is an array of strings
            
Option B:

            Arr is a string.
            
Option C:

            Arr is a pointer to string.
            
Option D:

            Arr is an array of pointers to strings.
            
Correct Answer: option D
Example:[83]

            What would be the output of following program?
#include <stdio.h>
void main()
{
  char *Arr[] = 
  {
    "Jena",
    "Kumar" 
  };
  printf("%c,%s\n", Arr[1][3],Arr[1]);
}
          
Option A:

            a,Jena
            
Option B:

            J,Jena
            
Option C:

            a,Kumar
            
Option D:

            u,Kumar
            
Correct Answer: option C
Example:[84]

            What would be output of the following program?
#include <stdio.h>
void (*fptr)(int * ,int * );
void function(int * ,int * );
int main()
{
  int num1 = 20,num2 = 30;
  fptr = function;
  (*fptr)(&num1,&num2);
  printf("%d,%d\n", num1,num2);
  return 0;
}
void function(int *a,int *b)
{
  int copy;
  copy = *a;
  *a = *b;
  *b = copy;
}
          
Option A:

            20,30
            
Option B:

            30,30
            
Option C:

            30,20
            
Option D:

            20,20
            
Correct Answer: option C
Example:[85]

            What is a function pointer in C?
          
Option A:

            A pointer variable which points to another function.
            
Option B:

            A pointer variable which points to another string variable.
            
Option C:

            A pointer variable which points to another int variable.
            
Option D:

            None of the given above.
            
Correct Answer: option A
Example:[86]

            What is the following pointer declaration all about?
int (*f)(int ,int);
          
Option A:

            f is a pointer to a function that takes two integers as inputs and another integer as output.
            
Option B:

            f is a pointer to a function that takes two integers as inputs.
            
Option C:

            f is pointer to a function that gives output as integer.
            
Option D:

            None of the given above.
            
Correct Answer: option A
Example:[87]

            A state machine in c can be implemented by ___________?
          
Option A:

            Using an if else statements.
            
Option B:

            Using a switch case statements.
            
Option C:

            Using function pointers.
            
Option D:

            All mentioned above.
            
Correct Answer: option D
Example:[88]

            What is the output of the following program?
#include <stdio.h>
int add(int, int);
int (*fptr)(int,int);
void main()
{
	int ret = 0;
	fptr = add;
	ret = (*fptr)(3,2);
	printf("Result is:%d\n", ret);
}
int add(int a, int b)
{
	return a+b;
}
          
Option A:

            5
            
Option B:

            6
            
Option C:

            3
            
Option D:

            2
            
Correct Answer: option A
Example:[89]

            What is the error in the following program?
#include <stdio.h>
int add(int, int);
typedef int (*f)(int,int);
void main()
{
	f = add;
}
int add(int a, int b)
{
	return a+b;
}
          
Option A:

            Error in declaring the function pointer.
            
Option B:

            Error in initializing the function pointer.
            
Option C:

            Error in defining prototype for the function add. 
            
Option D:

            Error in the function definition of add.
            
Correct Answer: option B
Example:[90]

            What is the error in the following program?
#include <stdio.h>
int add(int, int);
typedef int (*f)(int,int);
void main()
{
	int ret = 0;
	f fptr = NULL;
	fptr = add;
	ret = (*fptr)(3,2);
	printf("Result is:%d\n", ret);
}
int add(int a, int b)
{
	return a+b;
}
          
Option A:

            Error in declaring the function pointer f.
            
Option B:

            Error in initializing the function pointer f.
            
Option C:

            Error in calling the function pointer f. 
            
Option D:

            There is no error in the program.
            
Correct Answer: option D
Example:[91]

            What is the error in the following program?
#include <stdio.h>
typedef int (*f)(int,int);
int addop(f ptr, int a, int b)
{
	int ret = 0;
	ret = (ptr)(a,b);
	return ret;
}
int add(int a, int b)
{
	return a+b;
}
void main()
{
	int ret = 0;
	f fptr = NULL;
	fptr = add;
	ret = addop(fptr,3,2);
	printf("Result is:%d\n", ret);
}
          
Option A:

            Error in declaring the function pointer f.
            
Option B:

            Error in initializing the function pointer f.
            
Option C:

            Error in calling the function addop.
            
Option D:

            Error in the function definition of addop.
            
Correct Answer: option D
Example:[92]

            Which of the following statement represents a pointer to function?
          
Option A:

            int *f(int, int);
            
Option B:

            int (*f)(int*, int*);
            
Option C:

            void f(int *,int *);
            
Option D:

            void f(int ,int );
            
Correct Answer: option B
Example:[93]

            What is the following declaration is all about?"  
void *(*foo) (int*);
          
Option A:

            (*foo) is a pointer to the function, whose argument is of int* type and return type is void*
            
Option B:

            foo is a pointer to the function, whose argument is of int* type and return type is void*
            
Option C:

            (*foo) is a pointer to the function, whose argument is of int* type and return type is void
            
Option D:

            (*foo) is a pointer to the function, whose argument is of int type and return type is void*
            
Correct Answer: option A
Example:[94]

            What is the output of the following program?
#include <stdio.h>
void main()
{
    int i = 10;
    int *p = &i;
    *p = 11;
    printf("%d %d\n", i, *p);
}
          
Option A:

            10,11
            
Option B:

            11,11
            
Option C:

            11,10
            
Option D:

            10,10
            
Correct Answer: option B
Example:[95]

            What is the output of the following program?
#include <stdio.h>  
void main(void) 
{ 
    int i = 10;    
    const int *ptr = &i;        
    *ptr = 100; 
    printf("%d,%d\n", i,*ptr); 
} 
          
Option A:

            100,100
            
Option B:

            110,110
            
Option C:

            100,110
            
Option D:

            Compile error
            
Correct Answer: option D
Example:[96]

            What is the output of the following c program?
#include <stdio.h>
void main()
{
    unsigned int i = 0x00000001;
    char *c = (char *)&i;
    printf("%d\n", *c);
}
          
Option A:

            1
            
Option B:

            0
            
Option C:

            1 if machine is little endian, 0 if machine is big endian
            
Option D:

            Compile error
            
Correct Answer: option C
Example:[97]

            A pointer is called dangling pointer if 
          
Option A:

            it points to a deallocated memory.
            
Option B:

            it points to a void pointer.
            
Option C:

            it points to a NULL pointer.
            
Option D:

            it points to a memory which is allocated but not freed.
            
Correct Answer: option A
Example:[98]

            What is the output of the following program?
#include <stdio.h>
void Change(int *,int *);
void main()
{
  int a1 = 20,a2 =30;
  Change(&a1,&a2);
  printf("%d,%d\n", a1,a2);
}
void Change(int *a,int *b)
{
  int copy;
  copy = *a;
  *a = *b;
  *b = copy;
}
          
Option A:

            20,30
            
Option B:

            30,20
            
Option C:

            30,30
            
Option D:

            20,20
            
Correct Answer: option B
Example:[99]

            What is the output of the following program?
#include <stdio.h>
void Change(int ,int );
void main()
{
  int a1 = 20,a2 =30;
  Change(a1,a2);
  printf("%d,%d\n", a1,a2);
}
void Change(int a,int b)
{
  int copy;
  copy = a;
  a = b;
  b = copy;
}
          
Option A:

            20,30
            
Option B:

            30,20
            
Option C:

            30,30
            
Option D:

            20,20
            
Correct Answer: option A
Example:[100]

            ptr is ____ pointer after executing the following program?
#include <stdio.h>  
#include <stdlib.h>
void main()  
{  
   int *ptr = (int *)malloc(sizeof(int));  
   int a = 5;  
   ptr = &a; 
   printf("%d\n", *ptr); 
   free(ptr); 
}
          
Option A:

            NULL pointer
            
Option B:

            Void pointer
            
Option C:

            Dangling pointer
            
Option D:

            None of the above
            
Correct Answer: option C
Example:[101]

            The dangling pointer errors can be avoided by
          
Option A:

            Allocating more memory using malloc
            
Option B:

            Assigning NULL value to the pointer after freeing allocated memory from the pointer
            
Option C:

            Assigning void value to the pointer
            
Option D:

            Deallocating memory from pointer using free.
            
Correct Answer: option B
Example:[102]

            Which of the following statement is not true regarding structure in a c program?
          
Option A:

            Keyword struct introduces a structure definition.
            
Option B:

            Structures contain variables of many different data types.
            
Option C:

            Structures are commonly used to define records to be stored in files.
            
Option D:

            Each structure definition must end with a comma.
            
Correct Answer: option D
Example:[103]

            What is nested structure in C? 
          
Option A:

            Nested structure is the structure in which the pointer points to any data type. 
            
Option B:

            Nested structure is the structure in which the pointer points to the structure of the same type. 
            
Option C:

            Nested structure is the structure in which the pointer points to another structure.
            
Option D:

            Nested structure is a structure in which a structure is declared inside another structure. 
            
Correct Answer: option D
Example:[104]

            What is the output of the following program?
#include <stdio.h>
#include <string.h>
struct test
{
  char s[10];
};
void myfunc(struct test *d)
{
  strcpy(d->s,"World");
}
void main()
{
  struct test t;
  myfunc(&t);
  printf("%s", t.s);
}
          
Option A:

            No output
            
Option B:

            World
            
Option C:

            Compile error
            
Option D:

            Garbage output
            
Correct Answer: option B
Example:[105]

            What is the output of the following program?
#include <stdio.h>
#include <string.h>
void myfunc(struct test *d)
{
  strcpy(d->s,"World");
}
void main()
{
  struct test
  {
    char s[10];
  };
  struct test t;
  myfunc(&t);
  printf("%s", t.s);
}
          
Option A:

            No output
            
Option B:

            World
            
Option C:

            Compile error
            
Option D:

            Garbage output
            
Correct Answer: option C
Example:[106]

            What will be error the following program will face during execution?
#include <stdio.h> 
#include <string.h> 
void main ()  
{  
    char a[2] = "";
    strcpy(a,"Hello World");
    printf("%s\n", a);
}

          
Option A:

            Stack overflow
            
Option B:

            Heap overflow
            
Option C:

            Frozen memory
            
Option D:

            Memory leak
            
Correct Answer: option A
Example:[107]

            What will be error the following program will face during execution?
#include <stdio.h>
int main()
{
    char i[5] = "";
    scanf("%s", i);
    printf("%s",i);
    return 0;
}
          
Option A:

            Buffer overflow
            
Option B:

            Heap overflow
            
Option C:

            Frozen memory
            
Option D:

            Memory leak
            
Correct Answer: option A
Example:[108]

            What will be the output of the following program?
#include <stdio.h>
union mass
{
   	unsigned int a;
   	char b;
};
void main()
{
    union mass test;
    test.a = 0x00000001;
    printf("%d\n", test.b);
}
          
Option A:

            1
            
Option B:

            0
            
Option C:

            1 if machine is little endian, 0 if machine is big endian
            
Option D:

            Compile error
            
Correct Answer: option C
Example:[109]

            What will be the output of the following program if int takes 4 bytes and char takes 1 byte?
#include <stdio.h>
union mass
{
   	unsigned int a;
   	char b;
};
void main()
{
	union mass u;
    printf("%d\n", sizeof(u));
}
          
Option A:

            1
            
Option B:

            5
            
Option C:

            4
            
Option D:

            6
            
Correct Answer: option C
Example:[110]

            What will be the output of the following program if int takes 4 bytes and char takes 1 byte?
#include <stdio.h>
struct student
{
   	int a;
   	char b;
};
void main()
{
	struct student s;
    printf("%d\n", sizeof(s));
}
          
Option A:

            1
            
Option B:

            5
            
Option C:

            4
            
Option D:

            6
            
Correct Answer: option B
Example:[111]

            Left shifting an integer x with an integer y (x<<y) is equivalent to 
          
Option A:

            dividing x with 2^y (2 raise to power y).
            
Option B:

            adding x with 2^y (2 raise to power y).
            
Option C:

            multiplying x with 2^y (2 raise to power y).
            
Option D:

            masking x with 2^y (2 raise to power y).
            
Correct Answer: option C
Example:[112]

            Right shifting an integer x with an integer y (x>>y) is equivalent to 
          
Option A:

            dividing x with 2^y (2 raise to power y).
            
Option B:

            adding x with 2^y (2 raise to power y).
            
Option C:

            multiplying x with 2^y (2 raise to power y).
            
Option D:

            masking x with 2^y (2 raise to power y).
            
Correct Answer: option A
Example:[113]

            What is the output of the following program?
#include <stdio.h>
unsigned int fun(unsigned int ,unsigned int );
void main()  
{  
   unsigned int r = 8,res;
   res = fun(r,0);
   printf("%d\n", res);
}
unsigned int fun(unsigned int a,unsigned int x)
{
	return (a |= 1 << x);
}
          
Option A:

            8
            
Option B:

            9
            
Option C:

            10
            
Option D:

            12
            
Correct Answer: option B
Example:[114]

            What is the output of the following program?
#include <stdio.h>
unsigned int fun(unsigned int ,unsigned int );
void main()  
{  
   unsigned int r = 9,res;
   res = fun(r,0);
   printf("%d\n", res);
}
unsigned int fun(unsigned int a,unsigned int x)
{
	return (a &= ~(1 << x));
}
          
Option A:

            8
            
Option B:

            9
            
Option C:

            10
            
Option D:

            12
            
Correct Answer: option A
Example:[115]

            What will be the output of the following program?
#include <stdio.h>
void main()
{
	printf("Left Shift output %d,Right Shift output %d\n", 16 << 2,16 >> 2);
}
          
Option A:

            Left Shift output 64,Right Shift output 4
            
Option B:

            Left Shift output 4,Right Shift output 64
            
Option C:

            Left Shift output 32,Right Shift output 16
            
Option D:

            Left Shift output 16,Right Shift output 32
            
Correct Answer: option A
Example:[116]

            What will be the output of the following program?
#include <stdio.h>
unsigned int fun(unsigned int ,unsigned int );
void main()  
{  
   unsigned int r = 8,res;
   res = fun(r,0);
   printf("%d\n", res);
}
unsigned int fun(unsigned int a,unsigned int x)
{
	return (a ^= (1 << x));	
}
          
Option A:

            8
            
Option B:

            9
            
Option C:

            10
            
Option D:

            12
            
Correct Answer: option B
Example:[117]

            What will be the output of the following program?
#include <stdio.h>
unsigned int fun(unsigned int ,unsigned int ,unsigned int);
void main()  
{  
   unsigned int res;
   res = fun(40,0,3);
   printf("%d\n", res);
}
unsigned int fun(unsigned int a,unsigned int start,unsigned int end)
{
   int i;
   for(i = start;i < end;i++)
   {
      a |= (1 << i);
   }
   return a;
}
          
Option A:

            41
            
Option B:

            43
            
Option C:

            47
            
Option D:

            42
            
Correct Answer: option C
Example:[118]

            What will be the output of the following program?
#include <stdio.h>
unsigned char fun(unsigned char );
void main()  
{  
    unsigned char y;
    y = fun(0x12);
    printf("%x\n", y);
}
unsigned char fun(unsigned char a)
{
   return ((a << 4) | (a >> 4));
}
          
Option A:

            21
            
Option B:

            12
            
Option C:

            18
            
Option D:

            33
            
Correct Answer: option A
Example:[119]

            What will be the output of the following program?
#include <stdio.h>
struct fiddle
{
	unsigned int itals :1; 
	unsigned int body  :2; 
	unsigned int color :2;
	unsigned int       :3; 
};
void main()
{
	printf("%d\n", sizeof(struct fiddle));
}
          
Option A:

            4
            
Option B:

            16
            
Option C:

            8
            
Option D:

            None of the mentioned.
            
Correct Answer: option A
Example:[120]

            struct time is written below to represent current time of the day? What are the values of A,B,C?
struct time
{
   unsigned int mins : A;
   unsigned int seconds : B;
   unsigned int hour : C;
};
          
Option A:

            A is 6, B is 6, C is 5
            
Option B:

            A is 6, B is 5, C is 6
            
Option C:

            A is 5, B is 6, C is 6
            
Option D:

            Can't say, compiler dependent
            
Correct Answer: option A
Example:[121]

            #include <stdio.h>
void main()
{
    int a = 0xF0;
    a = (1 << 3) | a;
    a = (~(1 << 3) & a);
    a = (1 << 3) ^ a;
    printf("%p\n", a);
}
          
Option A:

            0xF8
            
Option B:

            0xF0
            
Option C:

            0xF1
            
Option D:

            0xF7
            
Correct Answer: option A
Example:[122]

            What will be the output of the following program?
#include <stdio.h>
unsigned int fun(unsigned int ,unsigned int ,unsigned int);
void main()  
{  
   unsigned int res;
   res = fun(47,0,3);
   printf("%d\n", res);
}
unsigned int fun(unsigned int a,unsigned int start,unsigned int end)
{
   int i;
   for(i = start;i < end;i++)
   {
      a &= ~(1 << i);
   }
   return a;
}
          
Option A:

            41
            
Option B:

            43
            
Option C:

            47
            
Option D:

            40
            
Correct Answer: option D
Example:[123]

            What is self referential structure in C?
          
Option A:

            Self Referential Structure is the Data Structure in which the pointer points to NULL. 
            
Option B:

            Self Referential Structure is the Data Structure in which the pointer points to any data type. 
            
Option C:

            Self Referential Structure is the Data Structure in which the pointer points to the structure of the same type. 
            
Option D:

            Self Referential Structure is the Data Structure in which the pointer points to another structure. 
            
Correct Answer: option C
Example:[124]

            In linked list each node contains minimum of two fields. The first field is to store the data and the second field is which of the following?
          
Option A:

            Pointer to character
            
Option B:

            Pointer to integer
            
Option C:

            Pointer to node structure
            
Option D:

            Pointer to float
            
Correct Answer: option C

 Search Links


 Popular C search MCQs


 Popular C search examples