Created
February 12, 2016 07:53
-
-
Save jmramirezpro/8f1cb0868a39035bb02d to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
* 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