Advertisement
truko

tabuada

Aug 30th, 2019
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4.  
  5. int tabuada_for(int n)
  6. {
  7.     printf("TABUADA FOR\n");
  8.     int temp=0;
  9.     for(int i=1;i<=10;i++)
  10.     {
  11.         temp = n * i;
  12.         printf("%d x %d = %d\n", i, n, temp);
  13.     }
  14.     return 0;
  15. }
  16.  
  17. int tabuada_while(int n)
  18. {
  19.     printf("TABUADA WHILE\n");
  20.     int temp=0, i=1;
  21.     while(i <= 10)
  22.     {
  23.         temp = n * i;
  24.         printf("%d x %d = %d\n", i, n, temp);
  25.         i++;
  26.     }
  27.     return 0;
  28. }
  29.  
  30. int tabuada_do_while(int n)
  31. {
  32.     printf("TABUADA DO WHILE\n");
  33.     int temp=0, i=1;
  34.     do
  35.     {
  36.         temp = n * i;
  37.         printf("%d x %d = %d\n", i, n, temp);
  38.         i++;
  39.     }
  40.     while(i <= 10);
  41.     return 0;
  42. }
  43.  
  44. int main(void)
  45. {
  46.     int x, y, z;
  47.     printf("Valor pra tabuada for: \n");
  48.     scanf("%d", &x);
  49.     printf("Valor pra tabuada while: \n");
  50.     scanf("%d", &y);
  51.     printf("Valor pra tabuada do while: \n");
  52.     scanf("%d", &z);
  53.     printf("\n");
  54.     tabuada_for(x);
  55.     printf("\n");
  56.     tabuada_while(y);
  57.     printf("\n");
  58.     tabuada_do_while(z);
  59.     printf("\n");
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement