16/11/2022 ; 5:28 PM
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
/* Promedio curso.
|
||||
El programa, al recibir como dato el promedio de un alumno en un curso
|
||||
➥universitario, escribe aprobado si su promedio es mayor o igual a 6.
|
||||
|
||||
PRO: variable de tipo real. */
|
||||
void main(void)
|
||||
{
|
||||
float PRO;
|
||||
printf("ingrese el promedio del alumno: ");
|
||||
scanf("%f", &PRO);
|
||||
|
||||
if (PRO >= 6)
|
||||
printf("\nAprobado");
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Par, impar o nulo.
|
||||
*
|
||||
NUM: variable de tipo entero. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
int NUM;
|
||||
|
||||
printf("Ingrese el numero: ");
|
||||
scanf("%d", &NUM);
|
||||
|
||||
if (NUM == 0)
|
||||
printf("\nNulo");
|
||||
else
|
||||
if (pow(-1, NUM) > 0)
|
||||
printf("\nPar");
|
||||
else
|
||||
printf("\nImpar");
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/* Billete de ferrocarril.
|
||||
El programa calcula el costo de un billete de ferrocarril teniendo en
|
||||
➥cuenta la distancia entre las dos ciudades y el tiempo de permanencia
|
||||
➥del pasajero.
|
||||
|
||||
DIS y TIE: variables de tipo entero.
|
||||
BIL: variable de tipo real. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
int DIS, TIE;
|
||||
float BIL;
|
||||
printf("Ingrese la distancia entre ciudades y el tiempo de estancia: ");
|
||||
scanf("%d %d", &DIS, &TIE);
|
||||
|
||||
if ((DIS * 2 > 500) && (TIE > 10))
|
||||
BIL = DIS * 2 * 0.19 * 0.8;
|
||||
else
|
||||
BIL = DIS * 2 * 0.19;
|
||||
printf("\n\nCosto del billete: %.2f", BIL);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Igualdad de expresiones.
|
||||
El programa, al recibir como datos T, P y N, comprueba la igualdad de
|
||||
una expresión determinada.
|
||||
|
||||
T, P y N: variables de tipo entero. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
int T, P, N;
|
||||
printf("Ingrese los valores de T, P y N: ");
|
||||
scanf("%d %d %d", &T, &P, &N);
|
||||
if (P != 0)
|
||||
{
|
||||
if (pow(T / P, N) == (pow(T, N) / pow(P, N)))
|
||||
|
||||
printf("\nSe comprueba la igualdad");
|
||||
else
|
||||
printf("\nNo se comprueba la igualdad");
|
||||
}
|
||||
else
|
||||
printf("\nP tiene que ser diferente de cero");
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Función.
|
||||
El programa, al recibir como dato un valor entero, calcula el resultado de
|
||||
➥una función.
|
||||
|
||||
Y: variable de tipo entero.
|
||||
X: variable de tipo real. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float X;
|
||||
int Y;
|
||||
printf("Ingrese el valor de Y: ");
|
||||
scanf("%d", &Y);
|
||||
if (Y < 0 | | Y > 50)
|
||||
X = 0;
|
||||
else
|
||||
if (Y <= 10)
|
||||
X = 4 / Y - Y;
|
||||
else
|
||||
if (Y <= 25)
|
||||
X = pow(Y, 3) - 12;
|
||||
else
|
||||
X = pow(Y, 2) + pow(Y, 3) - 18;
|
||||
printf("\n\nY = %d\tX = %.2f", Y, X);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/* Teléfono.
|
||||
El programa, al recibir como datos la clave de la zona geográfica y el
|
||||
➥número de segundos de una llamada telefónica, calcula el costo de la misma.
|
||||
|
||||
CLA y TIE: variables de tipo entero.
|
||||
COS: variable de tipo real. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
int CLA, TIE;
|
||||
float COS;
|
||||
printf("Ingresa la clave y el tiempo: ");
|
||||
scanf("%d %d", &CLA, &TIE);
|
||||
switch (CLA)
|
||||
{
|
||||
case 1: COS = TIE * 0.13 / 60; break;
|
||||
case 2: COS = TIE * 0.11 / 60; break;
|
||||
case 5: COS = TIE * 0.22 / 60; break;
|
||||
case 6: COS = TIE * 0.19 / 60; break;
|
||||
case 7:
|
||||
case 9: COS = TIE * 0.17 / 60; break;
|
||||
case 10: COS = TIE * 0.20 / 60; break;
|
||||
case 15: COS = TIE * 0.39 / 60; break;
|
||||
case 20: COS = TIE * 0.28 / 60; break;
|
||||
default: COS = -1; break;
|
||||
}
|
||||
if (COS != -1)
|
||||
printf("\n\nClave: %d\tTiempo: %d\tCosto: %.2f", CLA, TIE, COS);
|
||||
else
|
||||
printf("\nError en la clave");
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/* Spa.
|
||||
El programa, al recibir como datos el tipo de tratamiento, la edad y el
|
||||
➥número de días de internación de un cliente en un spa, calcula el costo
|
||||
➥total del tratamiento.
|
||||
|
||||
TRA, EDA, DIA: variables de tipo entero.
|
||||
COS: variable de tipo real. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
int TRA, EDA, DIA;
|
||||
float COS;
|
||||
|
||||
printf("Ingrese tipo de tratamiento, edad y días: ");
|
||||
scanf("%d %d %d", &TRA, &EDA, &DIA);
|
||||
|
||||
switch (TRA)
|
||||
{
|
||||
case 1: COS = DIA * 2800; break;
|
||||
case 2: COS = DIA * 1950; break;
|
||||
case 3: COS = DIA * 2500; break;
|
||||
case 4: COS = DIA * 1150; break;
|
||||
default: COS = -1; break;
|
||||
}
|
||||
if (COS != -1)
|
||||
{
|
||||
if (EDA >= 60)
|
||||
COS = COS * 0.75;
|
||||
else
|
||||
if (EDA <= 25)
|
||||
COS = COS * 0.85;
|
||||
printf("\nClave tratamiento: %d\t Dias: %d\t Costo total: %.2f", TRA, DIA, COS);
|
||||
}
|
||||
else
|
||||
printf("\nLa clave del tratamiento es incorrecta");
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#include<stdio.h>
|
||||
|
||||
/* Empresa textil.
|
||||
El programa, al recibir como datos decisivos la categoría y antigüedad de
|
||||
➥un empleado, determina si el mismo reúne las condiciones establecidas por
|
||||
➥la empresa para ocupar un nuevo cargo en una sucursal.
|
||||
|
||||
CLA, CAT, ANT, RES: variables de tipo entero.
|
||||
SAL: variable de tipo real. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
int CLA, CAT, ANT, RES;
|
||||
printf("\nIngrese la clave, categoria y antiguedad del trabajador: ");
|
||||
|
||||
scanf("%d %d %d", &CLA, &CAT, &ANT);
|
||||
switch (CAT)
|
||||
{
|
||||
case 3:
|
||||
case 4: if (ANT >= 5)
|
||||
RES = 1;
|
||||
else
|
||||
RES = 0;
|
||||
break;
|
||||
case 2: if (ANT >= 7)
|
||||
RES = 1;
|
||||
else
|
||||
RES = 0;
|
||||
break;
|
||||
default: RES = 0;
|
||||
break;
|
||||
}
|
||||
if (RES)
|
||||
printf("\nEl trabajador con clave % d reúne las condiciones para el puesto", CLA);
|
||||
else
|
||||
printf("\nEl trabajador con clave % d no reúne las condiciones para el puesto", CLA);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
/* Incremento de precio.
|
||||
El programa, al recibir como dato el precio de un producto importado,
|
||||
➥incrementa 11% el mismo si éste es inferior a $1,500.
|
||||
|
||||
PRE y NPR: variable de tipo real. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float PRE, NPR;
|
||||
printf("ingrese el precio del producto: ");
|
||||
scanf("%f", &PRE);
|
||||
|
||||
if (PRE > 1500)
|
||||
{
|
||||
NPR = PRE * 1.11;
|
||||
printf("\nNuevo precio : % 7.2f", NPR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/* Promedio curso.
|
||||
El programa, al recibir como dato el promedio de un alumno en un curso
|
||||
➥universitario, escribe aprobado si su promedio es mayor o igual a 6, o
|
||||
➥reprobado en caso contrario.
|
||||
|
||||
PRO: variable de tipo real. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float PRO;
|
||||
printf("Ingrese el promedio del alumno: ");
|
||||
scanf("%f", &PRO);
|
||||
|
||||
if (PRO >= 6.0)
|
||||
printf("\nAprobado");
|
||||
|
||||
else
|
||||
printf("\nReprobado");
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/* incremento de precio.
|
||||
El programa, al recibir como dato el precio de un producto, incrementa al
|
||||
➥mismo 11% si es menor a 1500$ y 8% en caso contrario (mayor o igual).
|
||||
|
||||
PRE y NPR: variables de tipo real. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float PRE, NPR;
|
||||
printf("Ingrese el precio del producto: ");
|
||||
scanf("% f", &PRE);
|
||||
if (PRE < 1500)
|
||||
NPR = PRE * 1.11;
|
||||
else
|
||||
NPR = PRE * 1.08;
|
||||
printf("\nNuevo precio del producto : % 8.2f", NPR);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Función matemática.
|
||||
El programa obtiene el resultado de una función.
|
||||
|
||||
OP y T: variables de tipo entero.
|
||||
RES: variable de tipo real. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
int OP, T;
|
||||
float RES;
|
||||
printf("Ingrese la opción del calculo y el valor entero: ");
|
||||
scanf("%d %d", &OP, &T);
|
||||
|
||||
switch (OP)
|
||||
{
|
||||
case 1: RES = T / 5;
|
||||
break;
|
||||
case 2: RES = pow(T, T);
|
||||
/* La función pow está definida en la biblioteca math.h */
|
||||
break;
|
||||
case 3:
|
||||
case 4: RES = 6 * T / 2;
|
||||
break;
|
||||
default: RES = 1;
|
||||
break;
|
||||
}
|
||||
printf("\nResultado: % 7.2f", RES);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Incremento de salario.
|
||||
El programa, al recibir como dato el nivel de un profesor, incrementa su
|
||||
➥salario en función de la tabla 2.3.
|
||||
|
||||
NIV: variable de tipo entero.
|
||||
SAL: variables de tipo real. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float SAL;
|
||||
int NIV;
|
||||
printf("Ingrese el nivel academico del profesor: ");
|
||||
scanf("%i", &NIV);
|
||||
|
||||
printf("ingrese el salario: ");
|
||||
scanf("%f", &SAL);
|
||||
|
||||
switch (NIV)
|
||||
{
|
||||
case 1: SAL = SAL * 1.0035; break;
|
||||
case 2: SAL = SAL * 1.0041; break;
|
||||
case 3: SAL = SAL * 1.0048; break;
|
||||
case 4: SAL = SAL * 1.0053; break;
|
||||
}
|
||||
printf("\n\nNivel: %d \tNuevo salario: %.2f\n", NIV, SAL);
|
||||
|
||||
system("pause");
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/* ventas descendentes.
|
||||
El programa, al recibir como datos tres valores que representan las ventas
|
||||
➥de los vendedores de una tienda de discos, escribe las ventas en
|
||||
➥orden descendente.
|
||||
|
||||
P, S y R: variables de tipo real. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float P, S, R;
|
||||
printf("\nIngrese las ventas de los tres vendedores: ");
|
||||
scanf("%f %f %f", &P, &S, &R);
|
||||
if (P > S)
|
||||
if (P > R)
|
||||
if (S > R)
|
||||
printf("\n\n El orden es P, S y R: %.2f %.2f %.2f", P, S, R);
|
||||
else
|
||||
printf("\n\n El orden es P, R y S: %.2f %.2f %.2f", P, R, S);
|
||||
else
|
||||
printf("\n\n El orden es R, P y S: %.2f %.2f %.2f", R, P, S);
|
||||
else
|
||||
if (S > R)
|
||||
if (P > R)
|
||||
printf("\n\n El orden es S, P y R: %.2f %.2f %.2f", S, P, R);
|
||||
else
|
||||
printf("\n\n El orden es S, R y P: %.2f %.2f %.2f", S, R, P);
|
||||
else
|
||||
printf("\n\n El orden es R, S y P: %.2f %.2f %.2f", R, S, P);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/* Asistentes.
|
||||
El programa, al recibir como datos la matrícula, la carrera, el semestre
|
||||
➥y el promedio de un alumno de una universidad privada, determina si
|
||||
➥éste puede ser asistente de su carrera.
|
||||
|
||||
MAT, CAR y SEM: variables de tipo entero.
|
||||
PRO: variable de tipo real. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
int MAT, CAR, SEM;
|
||||
float PRO;
|
||||
printf("Ingrese matricula: ");
|
||||
scanf("%d", &MAT);
|
||||
|
||||
printf("Ingrese carrera(1 - Industrial 2 - Telematica 3 - Computacion 4 - Mecanica): ");
|
||||
scanf("%d", &CAR);
|
||||
|
||||
printf("Ingrese semestre: ");
|
||||
scanf("%d", &SEM);
|
||||
|
||||
printf("Ingrese promedio: ");
|
||||
scanf("%f", &PRO);
|
||||
|
||||
switch (CAR)
|
||||
{
|
||||
case 1: if (SEM >= 6 && PRO >= 8.5)
|
||||
printf("\n%d %d %.2f", MAT, CAR, PRO);
|
||||
break;
|
||||
case 2: if (SEM >= 5 && PRO >= 9.0)
|
||||
printf("\n%d %d %.2f", MAT, CAR, PRO);
|
||||
break;
|
||||
case 3: if (SEM >= 6 && PRO >= 8.8)
|
||||
printf("\n%d %d %.2f", MAT, CAR, PRO);
|
||||
break;
|
||||
case 4: if (SEM >= 7 && PRO >= 9.0)
|
||||
printf("\n %d %d %.2f", MAT, CAR, PRO);
|
||||
break;
|
||||
default: printf("\n Error en la carrera");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Expresión.
|
||||
El programa, al recibir como datos tres valores enteros, establece si los
|
||||
➥mismos satisfacen una expresión determinada.
|
||||
R, T y Q: variables de tipo entero.
|
||||
|
||||
RES: variable de tipo real. */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float RES;
|
||||
int R, T, Q;
|
||||
|
||||
printf("Ingrese los valores de R, T y Q: ");
|
||||
scanf("%d %d %d", &R, &T, &Q);
|
||||
|
||||
RES = pow(R, 4) - pow(T, 3) + 4 * pow(Q, 2);
|
||||
|
||||
if (RES < 820)
|
||||
printf("\nR = %d\tT = %d\t Q = %d", R, T, Q);
|
||||
}
|
||||
Reference in New Issue
Block a user