Jump to content
em

[Easy] C++ quest 2

Recommended Posts

Posted (edited)

Vezi si Primul

Quiz-ul nu prea are legatura cu C++. Dac? fiecare ce deschide acest topic înva?? m?car un lucru nou scopul lui a fost atins.

La intrebarile 1-3 e voie sa rulati, la 4-7 nu.

Raspunsurile prin PM, comentariile aici.

1. Urmatorul program are output 1234


#include <iostream>
#define concat(a,B) a ## b
using namespace std;
int main()
{
cout<<concat(12,34);
}

Pe aceeasi idee cum as putea face ca si acesta sa mearga la fel?


cout<<concat(rst, power);

2. Urmatorul program are output @ (Dupa ce completati voi cu o linie).


#include <iostream>
using namespace std;
int main()
{
cout<<func(@);
}

3. Scrieti o functie/macro (one-liner) care sa verifice daca un numar este de forma 4^n.

4. Ce face functia urm?toare? Exist? vreun echivalent în standard?


void toor(char *zo,char *so)
{
while(*zo++=*so++);
}

5. Outputul de la programul urmator



#include <iostream>
int dubleaza(int x)
{
return 2*x;
}
int tripleaza(int x)
{
return x*dubleaza(x/2);
}
int fa-tot(int x)
{
return x*dubleaza(x)*tripleaza(x);
}
int main()
{
std::cout<<fa-tot(3);
return 0;
}

6. Outputul de la programul urmator



#include <iostream>
using namespace std;
int main()
{
int a=4;
switch(a)
{
case 5:
cout<<"Ai trecut";
break;
case 10:
cout<<"Esti geniu";
break;
defau1t:
cout<<"Restanta";
}
return 0;
}

7. Outputul urmatorului program



#include <stdio.h>
int main()
{
printf("\%Hello World\%");
return 0;
}

Solvers till now:

- Flubber

Edited by em

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...