-
-
Save InacioCarvalhoOliveira/705031ca8b332ec77e7b3aa1549e46f8 to your computer and use it in GitHub Desktop.
exercises in C language_ basics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int main(){ | |
int numeroInteiro = 10; | |
float numeroReal = 3.75; | |
printf("O numero Inteiro eh: %d",numeroInteiro); | |
printf("\nO numero Real eh: %.2f",numeroReal); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
// Leia o tamanho do lado de um quadrado e imprima como resultado a sua área : | |
int main() { | |
int quadrado = 8 ; | |
printf("O tamanho de um lado do quadrado e:%dcm" , quadrado); | |
printf("\nA area do quadrado e: %dcm ",quadrado*quadrado); | |
printf("\n\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/* Leia o valor do raio de um círculo e calcule a área do círculo correspondente. Imprima o | |
resultado dessa operação. A área do círculo é 𝜋 ∗ 𝑟𝑎𝑖𝑜², considere 𝜋 = 3,141592 */ | |
int main() { | |
int raio = 12; | |
float raioquadrado = raio * raio; | |
printf("O valor do raio do circulo e:%d" , raio); | |
printf("\nA area do circulo e: %.2f " , 3.14* raioquadrado); | |
printf("\n\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Sejam 𝑎 e 𝑏 os catetos de um triângulo, onde a hipotenusa é obtida pela equação: | |
ℎ𝑖𝑝𝑜𝑡𝑒𝑛𝑢𝑠𝑎 = √𝑎2 + 𝑏2. Faça um programa que receba os valores de 𝑎 e 𝑏 e encontre o | |
valor da hipotenusa através da equação. Imprima no final o resultado dessa operação. */ | |
int main() { | |
int num1, num2, num3; | |
float hipotenusa; | |
printf("Insira o primeiro valor: "); | |
scanf("%d", &num1); | |
printf("Insira o segundo valor: "); | |
scanf("%d", &num2); | |
hipotenusa = sqrt((num1* num1) + (num2* num2)); | |
printf("A hipotenusa dos valores eh = %.2f", hipotenusa); | |
printf("\n\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/* . Leia a altura e o raio de um cilindro circular e imprima o volume do cilindro. O volume de | |
um cilindro circular é calculado por meio da seguinte fórmula: V = 𝜋 ∗ 𝑟𝑎𝑖𝑜2∗ 𝑎𝑙𝑡𝑢𝑟𝑎, onde𝜋 = 3,141592 .*/ | |
int main() { | |
int altura = 4; | |
printf("A altura do cilindro eh: 4"); | |
int raio = 2; | |
printf("\nO raio do cilindro eh: 2"); | |
float volume = 3.14 * (raio*raio) * altura; | |
printf("\nO volume do cilindro eh: %.2f" , volume); | |
printf("\n\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/* Faça um programa que possa entrar com o valor de um produto e imprima o valor tendo | |
em vista que o desconto foi de 12% */ | |
int main() { | |
float valor, desconto, vfinal; | |
printf("Digite o preco do produto:"); | |
scanf("%f" , &valor); | |
desconto = valor * 0.12; | |
vfinal = valor - desconto; | |
printf("\nO valor com desconto eh: %.2f" ,vfinal); | |
printf("\n\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include <stdio.h> | |
#include <stdlib.h> | |
/* A importância de R$ 780.000,00 será dividida entre três ganhadores de um concurso. | |
Sendo que da quantia total: | |
O primeiro ganhador receberá 46%; | |
O segundo receberá 32%; | |
O terceiro receberá o restante; | |
Calcule e imprima a quantia ganha por cada um dos ganhadores. */ | |
int main() { | |
float valor = 780.000; | |
printf("O valor total eh:R$%.3f", valor ); | |
float gan1, gan2, desc2, gan3, desc3; | |
gan1= valor * 0.46; | |
printf("\nPrimeiro ganhador recebe:R$%.3f", gan1); | |
gan2= valor * 0.32; | |
printf("\nPrimeiro ganhador recebe:R$%.3f", gan2); | |
gan3= valor * 0.22; | |
printf("\nPrimeiro ganhador recebe:R$%.3f", gan3); | |
printf("\n\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/* Uma empresa contrata um encanador a R$ 30,00 por dia. Crie um programa que solicite o | |
número de dias trabalhados pelo encanador e imprima a quantia líquida que deverá ser paga, | |
sabendo-se que são descontados 8% para imposto de renda. | |
*/ | |
int main() { | |
float dias; | |
printf("\nQuantos dias o encanador trabalhou? "); | |
scanf("%f" , &dias); | |
float sal = 30.00; | |
float ir, salfinal; | |
ir = sal * 0.08; | |
salfinal = sal - ir; | |
printf("\nO encanador recebera: R$%.2f" , salfinal * dias); | |
printf("\n\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/* Faça um programa que leia o valor da hora de trabalho (em reais) e número de horas | |
trabalhadas no mês, e imprima o valor a ser pago ao funcionário, adicionando 10% sobre o | |
valor calculado */ | |
int main() { | |
float horadia = 5.50; | |
printf("Voce recebe por hora: R$%.2f", horadia); | |
float horames; | |
printf("\nQuantas horas voce trabalhou esse mes: "); | |
scanf("%f", &horames); | |
float hrstrab = horadia * horames; | |
float bonus, salfim; | |
bonus = hrstrab * 0.10; | |
salfim = hrstrab + bonus; | |
printf("Voce recebera esse mes: R$%.2f", salfim); | |
printf("\n\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/* Receba o salário-base de um funcionário, calcule e imprima o salário a receber, sabendo-se | |
que esse funcionário tem uma gratificação de 5% sobre o salário-base. Além disso, paga % de | |
imposto sobre o salário-base | |
*/ | |
int main() { | |
float salb; | |
printf("Insira seu salario: R$"); | |
scanf("%f", salb); | |
float gratificacao, imposto, saltot; | |
gratificacao = salb * 0.05; | |
imposto = salb * 0.07; | |
saltot = salb + gratificacao - imposto; | |
printf("\nSalario a receber eh: R$%.2f", saltot); | |
printf("\n\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/* Escreva um algoritmo para criar um programa de ajuda para vendedores. A partir de um | |
valor total lido, mostre: | |
O total a pagar com desconto de 10%; | |
O valor de cada parcela, no parcelamento de 3 x sem juros; | |
A comissão do vendedor, no caso de a venda ser a vista (5% sobre o valor com desconto) | |
A comissão do vendedor, no caso de a venda ser parcelada (5% sobre o valor total) | |
*/ | |
int main() { | |
float vlrtot; | |
printf("Qual o valor total? "); | |
scanf("%f", &vlrtot); | |
float des10, vlrapagar; | |
des10 = vlrtot * 0.10; | |
vlrapagar = vlrtot - des10; | |
printf("\nTotal a pagar com desconto de 10%: R$%.2f" , vlrapagar); | |
float parc3; | |
parc3= vlrtot / 3; | |
printf("\nTotal do parcelamento em 3x sem juros: R$%.2f", parc3); | |
float comissao; | |
comissao= vlrapagar * 0.05; | |
printf("\nComissao venda a vista: R$%.2f", comissao); | |
float comissao2; | |
comissao2= vlrtot * 0.05; | |
printf("\nComissao venda parcelada: R$%.2f", comissao2); | |
printf("\n\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int main(){ | |
int soma,a ,b ,c; | |
printf("Digite 03 numeros inteiros:\n"); | |
scanf("%d%d%d",&a,&b,&c); | |
printf("\n a soma dos 03 numeros resultam em :%d",a+b+c); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/* Receba a altura do degrau de uma escada e a altura que o usuário deseja alcançar subindo | |
a escada. Calcule e mostre quantos degraus o usuário deverá subir para atingir seu objetivo, | |
sem se preocupar com a altura do usuário */ | |
int main() { | |
float degrau, altura, qtd; | |
printf("Insira a altura do degrau em centimetros: "); | |
scanf("%f", °rau); | |
printf("Qual altura deseja alcancar em metros:"); | |
scanf("%f", &altura); | |
qtd = (degrau*100) / altura; | |
printf("\nA quantidade de degraus para alcancar a altura eh:%.0f" , qtd); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <ctype.h> | |
/* Faça um programa para converter uma letra maiúscula em letra minúscula. Use a tabela | |
ASCII. */ | |
int main(void) { | |
char letra; | |
printf("Digite uma letra minuscula: "); | |
scanf("%c", &letra); | |
letra = toupper(letra); | |
printf("\nLetra em maiusculo: %c " , letra); | |
printf("\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
/* Faça um programa para ler um número inteiro, positivo de três dígitos, e gerar outro | |
número formado pelos dígitos invertidos do número lido. Exemplo: | |
NúmeroLido = 123 | |
NúmeroGerado = 321. */ | |
int main() { | |
int num, num1, num2, num3; | |
printf("Digite um numero inteiro de 3 digitos positivo: "); | |
scanf("%d", &num); | |
if (num > 10) { | |
num1 = num%10; | |
num = num/10; | |
num2 = num%10; | |
num = num/10; | |
num3=num%10; | |
num=num/10; | |
} | |
printf("%d%d%d\n", num1, num2, num3); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
// Leia um número inteiro de 4 dígitos e imprima 1 dígito por linha | |
int main() { | |
int num1 = 1 , num2 = 2 , num3 = 3 , num4 = 4; | |
printf("Numero inteiro de 4 digitos : %d%d%d%d " , num1, num2, num3, num4); | |
printf("\n%d\n%d\n%d\n%d\n", num1, num2, num3); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
// Leia um valor inteiro em segundos, e imprima-o em horas, minutos e segundos | |
int main() { | |
int horas, minutos, segundos; | |
printf("Digite os segundos: "); | |
scanf("%d" , &segundos); | |
horas = segundos / 3600; | |
minutos = (segundos -(horas*3600))/60; | |
segundos = segundos - (horas*3600)-(minutos*60); | |
printf("%dh: %dm: %ds: ", horas, minutos, segundos); | |
printf("\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/* Faça um programa para leia o horário (hora, minuto e segundo) de início e a duração, em | |
segundos, de uma experiência biológica. O programa deve resultar com o novo horário (hora, | |
minuto e segundo) do termino da mesma. */ | |
int main() { | |
int h= 15, m =30, s=10; | |
printf("A hora inicial eh: %d:%d:%d", h, m, s); | |
int duracao = 10800; | |
printf("\nA hora de duracao da experiencia em segundos eh: %d", duracao); | |
int horas, minutos, segundos; | |
horas = duracao / 3600; | |
minutos = (duracao-(horas*3600))/60; | |
segundos = duracao - (horas*3600)-(minutos*60); | |
int hf, mf, sf; | |
hf= h + horas; | |
mf= m + minutos; | |
sf= s + segundos; | |
printf("\nA experiencia terminara as: %d:%d:%d", hf, mf, sf ); | |
printf("\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/* Implemente um programa em C que calcule o ano de nascimento de uma pessoa a partir | |
de sua idade e do ano atual */ | |
int main() { | |
int idade, ano_atual, ano_nasc; | |
printf("Digite sua idade: "); | |
scanf("%d", &idade); | |
printf("Insira em que ano estamos: "); | |
scanf("%d", &ano_atual); | |
ano_nasc = ano_atual - idade; | |
printf("Voce nasceu em: %d", ano_nasc); | |
printf("\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/*Faça um algoritmo que calcule a média ponderada das notas de 3 provas. A primeira e a | |
segunda prova têm peso 1 e a terceira tem peso 2. Antes de o usuário entrar com as notas do | |
aluno ele deve entrar com o número de matricula do aluno. Ao final, mostrar a matricula do | |
aluno juntamente com a sua média e indicar se o aluno foi aprovado ou reprovado. A nota | |
para aprovação deve ser igual ou superior a 60 pontos*/ | |
int main(){ | |
int matricula; | |
printf("Digite o numero de matricula: "); | |
scanf("%d", &matricula); | |
float n1, n2, n3, mediaponderada; | |
printf("\nNota 1: "); | |
scanf("%f", &n1); | |
printf("\nNota 2: "); | |
scanf("%f", &n2); | |
printf("\nNota 3: "); | |
scanf("%f", &n3); | |
mediaponderada = ((n1*1) + (n2 *1) + (n3 * 2))/4; | |
if (mediaponderada >=6){ | |
printf("\nAluno: %d" , matricula); | |
printf("\nNota: %.2f" , mediaponderada); | |
printf("\nVoce foi aprovado, parabens!"); | |
} else { | |
printf("\nAluno: %d" , matricula); | |
printf("\nNota: %.2f" , mediaponderada); | |
printf("\nVoce foi reprovado, estude mais um pouco!"); | |
} | |
printf("\n"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Escreva um programa que leia as coordenadas 𝑥 e 𝑦 de pontos no plano cartesiano e | |
calcule sua distância da origem (0, 0)*/ | |
int main() { | |
float x = 0; | |
float y = 0; | |
float R = 0; | |
printf ("Digite a coordenada x \n"); | |
scanf ("%f", &x); | |
printf ("Digite a coordenada y \n"); | |
scanf ("%f", &y); | |
R=sqrt(pow(x,2)+pow(y,2)); //pow(base, expoente) pra elevar ao quadrado e sqrt() é raíz quadrada | |
printf("A distancia e: %f \n", R); | |
fflush(stdin); | |
getchar(); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Três amigos jogaram na loteria. Caso eles ganhem, o prêmio deve ser repartido | |
proporcionalmente ao valor que cada deu para a realização da aposta. Faça um programa que | |
lê quanto cada apostador investiu, lê o valor do prêmio, e escreve quanto cada um ganharia. | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
int main() { | |
float vetor [3]; | |
int i=0, j=0, k=0; | |
int premio = 10000, armazenaPremio=0; | |
float arrecadado; | |
for(i=0; i<3; i++){ | |
printf("\nValor aposta amigo %d:",1+i); | |
scanf("%f",&vetor[i]); | |
} | |
arrecadado = vetor[0]+vetor[1]+vetor[2]; | |
printf("valor arrecadado %.2f\n",arrecadado); | |
// premio no randon min 500 max 10 mil, conta 20x e retorna um numero aceitavel. | |
for (j =0; j <20; j++){ | |
rand() % premio; | |
if (rand() < 500){ | |
for (j =0; j < 1; j++){ | |
armazenaPremio= rand()%premio; | |
} | |
} | |
}printf("premio %d", armazenaPremio); | |
float pct1 = (vetor[0] * 100)/arrecadado; | |
float pct2 = (vetor[1] * 100)/arrecadado; | |
float pct3 = (vetor[2] * 100)/arrecadado; | |
printf("\nAmigo 1 apostou: %.2f %% do total arrecadado.", pct1); | |
printf("\nAmigo 2 apostou: %.2f %% do total arrecadado.", pct2); | |
printf("\nAmigo 3 apostou: %.2f %% do total arrecadado.", pct3); | |
printf("\nAmigo 1 recebera: R$%.2f.", armazenaPremio * pct1/100); | |
printf("\nAmigo 2 recebera: R$%.2f.", armazenaPremio * pct2/100); | |
printf("\nAmigo 3 recebera: R$%.2f.", armazenaPremio * pct3/100); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <conio.h> | |
#include <math.h> | |
int main(){ | |
float quadrado,num; | |
printf("Digite O numero Real:"); | |
scanf("%f",&num); | |
quadrado = pow(num,2);// pow(base,expoente) | |
printf("O quadrado do numero eh:%.2f",quadrado); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Faça um programa para ler as dimensões de um terreno (comprimento 𝑐 e largura 𝑙), bem | |
como o preço do metro do arame 𝑝, então fornecer como saída o custo para cercar este | |
mesmo terreno*/ | |
int main() { | |
float largura, comprimento, preco, total; | |
printf("\nQual a largura do terreno: "); | |
scanf("%f", &largura); | |
printf("\nQual o comprimento do terreno: "); | |
scanf("%f", &comprimento); | |
printf("\nQual o preco do terreno: R$"); | |
scanf("%f", &preco); | |
total = (comprimento * largura * preco); | |
printf("\nVoce gastara para cercar o terreno: R$%.2f", total); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/*Ler uma temperatura em graus Celsius e apresentá-la convertida em graus Fahrenheit. A | |
fórmula de conversão é: 𝐹 = 𝐶 ∗ (9,05,0) + 32,0, sendo 𝐹 a temperatura em Fahrenheit e 𝐶 a | |
temperatura em Celsius*/ | |
int main() { | |
float c, f; | |
printf("Digite a temperatura em Graus Celsius: "); | |
scanf("%f", &c); | |
f = c*(9.0/5.0) + 32.0; | |
printf("\nA temperatura em Fahrenheit eh: %.2f", f); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler uma temperatura em graus Fahrenheit e apresentá-la convertida em graus Celsius. A | |
fórmula de conversão é: 𝐶 = 5,0 ∗ (𝐹 − 32,0)/9,0, sendo 𝐶 a temperatura em Celsius e 𝐹 a | |
temperatura em Fahrenheit.*/ | |
int main() { | |
float f, c; | |
printf("Digite a temperatura em Graus Fahrenheit: "); | |
scanf("%f", &f); | |
c = 5.0*(f -32.0)/9.0; | |
printf("A temperatura em Celsius eh: %.2f", c); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler uma temperatura em graus Kelvin e apresentá-la convertida em graus Celsius. A | |
fórmula de conversão é: 𝐶 = 𝐾 − 273,15, sendo 𝐶 a temperatura em Celsius e 𝐾 a | |
temperatura em Kelvin*/ | |
int main() | |
{ | |
float k, c; | |
printf("Digite a temperatura em Graus Kelvin: "); | |
scanf("%.2f", &k); | |
c = k - 273.15; | |
printf("A temperatura em Celsius eh: %.2f", c); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* . Ler uma temperatura em graus Celsius e apresentá-la convertida em graus Kelvin. A | |
fórmula de conversão é: 𝐾 = 𝐶 + 273,15, sendo 𝐶 a temperatura em Celsius e 𝐾 | |
atemperatura em Kelvin*/ | |
int main() { | |
float c, k; | |
printf("Digite a temperatura em Graus Celsius: "); | |
scanf("%f", &c); | |
k= c + 273.15; | |
printf("\nA temperatura em Kelvin eh: %.2f", k); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler uma velocidade em km/h (quilômetros por hora) e apresentá-la convertida em 𝑚/𝑠 | |
(metros por segundo). A fórmula de conversão é: 𝑀 = 𝑘/3,6, sendo 𝐾 a velocidade em 𝑘𝑚/ℎ | |
e 𝑀 em m/s */ | |
int main() { | |
float kmh, ms; | |
printf("Digite a velocidade em Km/h: "); | |
scanf("%f", &kmh); | |
ms= kmh / 3.6; | |
printf("\nA velocidade convertida em m/s : %.2f", ms); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler uma velocidade em 𝑚/𝑠 (metros por segundo) e apresentá-la convertida em | |
𝐾𝑚/ℎ (quilômetros por hora). A fórmula de conversão é: 𝐾 = 𝑀 ∗ 3,6 , sendo 𝐾 a velocidade | |
em 𝑘𝑚/ℎ e 𝑀 em 𝑚/𝑠. */ | |
int main() { | |
float ms, kmh; | |
printf("Digite a velocidade em m/s: "); | |
scanf("%f", &ms); | |
kmh = ms *3.6; | |
printf("\nA velocidade convertida em km/h eh: %.2f", kmh); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler uma distância em milhas e apresentá-la convertida em quilômetros. A fórmula de | |
conversão é: 𝐾 = 1,61 ∗ 𝑀 , sendo 𝐾 a distância em quilômetros e 𝑀 em milhas */ | |
int main() { | |
float milhas, km; | |
printf("Digite a distancia em milhas: "); | |
scanf("%f", &milhas); | |
km = 1.61 * milhas; | |
printf("\nA distancia convertida em milhas: %.2f", km); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler uma distância em quilômetros e apresentá-la convertida em milhas. A fórmula de | |
conversão é: 𝑀 = 𝐾/1,61 , sendo 𝐾 a distância em quilômetros e 𝑀 em milhas */ | |
int main() { | |
float km, milhas; | |
printf("Digite a distancia em milhas: "); | |
scanf("%f", &km); | |
milhas = km / 1.61; | |
printf("\nA velocidade convertida em milhas eh: %.2f", milhas); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler um ângulo em graus e apresentá-lo convertido em radianos. A fórmula de conversão é: | |
𝑅 = 𝐺 ∗ 𝜋/180 , sendo 𝐺 o ângulo em graus e R em radianos e 𝜋 = 3,141592 */ | |
int main() { | |
const double pi = 3.14; | |
float graus, r; | |
printf("Digite o valor do angulo em graus: "); | |
scanf("%f", &graus); | |
r = graus * pi/180; | |
printf("\nO angulo convertido em radianos eh: %.2f", r); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//4. Leia um número real e imprima a quinta parte deste número. | |
#include <stdio.h> | |
#include <string.h> | |
int main(){ | |
float num= 5.7, divisor; | |
divisor = num / 5; | |
printf ("a quinta part#e de %.2f equivale a : %.2f", num, divisor); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler um ângulo em radianos e apresentá-lo convertido em graus. A fórmula de conversão é: | |
𝐺 = 𝑅 ∗ 180/𝜋 , sendo 𝐺 o ângulo em graus e 𝑅 em radianos e 𝜋 = 3,141592. */ | |
int main() { | |
const double pi = 3.14; | |
float graus, r; | |
printf("Digite o valor do angulo em radianos: "); | |
scanf("%f", &r); | |
graus = r * 180/pi; | |
printf("\nO angulo convertido em graus eh: %.2f", graus); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler um valor de comprimento em polegadas e apresentá-lo convertido em centímetros. A | |
fórmula de conversão é: 𝐶 = 𝑃 ∗ 2,54 , sendo 𝐶 o comprimento em centímetros e 𝑃 o | |
comprimento em polegadas.*/ | |
int main() { | |
float p, c; | |
printf("Digite o valor em polegadas: "); | |
scanf("%f", &p); | |
c = p * 2.54; | |
printf("\nO valor convertido em centimetros eh: %.2fcm", c); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler um valor de comprimento em centímetros e apresentá-lo convertido em polegadas. A | |
fórmula de conversão é: 𝑃 = 𝐶/2,54 , sendo 𝐶 o comprimento em centímetros e 𝑃 o | |
comprimento em polegadas..*/ | |
int main() { | |
float p, c; | |
printf("Digite o valor em centimetros: "); | |
scanf("%f", &c); | |
p = c / 2.54; | |
printf("\nO valor convertido em polegadas eh: %.2f", p); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler um valor de volume em metros cúbicos 𝑚³ e apresentá-lo convertido em litros. A | |
fórmula de conversão é: 𝐿 = 1000 ∗ 𝑀, sendo 𝐿 o volume em litros e 𝑀 o volume em metros | |
cúbicos*/ | |
int main() { | |
float mc, lt; | |
printf("Digite o volume em m3: "); | |
scanf("%f", &mc); | |
lt = 1000 * mc; | |
printf("\nO valor convertido em litros eh: %.2f", lt); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler um valor de volume em litros e apresentá-lo convertido em metros cúbicos 𝑚³. A | |
fórmula de conversão é: 𝑀 = 𝐿/1000 , sendo 𝐿 o volume em litros e 𝑀 o volume em metros | |
cúbicos. */ | |
int main() { | |
float lt, m3; | |
printf("Digite o valor em litros: "); | |
scanf("%f", <); | |
m3 = lt /1000; | |
printf("\nO valor convertido em m3: %.2f",m3); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler um valor de massa em quilogramas e apresentá-lo convertido em libras. A fórmula de | |
conversão é: 𝐿 = 𝐾/0,45 , sendo 𝐾 a massa em quilogramas e 𝐿 a massa em libras */ | |
int main() { | |
float kg, lb; | |
printf("Digite massa em kg: "); | |
scanf("%f", &kg); | |
lb = kg /0.45; | |
printf("\nO valor convertido em libras: %.2f",lb); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler um valor de comprimento em jardas e apresentá-lo convertido em metros. A fórmula | |
de conversão é: 𝑀 = 0,91 ∗ 𝐽 , sendo 𝐽 o comprimento em jardas e 𝑀 o comprimento em | |
metros. */ | |
int main() { | |
float jd, mt ; | |
printf("Digite o comprimento em jardas: "); | |
scanf("%f", &jd); | |
mt = 0.91 * jd; | |
printf("\nO comprimento convertido em metros: %.2f",mt); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler um valor de comprimento em metros e apresentá-lo convertido em jardas. A fórmula | |
de conversão é: 𝐽 = 𝑀/0,91 , sendo 𝐽 o comprimento em jardas e 𝑀 o comprimento em | |
metros */ | |
int main() { | |
float jd, mt ; | |
printf("Digite o comprimento em metros: "); | |
scanf("%f", &mt); | |
jd = mt /0.91; | |
printf("\nO comprimento convertido em jardas: %.2f",jd); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler um valor de comprimento em metros e apresentá-lo convertido em jardas. A fórmula | |
de conversão é: 𝐽 = 𝑀/0,91 , sendo 𝐽 o comprimento em jardas e 𝑀 o comprimento em | |
metros */ | |
int main() { | |
float jd, mt ; | |
printf("Digite o comprimento em metros: "); | |
scanf("%f", &mt); | |
jd = mt /0.91; | |
printf("\nO comprimento convertido em jardas: %.2f",jd); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler um valor de área em acres e apresentá-lo convertido em metros quadrados 𝑚². A | |
fórmula de conversão é: 𝑀 = 𝐴 ∗ 4048,58 , sendo 𝑀 a área em metros quadrados e 𝐴 a área | |
em acres */ | |
int main() { | |
float m2, ac; | |
printf("Digite a area em acres: "); | |
scanf("%f", &ac); | |
m2 = ac * 4048.58; | |
printf("\nA area em m2 eh: %.2f",m2); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Efetue a leitura de três valores e apresente como resultado a soma dos quadrados dos três valores lidos. | |
#include <stdio.h> | |
#include <string.h> | |
#include <conio.h> | |
#include <math.h> | |
int main(){ | |
float a = 10, b =15, c = 20, quadradoA, quadradoB, quadradoC, soma; | |
quadradoA = pow(a,2);// pow(base,expoente) | |
quadradoB = pow(b,2);// pow(base,expoente) | |
quadradoC = pow(c,2);// pow(base,expoente) | |
soma = quadradoA + quadradoB + quadradoC; | |
printf("a soma dos quadrados %.2f,%.2f,%.2f resultam em %.2f",a ,b, c, soma); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler um valor de área em metros quadrados 𝑚2e apresentá-lo convertido em acres. A | |
fórmula de conversão é: 𝐴 = 𝑀 ∗ 0,000247, sendo 𝑀 a área em metros quadrados e 𝐴 a área | |
em acres */ | |
int main() { | |
float m2, ac; | |
printf("Digite a area em m2: "); | |
scanf("%f", &m2); | |
ac = m2 * 0.000247; | |
printf("\nA area em acres eh: %.2f",ac); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
/* Ler um valor de área em metros quadrados 𝑚² e apresentá-lo convertido em hectares. A | |
fórmula de conversão é: 𝐻 = 𝑀 ∗ 0,0001, sendo 𝑀 a área em metros quadrados e 𝐻 a área | |
em hectares */ | |
int main() { | |
float m2, hc; | |
printf("Digite a area em m2: "); | |
scanf("%f", &m2); | |
hc = m2 * 0.0001; | |
printf("\nA area em hectares eh: %.2f",hc); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//6. Leia quatro notas, calcule a média aritmética e imprima o resultado. | |
#include <stdio.h> | |
#include <string.h> | |
int main(){ | |
int a = 10, b =5.5, c = 2.95, e=9, bimestres = 4, mediaAritmetica = 0; | |
mediaAritmetica = (( a + b + c ) / bimestres); | |
printf("a as notas %d,%d,%d resultam na media %d",a ,b, c, mediaAritmetica); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//7. Leia um valor em real e a cotação do dólar. Em seguida, imprima o valor correspondente em | |
//dólares. | |
#include <stdio.h> | |
#include <string.h> | |
#define DOLAR 5.29 | |
int main(){ | |
float real = 250, cotacao = 0; | |
cotacao = real* DOLAR; | |
printf("A cotacao de %.2f BRL resultam em %.2f USD",real, cotacao); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//8. Leia um número inteiro e imprima o seu antecessor e o seu sucessor. | |
#include <stdio.h> | |
#include <string.h> | |
int main(){ | |
int vetor [5] = {1,2,3,4,5}; | |
for( int i = 1; i<5; i++) { | |
printf("valor escolhido:%d\n",i); | |
printf("sucessor: %d\n",vetor[i]); | |
if (vetor[0]== 1){ | |
int antecessor = vetor[i] - 2; | |
printf("antecessor:%d\n",antecessor); | |
return 0; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/* Leia um número inteiro e imprima a soma do sucessor de seu triplo com o antecessor de seu | |
dobro */ | |
int main() { | |
int num = 5; | |
printf("Numero inteiro: %d" , num); | |
printf("\nSoma do do sucessor de seu triplo com o antecessor de seu dobro : %d ", num * 3 + 1 + num * 2 -1); | |
printf("\n\n"); | |
system("pause"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment