C++ MCQ’s

C++ MCQ’s Home Page

C++ Basic 1
C++ Basic 2
C++ Basic 3
C++ Basic 4
C++ Basic 5
C++ OOPs Concepts 1
C++ OOPs Concepts 2
C++ OOPs Concepts 3
C++ OOPs Concepts 4
C++ OOPs Concepts 5

 

C++ MCQ’S | Basics 1

16.
What happens if the following program is executed in C and C++?

#include<stdio.h>
int main()
{
abc();
}
int abc()
{
printf(“Hello World”);
return 0;
}

a) Error in both C and C++
b) Warning in both C and C++
c) Error in C++ but Warning in C
d) Error in C but Warning in C++

17.
What happens if the following line is executed in C and C++?

int *p = malloc(10);

a) Error in both C and C++
b) Warning in both C and C++
c) Error in C++ and successful execution in C
d) Error in C and successful execution in C++

 

18.
What happens if the following line is executed in C and C++?

const int a;

a) Error in both C and C++
b) Warning in both C and C++
c) Error in C and successful execution in C++
d) Error in C++ and successful execution in C

 

19.
What happens if the following program is executed in C and C++?

#include <stdio.h>
int main(void)
{
int new = 5;
printf(“%d”, new);
}

a) Error in both C and C++
b) A successful run in both C and C++
c) Error in C and successful execution in C++
d) Error in C++ and successful execution in C

 

20.
What happens if the following program is executed in C and C++?

#include <stdio.h>
void main()
{
printf(“Hello World”);
}

a) Error in both C and C++
b) Successful run in both C and C++
c) Error in C and successful execution in C++
d) Error in C++ and successful execution in C