Advertisement
CarlosWGama

Aula Estrutura de Dados 02 - Revisão C

Jul 27th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <locale.h>
  4.  
  5. void telaSoma() {
  6.     int numero1, numero2;
  7.  
  8.     system("cls");
  9.     printf("Digite o primeiro número:\n");
  10.     scanf("%d", &numero1);
  11.     printf("Digite o primeiro número 2:\n");
  12.     scanf("%d", &numero2);
  13.  
  14.     printf("A soma dos valores é: %d", (numero1 + numero2));
  15.     getch();
  16. }
  17.  
  18. void telaATM() {
  19.     int valor;
  20.     system("cls");
  21.     printf("Digite um valor:\n");
  22.     scanf("%d", &valor);
  23.  
  24.     //Notas de 100
  25.     int notas = (valor/100);
  26.     if (notas > 0) {
  27.         printf("Notas de 100: %d\n", notas) ;
  28.         valor %= 100;
  29.     }
  30.     //Notas de 50
  31.     notas = (valor/50);
  32.     if (notas > 0) {
  33.         printf("Notas de 50: %d\n", notas) ;
  34.         valor %= 50;
  35.     }
  36.     //Notas de 20
  37.     notas = (valor/20);
  38.     if (notas > 0) {
  39.         printf("Notas de 20: %d\n", notas);
  40.         valor %= 20;
  41.     }
  42.  
  43.     //Notas de 10
  44.     notas = (valor/10);
  45.     if (notas > 0) {
  46.         printf("Notas de 10: %d\n", notas);
  47.         valor %= 10;
  48.     }
  49.  
  50.     //Notas de 5
  51.     notas = (valor/5);
  52.     if (notas > 0) {
  53.         printf("Notas de 5: %d\n", notas);
  54.         valor %= 5;
  55.     }
  56.  
  57.     //Notas de 1
  58.     if (valor > 0) {
  59.         printf("Notas de 1: %d\n", valor);
  60.     }
  61.  
  62.     getch();
  63. }
  64.  
  65. int main() {
  66.     setlocale(LC_ALL, "");
  67.    int opc;
  68.  
  69.    do {
  70.         system("cls");
  71.         printf("1 - Realizar Soma de dois números\n");
  72.         printf("2 - Sistema ATM\n");
  73.         printf("3 - Sair do Sistema\n");
  74.         scanf("%d", &opc);
  75.  
  76.         if (opc == 1) {
  77.             telaSoma();
  78.         } else if (opc == 2) {
  79.             telaATM();
  80.         }
  81.  
  82.    } while(opc != 3);
  83.  
  84.    return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement