Pgina 1
Pgina 2
# include <stdio.h> # include <conio.h> main() { float area, b1, b2, h; clrscr(); printf(ingrese el valor de b1:); printf(ingrese el valor de b2:); printf(ingrese el valor de la altura:); scanf(%f, &b1, &b2, &h); area= (b1 + b2)*h /2; printf(la respuesta es: %f, area); getch(); }
SEGN LA VENTA QUE HAYA REALIZADO. SI LA VENTA ES MAYOR A $500, EL VENDEDORDEBE RECIBIR EL 15% DEL TOTAL DE LA VENTA; CASO CONTRARIO NO HAYCOMISION.
#include <stdio.h> #include <conio.h> main() { float ventot, comision; clrscr(); printf(ingrese la venta total:); scanf(%f,&ventot); if(ventot>500); { comisin=ventot*0.15; } printf(el vendedor debe recibir: %2f, comisin); getch(); }
5) ELABORE UN PROGRAMA QUE CALCULE LA COMISION QUE DEBE RECIBIR UN VENDEDOR.SI LA VENTA ES MAYOR A $500 EL VENDEDOR DEBE
Jos Rendn Pineda Pgina 5
RECIBIR EL 15% DEL TOTAL DE LAVENTA; CASO CONTRARIO, ES DECIR SI LA VENTA ES MENOR O IGUAL QUE $500 DEBE RECIBIR EL 5%
#include <stdio.h> #include <conio.h> main() { float ventot, comision; clrscr(); printf(calculo de comision \n); printf(ingrese la venta total:); scanf(%f,&ventot); if(ventot>500){ comisin=ventot*0.15; } else { comisin=ventot*0.05; } printf(el vendedor debe recibir: %2f, comisin); getch(); }
6) Una tienda de artefactos elctricos necesita incrementar sus ventas y para ella pone en vigencia el siguiente plan. Un descuento del 10% para las compras que superen los
Jos Rendn Pineda Pgina 6
$300; para las compras menores o iguales que $300 el descuento debe ser del 5%.
#include <stdio.h> #include <conio.h> int main() { float ventot, descuento; clrscr() ;printf(calculo de descuento\n); printf(ingrese la venta total); scanf(%f,&ventot); if(ventot > 300) { descuento=ventot - 0.10 ; } else { descuento=ventot - 0.05; } printf(la venta total a pagar es %2f el descuento es); getch(); }
#include <stdio.h> #include <conio.h> main() { int num; clrscr(); printf(ingrese un numero:); scanf(%d,&num); if(num>=0){ printf(numero positive); } else { printf(numero negativo); } getch(); }
Pgina 8
8) UNA TIENDA DE ARTEFACTOS ELECTRICOS PONE EN VIGENCIA EL SIGUIENTE PLAN PARAINCREMENTAR SUS VENTAS SI LA COMPRA ES DESCONTAR EL >100 5% >200 8% >250 12% <250 15%
#include <stdio.h> #include <conio.h> main() { float ventot, descuento; clrscr(); printf(calculo de la venta\n); printf(ingrese la venta total:); scanf(%2f,&ventot); if(ventot<100) descuento=ventot*0.05; else if(ventot<200) descuento=ventot*0.08 ;else if(ventot<250) descuento=ventot*0.12; else if(ventot>250) descuento=ventot*0.15; descuento=ventot-descuento; printf(la venta total a pagar es: %2f, descuento); getch(); }
Pgina 9
#include <stdio.h> #include <conio.h> main() { int a,b,max; clrscr(); printf(ingrese un numero:); scanf(%d,&a); printf(ingrese otro numero:);scanf(%d,&b); max=(a>b)? a:b; printf(el mayor es: %d2,max); getch(); }
Pgina 10
10) VEAMOS UN PROGRAMA QUE SOLICITA LA NOTA OBTENIDA POR UN ESTUDIANTE EN LA SUMATORIA . SI LA NOTA ES MAYOR O IGUAL QUE 40 MUESTRA EL MENOR APROBADO, CASO CONTRARIO MUESTRA SUPLETORIO.
#include <stdio.h> #include <conio.h> main() { float nota; printf(ingrese la nota obtenida:); scanf(%f,¬a); if(nota>=40) printf(aprobado); else printf(reprobado); getch(); }
Pgina 11
Pgina 12
12) BOLETA DE PAGOPROGRAMA PARA OBTENER EL SALARIO NETO Y LA RETENCION DE UN EMPLEADO. ELCALCULO DE LA RETENCION SE BASA EN LAS CONDICIONES SIGUIENTES: SI 0 < SALARIO <=1500 RETENCION O% SI 1500 <=SALARIO <=3000 RETENCION 5% SI 3000 <= SALARIO RETENCION8%
#include <stdio.h> #include <conio.h> main() { char nombre[30]; float salario,reten,salneto; clrscr(); printf(ingrese datos del empleado\n); printf(__________________\n); printf(nombre:); gest (nombre); printf(salario:);scanf(%f,&salario); printf(__________________\n); if(salario>=1500) { if(salario<=3000) reten=salario*0.05; else reten=salario*0.08; } else reten=0; salneto=salario-reten;
Pgina 13
13) ELABORE UN PROGRAMA PARA CALCULAR LA SUMA DE LOS NUMEROS N, UTILIZANDO LAESTRUCTURA WHILE
Jos Rendn Pineda Pgina 14
#include <stdio.h> #include <conio.h> main() { int x,n,suma; clrscr(); printf(ingrese un numero entero:); scanf(%d,&n) ;suma=0; x=1; while(x<=n){ //acumula la suma de los nmeros 1,2,3 ,n suma=suma+x; //genera los nmeros 1,2,3,n x=x+1; } printf(la suma de los nmeros es: %ld, suma); printf(pulse cualquiera de las teclas); getch(); }
#include <stdio.h> #include <conio.h> main() { int n,x; float fact=1; clrscr(); printf(ingrese un numero entero:); scanf(%d,&n); x=n; while(x>0){ fact=fact*x; x=x-1; } printf(el factorial de %d es: %f, n, fact); getch(); }
15) ELABORE UN PROGRAMA QUE CALCULE EL PRODUCTO DE DOS NUMEROS MEDIANTESUMAS SIN UTILIZAR EL OPERADOR (*)
Jos Rendn Pineda Pgina 16
Colegio fiscal mixto 15 de Octubre i= tipo de inters nominal n= numero de periodos por aos t= nmero de aos
#include<stdio.h> #include<conio.h> main() { float m,c,I; int n,t; clrscr(); gotoxy (6,2); printf(calculo del capital final o monto); gotoxy (17,3); printf(capital inicial:); scanf(%f,&c); gotoxy (17,4); printf(interes nominal:); scanf(%f,&i); gotoxy (6,5); printf(numero de periodos:); scanf(%d,&n); gotoxy (18,6); printf(numero de aos:); scanf(%d,&t); i=i/100; m=c*pow(1+2/n,n*t); gotoxy (19,7); printf(capital final: %2f, m); gotoxy (6,8); printf(pulse cualquier tecla); getch(); }
Pgina 18
Pgina 19
19) ELABORAR UN PROGRAMA QUE SOLICITE EL INGRESO DE UN CARCTER EN MINUSCULA Y LO CONVIERTA EN MAYUSCULA
#include <stdio.h> #include <conio.h> char mayus (char); main() {
Pgina 20
Pgina 22
Pgina 23
Pgina 24
Pgina 25
Pgina 26