Está en la página 1de 3

Ejercicio 1

// Online C compiler to run C program online


#include <stdio.h>
//tiempo caida de servidor en minutos
//perdidas en dolares
int main() {
int tiempoServidorCaido = 5;
double mediaPerdidas = 500.95;
mediaPerdidas *= tiempoServidorCaido;

printf("el total de perdidas es de %.2f", mediaPerdidas);

return 0;
}
--------------------------------------------------------------
el total de perdidas es de 2504.75
-----------------------------------------------------------------
// Online C compiler to run C program online
#include <stdio.h>
//tiempo caida de servidor en minutos
//perdidas en dolares
int main() {
int tiempoServidorCaido = 5;
double mediaPerdidas = 500.95;
mediaPerdidas *= tiempoServidorCaido / 2; //reducimos las perdidad a la mitad

printf("el total de perdidas es de %.2f", mediaPerdidas);

return 0;
}
---------------------------------------------------------------
el total de perdidas es de 1001.90
-----------------------------------------------------------------
ejercicio 2
// Online C compiler to run C program online
#include <stdio.h>

int main() {
int x = 1;
int y = 27;
if (x != y) { //comparador x distinto (!=) a y
printf("Felicitaciones! Ah usado los comparadores de forma correcta");
} else{
printf("Intente de nuevo");
}
return 0;
}
----------------------------------------------------------------------------------
Felicitaciones! Ah usado los comparadores de forma correcta
-----------------------------------------------------------------------------------
// Online C compiler to run C program online
#include <stdio.h>

int main() {
int x = 1;
int y = 1; // cambiamos el 27 x 1 para que ambos valores sean iguales
if (x != y) {
printf("Felicitaciones! Ah usado los comparadores de forma correcta");
} else{
printf("Intente de nuevo");
}
return 0;
}
---------------------------------------------------------------------------------------
Intente de nuevo
----------------------------------------------------------------------------------------
Ejercicio 3
#include <stdio.h>

int main() {
int x = 5; int y = 42;
int z = 10; int q = 5;
int h = 90; int j = 90;

if (x < y) { // x menos que y


if (z > q){ //z mayor que q
if ( h == j){ // h igual a j
printf("Felicitaciones!! Ah usado los comparadores de forma correcta");
}
}
}
return 0;
}
--------------------------------------------------------------------------------------------
Felicitaciones!! Ah usado los comparadores de forma correcta
------------------------------------------------------------------------------------------------
Ejercicio 4
#include <stdio.h>

int main() {
int x;
int y;

x = (2 + 3) * 5; // agregamos parentesis
y = 20 / (4 + 6); //agregamos parentesis
printf("x es %d\n", x);
printf("y es %d\n", y);

return 0;
}
----------------------------------------------------------------------------------
x es 25
y es 2
-----------------------------------------------------------------------------------
Ejercicio 5

// Online C compiler to run C program online


#include <stdio.h>
#include <time.h>

int main() {
srand(time(NULL)); //genera numeros aleatorios
int coin = rand() % 2;

if(coin == 0) {
printf("\nCara\n");
}else {
printf("\nCruz\n");
}

return 0;
}
------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------
Ejercicio 6

#include <stdio.h>

int main(){

int a = 1;
int b = 2;

if (a> 0 && b > 0) {


printf("Se dió la condicion\n");
}
return 0;
}

También podría gustarte