Baixe o app para aproveitar ainda mais
Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original
program aula01; var idade,idade2,i,t,mes,j,n1 : integer; nome : string; a : boolean; const pi = 3.14; distancia_da_terra_a_lua = 300000; velocidade_luz = 3000032432949234; procedure quadrado(n : integer); begin writeln('O quadrado de ',n,' vale ',n*n); end; function fat(y:integer) : integer; var x: integer; begin fat := 1; for x := 1 to y do fat := fat*x; end; begin // palavras reservadas e identificadores // ex: and, if, for, while, string.... // estrutura basica de um programa pascal // variaveis,constantes // inteiro, real, logico, caractere, string... // constantes // operadores e expressoes // aritmeticos: +,-,*,/,div,mod // logicos:and,or,xor,not // relacionais: >,<,=,!= idade := 33; idade2 := 66; idade2 := 40; i := idade + (idade2*2) + 12; // comandos de entrada e saida writeln(i); writeln('Por favor, informe o valor de t: '); readln(t); writeln(''); writeln('o valor de t eh: ',t); // condicional - tomando decisoes // if para condicoes simples, case para multiplas condicoes if (t > 10) then writeln('eh maior que 10') else writeln('eh menor que 10'); writeln('Informe o numero do mes: '); readln(mes); case mes of 1 : writeln('janeiro'); 2 : writeln('fevereiro'); 3 : writeln('marco'); else writeln('mes errado'); end; // estruturas de repeti‡Æo (la‡os,loops) for i := 1 to 10 do for j := 1 to 10 do begin write(i*j); write(','); end; writeln(''); writeln('while'); j := 50; while (j < 100) do begin write(j,','); j := j + 1; end; writeln(''); writeln('repeat:'); repeat write(j,''); // va para a lina 3 j := j+1; until j > 100; writeln(''); writeln('quadrado'); // funcoes e procedimentos n1 := 10; quadrado(n1); //writeln('quadrado'); writeln(''); writeln('fatorial'); //n1 := 22; n1 :=fat(7); writeln('O fatorial ‚ ',n1); readln; end. -------------------------------------------------------------------------------------------------------------------------------- program calcular_imc; var peso, altura, resultado_imc : real; function imc(peso,altura:real) : real; begin imc := peso/(altura*altura); end; begin writeln('SOFTWARE DE CALCULO DO IMC'); writeln('Informe o seu peso (Kg): '); readln(peso); writeln('Informe a sua altura (m): '); readln(altura); resultado_imc := imc(peso,altura); writeln('O seu IMC ‚: ',resultado_imc:3:2); if (resultado_imc < 20) then writeln('Vocˆ est MAGRO(A)') else if (resultado_imc > 25) then writeln('Voce est GORDO(A)') else writeln('Parabens, vocˆ est no peso ideal - FITNESS'); readln; end. -------------------------------------------------------------------------------------------------------------------------------- program academico; var nota1,nota2,nota3,media,nef : real; begin writeln('Sistema Academico'); writeln('Informe a nota 1: '); readln(nota1); writeln('Informe a nota 2: '); readln(nota2); writeln('Informe a nota 3: '); readln(nota3); media := (nota1+nota2+nota3)/3; writeln('A media parcial ‚: ',media); if (media < 4) then writeln('REPROVADO') else if (media >= 7) then writeln('APROVADO') else begin writeln('ALUNO ESTµ NA FINAL'); writeln('Informe a NEF' ); readln(nef); media := (media + nef)/2; writeln('Media final: ',media); if (media >=5.0) AND (nef >= 5.0) then writeln('APROVADO NA FINAL') ELSE writeln('REPROVADO NA FINAL'); end; readln; end.
Compartilhar