Advertisements

Search results for unsigned

Example:[1]

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

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

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

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

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

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

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

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

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

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

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

            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