Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <strings.h>
- #include <ctype.h>
- struct Perguntas {
- char texto[200];
- char resposta_correta;
- int pontos;
- };
- struct Teste {
- struct Perguntas perguntas[10];
- char resposta[10];
- };
- int main() {
- struct Teste teste;
- system("cls");
- printf("Bem vindo ao teste!!!\n");
- strcpy(teste.perguntas[0].texto,"\n\nPrintf eh um:\na)erro de codificacao\nb)com.de entrada de dados\nc)com.de saida de dados");
- teste.perguntas[0].resposta_correta = 'C';
- teste.perguntas[0].pontos = 2;
- strcpy(teste.perguntas[1].texto,"\n\nScanf eh um:\na)erro de codificacao\nb)com.de entrada de dados\nc)com.de saida de dados");
- teste.perguntas[1].resposta_correta = 'B';
- teste.perguntas[1].pontos = 1;
- strcpy(teste.perguntas[2].texto,"\n\nError eh um:\na)erro de codificacao\nb)com.de entrada de dados\nc)com.de saida de dados");
- teste.perguntas[2].resposta_correta = 'A';
- teste.perguntas[2].pontos = 3;
- int i;
- for(i=0;i<3;i++) {
- printf("%s \n\nResposta .: ",teste.perguntas[i].texto);
- teste.resposta[i] = getche();
- }
- int totalpontos = 0;
- for(i=0;i<3;i++) {
- if (teste.perguntas[i].resposta_correta == toupper(teste.resposta[i]))
- totalpontos = totalpontos + teste.perguntas[i].pontos;
- }
- printf("\n\nO total de pontos acumulados foi %i . \n\n",totalpontos);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement