Baixe o app para aproveitar ainda mais
Prévia do material em texto
1 // F9 -> Compilar F10 -> Executar F11 -> Compilar e Executar 2 3 //BIBLIOTECAS 4 #include <stdio.h> // Funções de Entrada 5 #include <stdlib.h> // Funções Padrão 6 7 // CORPO DO PROGRAMA 8 int main(){ ou void main() { //Inicio 9 10 //DECLARAÇÃO DE VARIÁVEIS 11 // Tipos: Int(%d) -> inteiro; Float(32Bits) e Double(64Bits) (%f) -> Decimais; Char (%c) -> Caractere; 12 int x1, y1, result1; // Declarando as Variáveis globais do tipo Int 13 int x = 1, y = 1, result = 0; // Declaração de Variáveis globais atribuindo Valores iniciais 14 float result2; // Variável Global do tipo float 15 16 //Obs: Ex: " i-- " -> i = i - 1 (Decrementa) ou " i++ " -> i = i + 1 (Incrementa) 17 18 // ENTRADA OU LEITURA DE DADOS 19 scanf("%d", &x1); // Ler Variável x1 20 scanf("%d", &y1); // ler Variável y1 21 22 //BLOCOS DE COMANDOS 23 result = x + y; // OBS: " = " -> Receber ou atribuir " == " -> igual 24 result1 = x1 + y1; 25 float result2 = (result1 / 3); 26 27 // ESTRUTURAS DE DECISÃO " if " ou " if else " 28 if(/*Condição 1*/){ // se 29 // Bloco de Comandos 30 }else if(/*condição 2*/){ // senão se 31 // Bloco de Comandos 32 }else{ // senão 33 // Bloco de Comandos 34 } 35 36 // if e else sem {} 37 if(/*Condição 1*/) 38 // Bloco de Comandos 39 else 40 // Bloco de Comandos 41 42 // ESTRUTURAS DE REPETIÇÃO " WHILE " 43 44 while(/*Condição*/) { // Enquanto a condição for verdadeira o while vai rodar 45 // Bloco de Comandos 46 } 47 48 // ESTRUTURAS DE REPETIÇÃO " FOR " 49 50 for (i = 0; i > 0; i++ /*i--*/){ // for (var = inicio; condição; incremento) 51 // Bloco de Comandos 52 break; // Caso necessário 53 } 54 55 //switch case 56 57 int operador; 58 printf("Qual operdaor deseja escolher?\n"); 59 scanf("%d", &operdador); // 60 switch(operador){ 61 case 1: 62 // Bloco de Comandos 63 break; 64 case 2: 65 // Bloco de Comandos 66 break; 67 case 2: 68 // Bloco de Comandos 69 break; 70 default: // Caso nenhuma das opções seja escolhida 71 // Bloco de Comandos 72 } 73 74 // SAÍDA OU ESCRITA DE DADOS 75 printf("Calculadora de soma: \n"); // Escrever (\n -> Pular linha) 76 printf("O valor da soma eh: %d ", result1); // Escrever 77 printf("O valor da soma eh: %f ", result2); // Escrever 78 printf("O valor da soma eh: %.2f ", result2); // Escrever 79 80 printf("cont = %d|soma = %d|ValoraSomar = %d\n", cont, soma, ValoraSomar); // Passo a passo 81 82 // COMANDO DE PARADA DO SISTEMA 83 system("pause"); 84 85 } //FIM 86
Compartilhar