NCR: Written Test for experienced C/C++ professional
Question 1: Reverse words in the given string âthis is itâ Output should be âit is thisâ
Void reverseWordsOfString(char *str){// Implement }
Question 2: If we call myFunc(n) with the below provide definition, what will be the output?
int myFunc(int n)
{ While(n--)
{ Switch(--n)
{ case 1:printf(â\n%dâ,n);
default:printf(â\n%dâ,n);
return myFunc(--n);
break;
case 0:printf(â\n%dâ,n);
break;
case 2:printf(â\n%dâ,n);
break; }
}If (n==0)
Return 0; }
Question 3:Critque the above program , and suggest any correction needs to be done in the respect of code style, logic,..etc.
Question 4: What is the output of the below program. If there any errors , mention line numbers and correct them.
#include using namespace std;
class A{ public: virtual display_A(A *obj)
{
cout<<âclass Aâ<display_A(&obja);
pObja->display_A(&objb);
pObja->display_B(&objb);
pObja->display_A(&objc);
return 0;
}