Baixe o app para aproveitar ainda mais
Prévia do material em texto
ALGORITMOS AULA DE REVISÃO AV1 RAV1 ALGORITMOS Atenção aos Temas Principais dessa Aula RAV1 ALGORITMOS Conteúdo Programático desta aula Revisão dos principais assuntos ministrados nas Aulas de 1 até 5; RAV1 ALGORITMOS Direto ao Assunto RAV1 ALGORITMOS RAV1 ALGORITMOS Dentro desse símbolo, poderemos encontrar: RAV1 ALGORITMOS É um dos quatro comandos básicos da programação. Consiste em se atribuir um valor a uma variável. RAV1 ALGORITMOS Dentro desse símbolo, poderemos encontrar: RAV1 ALGORITMOS se simples se composto RAV1 ALGORITMOS ses encadeados RAV1 ALGORITMOS RAV1 ALGORITMOS RAV1 ALGORITMOS A variável pode ser definida como sendo um endereço, ou mais de um endereço, na memória principal que armazena dados/ informações e cujo valor poderá ser alterado durante a execução do programa. A esse endereço será associado a um nome. RAV1 ALGORITMOS Todos os comandos deverão ser colocados entre inicio e fim. RAV1 ALGORITMOS escrever variável escrever constante numérica escrever "texto" escrever [expressão] escrever variável , "texto" ,. . . escrever dia escrever “Entendi” escrever 23 escrever 23 + 89 Portugol RAV1 ALGORITMOS Muitas linguagens aceitam undescore (_) além dos algarismos e letras não acentuadas. Atenção para palavras reservadas. Mas para facilitar, nesse primeiro momento, e atender às três linguagens algorítmicas, vamos adotar aqui as seguintes regras: 1o caracter -> letra A partir do segundo, letra ou algarismo. Regras para se nomear variáveis RAV1 ALGORITMOS É um dos quatro comandos básicos da programação. Consiste em se atribuir um valor a uma variável. Portugol RAV1 ALGORITMOS Portugol ler nomeVariável ler nVar1, nVar2 ler nome ler idade ler altura, peso RAV1 ALGORITMOS Portugol se simples se composto RAV1 ALGORITMOS Portugol ses encadeados RAV1 ALGORITMOS Portugol RAV1 ALGORITMOS Portugol RAV1 ALGORITMOS O cabeçalho é obrigatório: programa nome. As declarações das variáveis são posicionadas depois do comando declaracoes e os demais comandos serão colocados entre inicio e fim. Estrutura da Linguagem Algorítmica WEBportugol RAV1 ALGORITMOS escreva( variável ) escreva( constante numérica ) escreva( "texto") escreva("texto“, variável) escreva( dia) escreva( “Entendi”) escreva( 23 ) escreva( “soma: “, s) WEBportugol RAV1 ALGORITMOS Regras para se nomear variáveis Muitas linguagens aceitam undescore (_) além dos algarismos e letras não acentuadas. Atenção para palavras reservadas. Mas para facilitar, nesse primeiro momento, e atender às três linguagens algorítmicas, vamos adotar aqui as seguintes regras: 1o caracter -> letra A partir do segundo, letra ou algarismo. RAV1 ALGORITMOS É um dos quatro comandos básicos da programação. Consiste em se atribuir um valor a uma variável. WEBportugol RAV1 ALGORITMOS WEBportugol leia( nomeVariável) leia( nVar1, nVar2) leia(nome) leia(idade) leia (altura, peso) RAV1 ALGORITMOS WEBportugol se simples se composto RAV1 ALGORITMOS WEBportugol ses encadeados RAV1 ALGORITMOS O cabeçalho é obrigatório: prog xxx. Todos os comandos deverão ser posicionados entre os comandos prog e fimprog, começando pela declaração das variáveis. Estrutura da Linguagem Algorítmica UAL RAV1 ALGORITMOS imprima variável; imprima constante numérica; imprima "texto"; imprima [expressão]; imprima variável , "texto", . . .; imprima dia; imprima “Entendi”; imprima 23; imprima 23 + 89; UAL RAV1 ALGORITMOS Os caracteres de controle \n e \t são usados com o comando imprima(escrever ou escreva) para que o programador possa decidir, parcialmente, onde mensagem, conteúdo de variável, constante, etc, será exibido. O \t não está disponível no WEBportugol RAV1 ALGORITMOS Regras para se nomear variáveis Muitas linguagens aceitam undescore (_) além dos algarismos e letras não acentuadas. Atenção para palavras reservadas. Mas para facilitar, nesse primeiro momento, e atender às três linguagens algorítmicas, vamos adotar aqui as seguintes regras: 1o caracter -> letra A partir do segundo, letra ou algarismo. RAV1 ALGORITMOS É um dos quatro comandos básicos da programação. Consiste em se atribuir um valor a uma variável. UAL RAV1 ALGORITMOS UAL leia nomeVariável; leia nome; leia idade; leia altura; RAV1 ALGORITMOS UAL se simples se composto RAV1 ALGORITMOS UAL ses encadeados RAV1 ALGORITMOS Operadores Aritméticos RAV1 ALGORITMOS Uma expressão relacional O TESTE RAV1 ALGORITMOS O TESTE RAV1 ALGORITMOS Exemplos Obs: Todos os operadores Relacionais têm a mesma hierarquia. RAV1 ALGORITMOS O TESTE Duas, ou mais, expressões relacionais RAV1 ALGORITMOS O TESTE RAV1 ALGORITMOS O TESTE Binário Binário RAV1 ALGORITMOS O TESTE Unário RAV1 ALGORITMOS Exemplos Obs: !(nao) tem maior hierarquia, seguido do &&(and) e, depois, ||(ou) RAV1 ALGORITMOS RAV1 ALGORITMOS RAV1 ALGORITMOS iostream cstring cmath cctype iomanip cstdlib ... RAV1 ALGORITMOS #include <iostream> #include “anita.h” RAV1 ALGORITMOS RAV1 ALGORITMOS RAV1 ALGORITMOS cout<< ... << ....<< ... ; RAV1 ALGORITMOS Declarando Variável – C++ A linguagem aceita undescore (_) além dos algarismos e letras não acentuadas. Atenção para palavras reservadas. Mas para facilitar, nesse primeiro momento, e atender às três linguagens algorítmicas, vamos adotar aqui as seguintes regras: 1o caracter -> letra A partir do segundo, letra ou algarismo. Regras para se nomear variáveis RAV1 ALGORITMOS nomeVar = nomeVar <op> valor; nomeVar <op>= valor; RAV1 ALGORITMOS cin>>altura; cin>>AV1>>AV2>>AV3; RAV1 ALGORITMOS RAV1 ALGORITMOS if simples if composto RAV1 ALGORITMOS ifs encadeados RAV1 ALGORITMOS RAV1 ALGORITMOS RAV1 ALGORITMOS VAMOS PRATICAR RAV1 ALGORITMOS O operador %(mod) 151118 O Problema da Data RAV1 ALGORITMOS 151118 dia 1)O Problema da Data 100000 10000 1000 100 10 1 RAV1 ALGORITMOS dia div / 100000 10000 1000 100 10 1 O Problema da Data 151118 RAV1 ALGORITMOS dia div / 151118 10000 100000 10000 1000 100 10 1 O Problema da Data 151118 RAV1 ALGORITMOS mes 100000 10000 1000 100 10 1 O Problema da Data 151118 RAV1 ALGORITMOS mes div / 100000 10000 1000 100 10 1 O Problema da Data 151118 RAV1 ALGORITMOS mes div / 151118 100 100000 10000 1000 100 10 1 O Problema da Data 151118 RAV1 ALGORITMOS 1511 mes 1000 100 10 1 O Problema da Data RAV1 ALGORITMOS mes % mod 1000 100 10 1 O Problema da Data 1511 RAV1 ALGORITMOS mes % mod 100 1000 100 10 1 O Problema da Data 1511 RAV1 ALGORITMOS ano 100 % mod 10000 1000 100 10 1 151118 O Problema da Data 151118 RAV1 ALGORITMOS 2) Usando errado a Estrutura do se...entao...senao RAV1 ALGORITMOS 2) Usando errado a Estrutura do se...entao...senao CORRIGIDO RAV1 ALGORITMOS 3) Entendo o break no switch() RAV1 ALGORITMOS 4) Menu com switch() RAV1 ALGORITMOS cout<<"\n\n========\n"; cout<<"\nOperacao\n"; cout<<"\n+ Somar"; cout<<"\n- Subtrair"; cout<<"\n* Multiplicar"; cout<<"\n/ dividir";cout<<"\nOpcao: "; cin>> aula; 4) Menu com switch() RAV1 ALGORITMOS 4) Menu com switch() RAV1 ALGORITMOS 5) Reajuste Salarial RAV1 ALGORITMOS 5) Reajuste Salarial RAV1 ALGORITMOS 5) Reajuste Salarial RAV1 ALGORITMOS 6) IMC RAV1 ALGORITMOS RAV1 ALGORITMOS Manipular dados/informações é, com certeza, uma das principais funções de um computador. O dado é um valor fornecido pelo usuário, gerado pelo programa ou lido de um arquivo Origem do Dado RAV1 ALGORITMOS Resumindo
Compartilhar