Advertisements

Search results for void

Example:[1]

            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:[2]

            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:[3]

            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:[4]

            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:[5]

            A function with its argument declared as void means?
          
Option A:

            The function does not return any datatype.
            
Option B:

            The function is available only in the file it is defined.
            
Option C:

            The function can be called from any file in the project.
            
Option D:

            The function that does not take any datatype as its argument.
            
Correct Answer: option D
Example:[6]

            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:[7]

            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:[8]

            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:[9]

            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:[10]

            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:[11]

            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:[12]

            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:[13]

            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:[14]

            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:[15]

            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:[16]

            #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:[17]

            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:[18]

            #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:[19]

            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:[20]

            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:[21]

            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:[22]

            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:[23]

            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:[24]

            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:[25]

            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:[26]

            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:[27]

            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:[28]

            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:[29]

            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:[30]

            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:[31]

            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:[32]

            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:[33]

            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:[34]

            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:[35]

            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:[36]

            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:[37]

            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:[38]

            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:[39]

            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:[40]

            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:[41]

            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:[42]

            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:[43]

            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:[44]

            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:[45]

            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:[46]

            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:[47]

            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:[48]

            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:[49]

            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:[50]

            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:[51]

            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:[52]

            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:[53]

            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:[54]

            What will be error the following program will face during execution?
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#define BUFSIZE 2
void main() 
{
    char *buf;
    buf = (char *)malloc(sizeof(char)*BUFSIZE);
    strcpy(buf, "Hello world\n");
}
          
Option A:

            Stack overflow
            
Option B:

            Heap overflow
            
Option C:

            Frozen memory
            
Option D:

            Memory leak
            
Correct Answer: option B
Example:[55]

            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:[56]

            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:[57]

            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:[58]

            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:[59]

            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:[60]

            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:[61]

            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:[62]

            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:[63]

            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:[64]

            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:[65]

            #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:[66]

            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

 Search Links


 Popular C search MCQs


 Popular C search examples