Advertisements

Search results for for

Example:[1]

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

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

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

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

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

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

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

            What is the output of the following program?
#include <stdio.h>
int main()
{
	const int array[5] = {0,1,2,3};
	for(int i = 0;i < 4;i++)
	{
		array[i] += 1;
		printf("%d\n", array[i]);	
	}
}

          
Option A:

            1,2,3,4
            
Option B:

            0,1,2,3
            
Option C:

            2,3,4,5
            
Option D:

            Compile error
            
Correct Answer: option D
Example:[11]

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

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

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

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

            Which of the following is true for the statement:
school.nursery.students = 10;
          
Option A:

            The structure students is nested within the structure nursery.
            
Option B:

            The structure school is nested within the structure nursery.
            
Option C:

            The structure nursery is nested within the structure school.
            
Option D:

            The structure nursery is nested within the structure students. 
            
Correct Answer: option C
Example:[17]

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

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

            For implementing recursive function the data structure used is:
          
Option A:

            Queue
            
Option B:

            Stack
            
Option C:

            Linked List
            
Option D:

            Tree
            
Correct Answer: option B
Example:[20]

            Linked lists are not suitable data structures for which one of the following problems
          
Option A:

            insertion sort 
            
Option B:

            binary search
            
Option C:

            radix sort 
            
Option D:

            polynomial manipulation
            
Correct Answer: option B
Example:[21]

            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