Advertisements

Search results for do

Example:[1]

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

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

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

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

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

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

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

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

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

            A state machine in C programming is?
          
Option A:

             a way of structuring a program to structure it around a set of states and the events that can cause it to change state.
            
Option B:

            a way to go to a certain state no matter what the program does.
            
Option C:

            a way to recover the program from asserts.
            
Option D:

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

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

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

            Doubly linked list is more efficient than singly linked list for which of the following operation?

          
Option A:

            Inserting a given item at the middle of the list
            
Option B:

            Searching an item in an unsorted list
            
Option C:

            Deleting a node from a given position in the list
            
Option D:

            Traversing a list to display all items in the list
            
Correct Answer: option C

 Search Links


 Popular C search MCQs


 Popular C search examples