Advertisement
AnandaVieira

Ex01

May 13th, 2021
764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Exercícios
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             /*1. Construa um programa que leia 5 valores e conte quantos destes valores são negativos,
  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 <= 0)
  21.                 {
  22.                     cont = cont + 1;
  23.                 }
  24.             }
  25.  
  26.             Console.WriteLine("A quantidade de números negativos digitados são: " + cont);
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement