Advertisements

Search results for if

Example:[1]

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

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

            If a storage class is missing in the array definition by default it will be taken to be
          
Option A:

            Automatic
            
Option B:

            External
            
Option C:

            Static
            
Option D:

            Either automatic or external depending on the place of occurrence.
            
Correct Answer: option A
Example:[4]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            If we continuously allocate memory and we do not free that memory space after use it may result in ______
          
Option A:

            Stack overflow
            
Option B:

            Heap overflow
            
Option C:

            Frozen memory
            
Option D:

            Memory leak
            
Correct Answer: option D
Example:[21]

            If we declare large number of local variables inside a function it can result in _______
          
Option A:

            Stack overflow
            
Option B:

            Heap overflow
            
Option C:

            Frozen memory
            
Option D:

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

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

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

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

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

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

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

            A queue is a _____ data structure
          
Option A:

            FIFO
            
Option B:

            LIFO
            
Option C:

            In-built structure 
            
Option D:

            None of the above
            
Correct Answer: option A
Example:[29]

            A stack is a _____ data structure
          
Option A:

            FIFO
            
Option B:

            LIFO
            
Option C:

            In-built structure
            
Option D:

            None of the above
            
Correct Answer: option B

 Search Links


 Popular C search MCQs


 Popular C search examples