Advertisement
AnandaVieira

Ex02

May 13th, 2021
719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Exercicios
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             /*2. Construa um programa que leia 5 valores e conte quantos destes valores são divisíveis por 3,
  11.             escrevendo esta informação.*/
  12.  
  13.             int cont = 0;
  14.  
  15.             for (int i = 0; i < 5; i++)
  16.             {
  17.                 Console.Write("Informe o valor: ");
  18.                 int a = int.Parse(Console.ReadLine());
  19.  
  20.                 if (a % 3 == 0)
  21.                 {
  22.                     cont = cont + 1;                
  23.                     Console.WriteLine("O valor de " + a + " é divisivel por 3 ");
  24.                 }
  25.  
  26.  
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement