11.07.2015 Views

Lista 03a - DCC/UFMG

Lista 03a - DCC/UFMG

Lista 03a - DCC/UFMG

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

26) Criar um algoritmo em PORTUGOL que leia os limites inferior e superior de umintervalo e imprima todos os números pares no intervalo aberto e seu somatório.Suponha que os dados digitados são para um intervalo crescente, ou seja, o primeirovalor é menor que o segundo.algoritmo L3P026;varinteiro: INF,SUP,C,SOMA;inícioleia(INF,SUP);SOMA ← 0;para C de INF+1 até SUP-1 façase ( C mod 2 = 0 ) entãoimprima( C );SOMA ← SOMA + C;fim-sefim-paraimprima("O valor da soma é: ",SOMA);fimprogram l3p026;varINF,SUP,C,SOMA: integer;beginwrite('Entre com o limite Inferior: ');readLn(INF);write('Entre com o limite Superior: ');readLn(SUP);SOMA := 0;for C := INF+1 to SUP-1 dobeginif ( C mod 2 = 0 ) then beginwriteLn( C );SOMA := SOMA + C;end;end;writeLn('O valor da soma eh: ',SOMA);end.INF = input('Entre com o limite Inferior: ');SUP = input('Entre com o limite Superior: ');SOMA = 0;for C = INF+1 : SUP-1if ( mod( C , 2 ) == 0 )disp( C );SOMA = SOMA + C;endendfprintf(1,'O valor da soma eh: %d\n',SOMA);<strong>UFMG</strong> – ICEx – <strong>DCC</strong> – Programação de Computadores – 2º. Sem 2005 – David Menoti 26

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!