Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- struct Question{
- const char* Pergunta;
- const char* Resposta;
- const char* Alternativas[4];
- };
- int main()
- {
- Question Perguntas[2];
- Perguntas[0] =
- {
- "Quanto e 1+1?", //pergunta
- "2", //resposta
- {
- "1", "2", "3", "4" //alternativas
- }
- };
- Perguntas[1] =
- {
- "Quanto e 5+1?",
- "6",
- {
- "1", "2", "3", "6"
- }
- };
- printf("Bem-vindo ao quiz.\n");
- int Resposta = 0;
- while(true)
- {
- for(int i = 0; i < _countof(Perguntas); i++)
- {
- printf("%s\n",Perguntas[i].Pergunta);
- for(int j = 0; j < 4; j++)
- {
- printf("[%d] %s\n", j, Perguntas[i]. Alternativas[j]);
- }
- printf("\nDigite: ");
- scanf("%i", &Resposta);
- if(Resposta < 0 || Resposta > 3)
- {
- Resposta = -1;
- }
- else if(strcmp(Perguntas[i]. Alternativas[Resposta], Perguntas[i].Resposta) != 0)
- {
- Resposta = -1;
- }
- if(Resposta == -1)
- {
- printf("\nVoce errou.\n\n");
- }else{
- printf("\nVoce acertou.\n\n");
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement