Visual basic

453 palavras 2 páginas
1) Qual é o valor exibido no seguinte código:
2)
3) int total = 2;
4) for (int i = 0; i < 5; i += 1)
5) {
6)
7) total = total * 2;
8) }
9) MessageBox.Show("O total é: " + total);
10)
11) • 256
12) • 64
13) • 128
14) • 512
15)
Resposta:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

int total = 2; for (int i = 0; i < 5; i++) { total *= 2;

} Console.WriteLine("total = "+total); Console.ReadKey();
64

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

2) FPC# que imprima a soma dos números de 1 até 1000.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> int y =0;

for (int x = 1; x <= 1000; x++) {

y += x;

} Console.Write(y); Console.ReadKey();

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

3) FPC# que imprima todos os múltiplos de 3, entre 1 e 100. Para saber se um número é múltiplo de 3, você pode fazer if(numero % 3 == 0).
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
for (int i = 0; i <=100; i++) { if(i % 3 == 0)

Console.WriteLine(i); } Console.ReadKey();
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

4) FPC# que some todos os números de 1 a 100, pulando os múltiplos de 3 O programa deve imprimir o resultado final em uma MessageBox. Qual o resultado?

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> int cont = 0; for (int i = 0; i <=100; i++) { if(i % 3 != 0) cont+=i;

} Console.WriteLine(cont); Console.ReadKey(); 5) FPC# que imprime todos os

Relacionados

  • Visual basic
    1652 palavras | 7 páginas
  • Visual Basic
    1031 palavras | 5 páginas
  • Visual Basic
    584 palavras | 3 páginas
  • Visual Basic
    4496 palavras | 18 páginas
  • Visual basic
    287 palavras | 2 páginas
  • Visual basic
    26342 palavras | 106 páginas
  • visual basic
    5355 palavras | 22 páginas
  • visual basic
    4517 palavras | 19 páginas
  • Visual basic
    1088 palavras | 5 páginas
  • visual basic
    533 palavras | 3 páginas