Buscar

18.What is the output of the program if characters 'h', 'e', 'l', 'l' , 'o' and enter are supplied as input? #include #include ...

18.What is the output of the program if characters 'h', 'e', 'l', 'l' , 'o' and enter are supplied as input?
#include
#include
using namespace std;
void f();
int main()
{
f();
return 0;
}
void f()
{
char c;
c = cin.get();
cout << c;
9 / 16 if(c != '\n')
f();
}
A.It prints: hello
B.It prints: olleh
C.It prints: h
D.It prints: o
Answer: A


A.It prints: hello
B.It prints: olleh
C.It prints: h
D.It prints: o

Essa pergunta também está no material:

C Certified Associate Programmer CPA Dumps
16 pág.

Ensino Médio LaSalle TechLaSalle Tech

💡 1 Resposta

User badge image

Ed Verified user icon

A resposta correta é a alternativa A) It prints: hello. O programa lê os caracteres digitados pelo usuário e os imprime na tela. A função f() é chamada recursivamente até que o caractere digitado seja um '\n' (enter), momento em que a recursão é interrompida e a função retorna. Portanto, se os caracteres 'h', 'e', 'l', 'l', 'o' e enter forem fornecidos como entrada, o programa irá imprimir "hello".

0
Dislike0

✏️ Responder

SetasNegritoItálicoSublinhadoTachadoCitaçãoCódigoLista numeradaLista com marcadoresSubscritoSobrescritoDiminuir recuoAumentar recuoCor da fonteCor de fundoAlinhamentoLimparInserir linkImagemFórmula

Para escrever sua resposta aqui, entre ou crie uma conta

User badge image

Outros materiais