Advertisement
Drowze

04 Comando de Repeticao for 04

Mar 31st, 2014
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. /* Faça um programa que calcule a soma dos números divisíveis por 3 entre 1 e 20.*/
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. void main()
  7. {
  8.     int i,soma;
  9.     soma=0;
  10.  
  11.     for(int i=1;i<=20;i++)
  12.     {
  13.         if(i%3==0)
  14.         {
  15.             printf("%d + %d = ",soma,i);
  16.             soma=soma+i;
  17.             printf("%d\n",soma);
  18.         }
  19.     }
  20.     printf("\nSoma = %d",soma);
  21.  
  22.     system("pause");
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement