Advertisements

Search results for return

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]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            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