Skip to content

Instantly share code, notes, and snippets.

@jmramirezpro
Created February 12, 2016 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmramirezpro/8f1cb0868a39035bb02d to your computer and use it in GitHub Desktop.
Save jmramirezpro/8f1cb0868a39035bb02d to your computer and use it in GitHub Desktop.
/*
* Aritmetica2.c
* Ejercicios del Podcast Codigo Fuente - Programa 021
* Realiza un programa que defina dos variables enteras i, j y dos reales, x e y,
* y lea sus valores por la entrada estándar. Usa con ellas las
* operaciones aritméticas +, -, *, /.
* Creado el 9 de feb. de 2016
* Author: jmramirez
*/
#include <stdio.h>
int main(void)
{
/* Variables */
int i;
int j;
float x;
float y;
/* Lectura de numeros enteros */
printf("Escribe número entero i: ");
scanf("%d",&i);
printf("Escribe número entero j: ");
scanf("%d",&j);
/* Operaciones con enteros */
printf("\n Numeros enteros");
printf("\n ================");
printf("\n Valores de variables...");
printf("\n i = %d", i);
printf("\n j = %d", j);
printf("\n Operaciones ...");
printf("\n i + j = %d", (i+j));
printf("\n i - j = %d", (i-j));
printf("\n i * j = %d", (i*j));
printf("\n i / j = %d", (i/j));
printf("\n i %% j = %d\n", (i%j)); /* Mirad como se escapa el caracter % */
/* Lectura de numeros reales */
printf("Escribe número real x: ");
scanf("%f",&x);
printf("Escribe número real y: ");
scanf("%f",&y);
/* Operaciones con reales */
printf("\n Numeros reales");
printf("\n ================");
printf("\n Valores de variables...");
printf("\n x = %f", x);
printf("\n y = %f", y);
printf("\n Operaciones ...");
printf("\n x + y = %f", (x+y));
printf("\n x - y = %f", (x-y));
printf("\n x * y = %f", (x*y));
printf("\n x / y = %f", (x/y));
printf("\n x %% y = %d\n", ((int)x % (int)y));
/* Operaciones con mezcla de tipos */
printf("\n Operaciones con mezcla de tipos");
printf("\n ================");
printf("\n j + y = %f", (j+y));
printf("\n i * x = %f", (i*x));
printf("\n j / x = %f\n", (j/x));
return (0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment