Aula7.At1
Autor: André.IAT | Publicado: 2010-08-30T06:40:00-07:00

/*FAZER UM PROGRAMA QUE RECEBA DOIS NÚMEROS E EXECUTE AS OPERAÇÕES LISTADAS A SEGUIR DE ACORDO COM A ESCOLHA DO USUÁRIO:
1-Média entre os números digitados
2-Diferença do maior pelo menor
3-Produto entre os números digitados
4-Divisão do primeiro pelo segundo
*/
&nbsp;&nbsp; &nbsp;#include&lt;stdio.h&gt;
&nbsp;&nbsp; &nbsp;#include&lt;conio.h&gt;
&nbsp;&nbsp; &nbsp;main ()
&nbsp;&nbsp; &nbsp;{
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; int a, b, diferenca, soma,op;
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; float div, media;
&nbsp;&nbsp; &nbsp;printf("||---------- Escolha as opções abaixo ------------||\n");
&nbsp;&nbsp; &nbsp;printf("||------ 1-Média entre os números digitados ------||\n");
&nbsp;&nbsp; &nbsp;printf("||------ 2-Diferença do maior pelo menor ---------||\n");
&nbsp;&nbsp; &nbsp;printf("||------ 3-Produto entre os números digitados ----||\n");
&nbsp;&nbsp; &nbsp;printf("||------ 4-Divisão do primeiro pelo segundo ------||\n");
&nbsp;&nbsp; &nbsp;printf("||------ Escolha uma opção :");
&nbsp;&nbsp; &nbsp;scanf("%d",&amp;op);
&nbsp;&nbsp; &nbsp;printf("||Entre com o 1 numero: &nbsp;");
&nbsp;&nbsp; &nbsp;scanf("%d",&amp;a);
&nbsp;&nbsp; &nbsp;printf("||Entre com o 2 numero: &nbsp;");
&nbsp;&nbsp; &nbsp;scanf("%d",&amp;b);
&nbsp;&nbsp; &nbsp;switch(op){
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 1:
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;media=(a+b)/2;
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("A media entre os numeros digitados eh %.2f\n",media);
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 2:
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (a&lt;b){
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;diferenca=b-a;
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("A diferenca do maior pelo menor eh %d\n",diferenca);
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}else
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;diferenca=a-b;
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("A diferenca do maior pelo menor eh %d\n",diferenca);
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 3:
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;soma=a+b;
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("O produto entre os numeros eh %d\n",soma);
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 4:
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;div=a/b;
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default:
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf("||---- Opcao invalida ----||\n");
&nbsp;&nbsp; &nbsp;}
&nbsp;&nbsp; &nbsp;getch();
}