Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main (){
- int ent = 0;
- char ind[1];
- int ele = 0, indice = 0, pos = 0, neg = 0, total = 0;
- float media = 0;
- printf("Entre com uma quantia de números: digite 0 para terminar\n");
- do{
- scanf("%d", &ent);
- if(ent == 0)
- break;
- total++;
- media += ent;
- if(ent > 0)
- pos++;
- if(ent < 0)
- neg++;
- }while(1);
- do{
- printf("Escolha uma das opcoes do menu abaixo:\n\n");
- printf("\n1- Para imprimir a média aritmética dos valores lidos;");
- printf("\n2- Para imprimir quantidade de valores positivos; ");
- printf("\n3- Para imprimir quantidade de valores negativos; ");
- printf("\n4- Para imprimir o percentual de valores negativos e positivos.");
- printf("\ns - Sair\nOpção:\n");
- scanf("%s",ind);
- switch(ind[0]){
- case '1':
- printf("Média: %.2f\n", media/total);
- break;
- case '2':
- printf("Números positivos: %d\n", pos);
- break;
- case '3':
- printf("Números negativos: %d\n", neg);
- break;
- case '4':
- printf("Percentual positivo: %.2f\n Percentual negativo: %.2f\n", (float)100*pos/total, (float)100*neg/total);
- break;
- case 's': break;
- default:
- printf("Opção inválida");
- break;
- }
- }while(ind[0] != 's');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement