Costo de un Producto
REALIZAR UN PROGRAMA QUE PERMITA INGREAR NOMBRE DEL PRODUCTO ,CANTIDAD Y COSTO ,CALCULAR EL SUBTOTAL EL DESCUENTO
LA BASE IMPONIBEL ELIVA Y EL TOTAL A PAGAR MOSTRAR LOS RESULTADOS
#include
#include
main()
{
float cant,pre,subt, des, bimp,iva, tot;
char nompro[20];
cout<<" Ingrese el Producto..:";cin>>nompro;
cout<<"Ingrese Cantidad......:";cin>>cant;
cout<<"Ingrese El precio.....:";cin>>pre;
subt=cant*pre;
des=subt*0.03;
bimp=subt-des;
iva=bimp*0.12;
tot=bimp+iva;
cout<<"\n El Subtotal es.........:"<
cout<<"\n Su Descuento es.......:"<< des;
cout<<"\n La base Imponible es...:"<< bimp;
cout<<"\n El IVA es..............:"<
cout<<"\n El Total a pagar es....:"<
getch();
}
2.-AREA DE DOS RECTANGULOS
#include
#include
main()
{
float bas1,alt1,bas2,alt2,ar1,ar2,sumar,promar;
cout<<" Ingrese la Primera base ..:";cin>>bas1;
cout<<"Ingrese La Primera Altura......:";cin>>alt1;
cout<<"Ingrese La Segunda Base......:";cin>>bas2;
cout<<"Ingrese La Segunda Altura......:";cin>>alt2;
ar1=bas1*alt1;
ar2=bas2*alt2;
sumar=ar1+ar2;
promar=sumar/2;
cout<<"\n La Primera Area es..........:"<
cout<<"\n La segunda Area.............:"<< ar2;
cout<<"\n La Suma de las Areas es.....:"<< sumar;
cout<<"\n El Promedio de las Areas....:"<
getch();
}
INGRESAR 3 NOTAS Y CALCULAR EL PROMEDIO SI EL PROMEDIO ES >30 APROBADO CASO CONTRARIO REPROBADO
#include
#include
main()
{
char nom [20], mat[15];
float not1,not2,not3,sum,prom;
cout<<" Ingrese su Nombre ..:";cin>>nom;
cout<<"Ingrese Materia......:";cin>>mat;
cout<<"Ingrese Primera Nota.:";cin>>not1;
cout<<"Ingrese Segunda Nota.:";cin>>not2;
cout<<"Ingrese Tercera Nota.:";cin>>not3;
sum=not1+not2+not3;
prom=sum/3;
cout<<"\n Su promedio es...:"<
if (prom>=30)
{
cout<<"\n Aprobado:";
}
else
{
cout<<"\n Reprobado:";
}
getch();
}
INGRESAR EL SUELDO SI EL SUELDO ES MAYO A 500,00 TENDRA UN INCREMENTO DEL 5% CASO CONTRARIO DEL 3% MOSTRAR EL INCREMENTO
Y EL NUEVO SUELDO
#include
#include
main()
{
float suel,inc,suelt;
cout<<" Ingrese su Sueldo Actual ..:";cin>>suel;
if (suel>=500)
{
inc=suel*0.05;
}
else
{
inc=suel*0.03;
}
suelt=suel+inc;
cout<<"\n El Incremento es..........:"<
cout<<"\n El Nuevo sueldo es.............:"<< suelt;
getch();
}
INGRESAR 3 NUMEROS SI LOS NUMEROS INGRESADOS SON IGUALES INGRESAR OTRO NUMERO Y GENERAR DESDE EL NUMERO INGRESADO HASTA EL TRIPLE CASO CONTRARIO DESDE EL 21 HASTA EL 1 DE DOS EN DOS ES DECIR 21,19,17.......1
#include
#include
main()
{
int n1,n2,n3,n,c,f;
gotoxy(30,2);printf("GENERADOR DE NUMEROS");
gotoxy(10,3);printf("INGRESE PRIMER NUMERO.....");scanf ("%d",&n1);
gotoxy(10,4);printf ("INGRESE SEGUNDO NUMERO....:");scanf("%d",&n2);
gotoxy(10,5);printf ("INGRESE TERCER NUMERO....:");scanf("%d",&n3);
if (n1==n2 && n2==n3)
{
gotoxy (10,6);printf ("INGRESE NUMERO....:");scanf("%d",&n);
f=7;
for (c=n;c<=n*3;c=c+1)
{
gotoxy(10,f);printf("%d",c);
f=f+1;
}
}
else
{
f=7;
for(c=21;c>=1;c=c-2)
{
f=f+1;
gotoxy(10,f);printf("%d",c);
}
}
getch();
}
Aporte al IESS
#include
#include
main()
{
char nom [25],car [20];
int edad;
float suel,apor;
gotoxy (33,1);printf ("EMPRESA A.B.C.");
gotoxy (8,2);printf ("NOMBRE...");scanf("%s",& nom);
gotoxy (8,3);printf ("EDAD...");scanf("%d",& edad);
gotoxy (8,4);printf ("CARGO...");scanf("%s",& car);
gotoxy (8,5);printf ("SUELDO...");scanf("%f",& suel);
apor=suel*0.0935;
gotoxy (8,7);printf ("APORTE AL IESS ES: %f",apor);
getch();
}
Centigrados a Fahrenheit con For
#include
#include
main()
{
int c ;
float far;
gotoxy (22,1);printf("CALCULO DE CENTIGRADOS A FAHRENHEIT");
gotoxy (6,3);printf(" CENTIGRADOS" );
gotoxy (47,3);printf(" FAHRENHEIT" );
for (c=1 ; c<=20;c=c+1)
{
gotoxy(10,c+4);printf("%d",c);
far=((c*9)/5+32);
gotoxy(50,c+4);printf("%.2f",far);
}
getch();
}
CONDICION IF
INGRESAR 1 NUMERO SI EL RECIDUO ES "0" INGRESAR DOS NUMEROS Y SACAR LA DIFERNCIA Y EL PRODUCTO
CASO CONTRARIO INGRESAR 3 NUMEROS Y SACAR EL PROMEDIO DE LOS 3 NUMEROS INGRESADOS MOSTRAR LOS RESULTADOS
#include
#include
main()
{
float n1,n2,n3,dif,mul,sum,prom;
int res,num;
cout<<" Un Numero ..:";cin>>num;
res=num%2;
if (res==0)
{
cout<<"Ingrese Primer Numero......:";cin>>n1;
cout<<"Ingrese Segundo Numero.:";cin>>n2;
dif=n1-n2;
mul=n1*n2;
cout<<"\n La Diferencia es...:"<
cout<<"\n El producto es...:"<
}
else
{
cout<<"Ingrese Primer Numero......:";cin>>n1;
cout<<"Ingrese Segundo Numero.:";cin>>n2;
cout<<"Ingrese Tercer Numero.:";cin>>n3;
sum=n1+n2+n3;
prom=sum/3;
cout<<"\n La suma es...:"<
cout<<"\n El Promedio es...:"<
}
getch();
}
INGRESAR DOS NUMEROS SI LOS NUMERO DIVIDIDO PARA 3 ES RESIDUO ES IGUAL ACERO
GENERAR EL TRIPLE DEL SEGUNDO NUMERO HASTA EL 1 EN FORMA DESEDENTE
#include
#include
main()
{
int n1,n2,m1,m2,c,f;
f=7;
gotoxy (29,2);printf("GENERADOR DE NUMEROS");
gotoxy (10,4);printf ("INGRESE PRIMER NUMERO....:");scanf("%d",&n1);
gotoxy (10,5);printf ("INGRESE SEGUNDO NUMERO....:");scanf("%d",&n2);
m1=n1%3;
m2=n2%3;
if (m1==0 || m2==0)
{
for (c=n2*3;c>=1;c=c-1)
{
gotoxy(10,f);printf("%d",c);
f=f+1;
}
}
getch();
}
SACAR EL PROMEDIO DE 5 PARCIALES CON EL WHILE
#include
#include
main()
{
char nom [30],mat [30];
int c,f;
float sum,prom,n;
gotoxy (30,1);printf("Colegio la Esperanza");
gotoxy (10,3);printf ("Nombre....:");scanf("%s",&nom);
gotoxy (50,3);printf ("Materia....:");scanf("%s",&mat);
f=5;
c=1 ;
sum=0;
while (c<=5)
{
gotoxy(10,f);printf ("Ingrese Parcial...: %d",c);scanf("%f",&n);
sum=sum+n;
c=c+1;
f=f+1;
}
prom=sum/5;
gotoxy (15,f+1);printf("La Suma es...:%.2f",sum);
gotoxy (15,f+2);printf("El Promedio es...:%.2f",prom);
if (prom>=30)
{
gotoxy (15,f+3);printf("Aprobado...:");
}
else
{
gotoxy (15,f+3);printf("Reprobado...:");
}
getch();
}
MATRICES Y VECTORES
CONVINACION DE MATRICES Y VECTORES
CREAR UN VECTOR DE 3x3 Y UN VECTOR DE 9 INGREASAR DATOS EN L AMATRIZ Y
PASAR LOS DATOS AL VECTOR EN EL M ISMO ORDEN COMO FUERON INGRESADO
#include
#include
main()
{
int mat[3][3],vec[9],fil,col,dirvec,posfil;
char s;
do
{
clrscr ();
posfil=5;
dirvec=0;
for(fil=0;fil<=2;fil++)
{
for(col=0;col<=2;col++)
{
gotoxy(10,posfil);printf ("Ingrese Matriz[%d][%d]",fil,col);scanf("%d",&mat[fil][col]);
vec[dirvec]=mat[fil][col];
dirvec++;
posfil++;
}
}
for (dirvec=0;dirvec<=8;dirvec++)
{
gotoxy(10,posfil+1);printf("Nueve vector es [%d]:%d",dirvec,vec[dirvec]);
posfil++;
}
gotoxy(10,30);printf("DESEA CONTINUAR S/N");scanf("%s",&s);
}
while(s=='s');
getch ();
}
5 VALORES CALCULAR LA SUMA CON ARRAY CON WHILE
#include
#include
main()
{
int vec[6], f,c;
vec[5]=0;
c=0;
f=5;
while(c<=4)
{
gotoxy (2,f);printf("Ingrese Valor :[%d]",c);scanf("%d",&vec[c]);
vec[5]=vec[5]+vec[c];
c=c+1;
f=f+1;
}
gotoxy (2,f);printf ("La Suma es...:%d",vec[5]);
getch ();
}
5 VALORES CALCULAR LA SUMA CON ARRAY SIN FOR
#include
#include
main()
{
int vec[6];
gotoxy (2,2);printf("Ingrese Valor 1:");scanf("%d",&vec[0]);
gotoxy (2,3);printf("Ingrese Valor 2:");scanf("%d",&vec[1]);
gotoxy (2,4);printf("Ingrese Valor 3:");scanf("%d",&vec[2]);
gotoxy (2,5);printf("Ingrese Valor 4:");scanf("%d",&vec[3]);
gotoxy (2,6);printf("Ingrese Valor 5:");scanf("%d",&vec[4]);
vec[5]=vec[0]+vec[1]+vec[2]+vec[3]+vec[4];
gotoxy (2,8);printf ("La Suma es...:%d",vec[5]);
getch ();
}
19 VALORES CALCULAR LA SUMA CON ARRAY CON FOR
#include
#include
main()
{
int vec[20], f,c;
vec[19]=0;
c=0;
f=5;
for(c=0;c<=18;c=c+1)
{
gotoxy (2,f);printf("Ingrese Valor :[%d]",c);scanf("%d",&vec[c]);
f++;
vec[19]=vec[19]+vec[c];
}
gotoxy (2,f);printf ("La Suma es...:%d",vec[19]);
getch ();
}
19 VALORES CALCULAR LA SUMA CON ARRAY CON WHILE
#include
#include
main()
{
int vec[20], f,c;
vec[19]=0;
c=0;
f=5;
while(c<=18)
{
gotoxy (2,f);printf("Ingrese Valor :[%d]",c);scanf("%d",&vec[c]);
vec[19]=vec[19]+vec[c];
c=c+1;
f=f+1;
}
gotoxy (2,f);printf ("La Suma es...:%d",vec[19]);
getch ();
}
CREAR DOS VECTORES INGREASAR DATOS EN EL PRIMER VECTOR PASAR LOS DATOS AL SEGUNDO VECTOR DE FORMA INVERSA
#include
#include
main()
{
int vec1[5],vec2[5],c,f,i;
char s;
do
{
clrscr ();
f=2;
i=4;
for(c=0;c<=4;c++)
{
gotoxy(2,f);printf("Ingresar Valor en el Vector..1[%d]",c);scanf("%d",&vec1[c]);
f++;
}
f=2;
for (c=0;c<=4;c++)
{
vec2[i-c]=vec1[c];
}
for (c=0;c<=4;c++)
{
gotoxy(40,f);printf("Nuevo Valor del vector[%d]:%d",c,vec2[c]);
f++;
}
gotoxy(5,f+8);printf("DESEA CONTINUAR S / N");scanf("%s",&s);
}
while(s=='s');
getch ();
}
CREAR UNA MATRIZ DE 3X3 Y SUMAR LOS DATOS INGRESADOS
#include
#include
main()
{
int mat[3][3],sum,fil,col,posfil,f;
char s;
do
{
clrscr ();
sum=0;
posfil=3;
for(fil=0;fil<=2;fil++)
{
for(col=0;col<=2;col++)
{
gotoxy(5,posfil);printf("Ingresar Valor la matriz..[%d][%d]",fil,col);scanf("%d",&mat[fil][col]);
sum=sum+mat[fil][col];
posfil++;
}
}
gotoxy(5,posfil);printf("La suma es[%d]:%d",sum);
f=7*2;
gotoxy(5,f);printf("DESEA CONTINUAR S/N");scanf("%s",&s);
}
while(s=='s');
getch ();
}
GENERARA UNA MATRIZ DIAGONAL CON 1
#include
#include
main()
{
int mat1[6][6],fil,col,posfil,poscol,c,f;
char s;
do
{
clrscr ();
for(fil=0;fil<=5;fil++)
{
for(col=0;col<=5;col++)
{
if (fil==col)
{
mat1[fil][col]=1;
}
else
{
mat1[fil][col]=0;
}
}
}
posfil=3;
for(fil=0;fil<=5;fil++)
{
poscol=5;
for(col=0;col<=5;col++)
{
gotoxy(poscol,posfil);printf("%d",mat1[fil][col]);
poscol=poscol+2;
}
posfil++;
}
f=15;
gotoxy(5,f);printf("DESEA CONTINUAR S/N");scanf("%s",&s);
}
while(s=='s');
getch ();
}
MULTIPLICAR DOS MATRICES MATRICES
#include
#include
main()
{
int mat1[3][4],mat2[4][3],mat3[3][4],sum,fil,col,posfil,f;
char s;
do
{
clrscr ();
sum=0;
posfil=3;
for(fil=0;fil<=2;fil++)
{
for(col=0;col<=3;col++)
{
gotoxy(5,posfil);printf("Matriz..1[%d][%d]",fil,col);scanf("%d",&mat1[fil][col]);
gotoxy(25,posfil);printf("Matriz..2[%d][%d]",fil,col);scanf("%d",&mat2[col][fil]);
posfil++;
}
}
posfil=3;
for(fil=0;fil<=2;fil++)
{
for(col=0;col<=3;col++)
{
mat3[fil][col]=mat1[fil][col]*mat2[col][fil];
gotoxy(44,posfil++);printf("La Nueva Matriz es[%d]:%d",mat3[fil][col]);
}
}
f=10*2;
gotoxy(5,f);printf("DESEA CONTINUAR S/N");scanf("%s",&s);
}
while(s=='s');
getch ();
}
CREAR UN VECTOR DE 10 INGRESAR DATOS EN LOS 5 PRIMEROS SI EL NUMERO IGRESADO ES PAR MOSTRAR UN 1 CASO CONTRARIO MOSTRAR 0
MOSTRAR EL VECTOR
#include
#include
main()
{
int vec[10],c,f;
char s;
do
{
clrscr ();
f=2;
for(c=0;c<=4;c++)
{
gotoxy(2,f);printf("Ingresar Valor en el Vector..[%d]",c);scanf("%d",&vec[c]);
if (vec[c]%2==0)
{
vec[c+5]=1;
}
else
{
vec[c+5]=0;
}
f++;
}
f=2;
for (c=9;c>=0;c--)
{
gotoxy(40,f++);printf("Valor del Vector[%d]:%d",c,vec[c]);
}
gotoxy(5,f+2);printf("DESEA CONTINUAR S / N");scanf("%s",&s);
}
while(s=='s');
getch ();
}
FUNCIONES
recibe_y_retorna
#include
#include
int mayor (int n1,int n2)
{
int may;
if (n1>n2)
may=n1 ;
else
may=n2;
return may;
}
main()
{
int num1,num2,may;
gotoxy(2,2);printf("Ingrese Primer número:..");scanf("%d",&num1);
gotoxy(2,3);printf("Ingrese Segundo Número:..");scanf("%d",&num2);
may=mayor(num1,num2);
gotoxy(2,4);printf("El Mayores :%d",may);
getch ();
}
recibe_y_no_retorna
#include
#include
void mayor (int n1,int n2)
{
int may;
if (n1>n2)
may=n1 ;
else
may=n2;
gotoxy(2,4);printf("El Mayor es :%d",may);
}
main()
{
int num1,num2;
gotoxy(2,2);printf("Ingrese Primer número:..");scanf("%d",&num1);
gotoxy(2,3);printf("Ingrese Segundo Número:..");scanf("%d",&num2);
mayor(num1,num2);
getch ();
}
no_recibe_y_retorna
#include
#include
int mayor ()
{
int num1,num2,mayor;
gotoxy(2,2);printf("Ingrese Primer número:..");scanf("%d",&num1);
gotoxy(2,3);printf("Ingrese Segundo Número:..");scanf("%d",&num2);
int may;
if (num1>num2)
may=num1 ;
else
may=num2;
return may;
}
main()
{
int may;
may= mayor();
gotoxy(2,4);printf("El Mayor es :%d",may);
getch ();
}
INGRESAR_2_NIMEROS_SI_EL_PRIMERO_ES_MAYOR_QUE_EL_SEGUNDO_CALCULAR_EL_RESIDUO_DEL_PRIMERO_PARA_EL_SEGUNDO
CASO_CONTRARIO_CALCULAR_LA_DIFERNCIA_DEL_PRIMERO_Y_EL_SEGUNDO
RECIBE_Y_RETORNA
#include
#include
int mayor (int n1,int n2)
{
int may,res,dif;
if (n1>n2)
{
may=n1;
res=residuo(n1,n2);
gotoxy(2,4);printf("El residuo es :%d",res);
}
else
{
may=n2;
dif=diferencia(n1,n2);
gotoxy(2,4);printf("La diferencia es :%d",dif);
}
return may;
}
int diferencia(int n1,int n2)
{
int dif;
dif=n1-n2;
return dif;
}
int residuo(int n1,int n2)
{
int res;
res=n1%n2;
return res;
}
main()
{
REALIZAR UN PROGRAMA QUE PERMITA INGREAR NOMBRE DEL PRODUCTO ,CANTIDAD Y COSTO ,CALCULAR EL SUBTOTAL EL DESCUENTO
LA BASE IMPONIBEL ELIVA Y EL TOTAL A PAGAR MOSTRAR LOS RESULTADOS
#include
#include
main()
{
float cant,pre,subt, des, bimp,iva, tot;
char nompro[20];
cout<<" Ingrese el Producto..:";cin>>nompro;
cout<<"Ingrese Cantidad......:";cin>>cant;
cout<<"Ingrese El precio.....:";cin>>pre;
subt=cant*pre;
des=subt*0.03;
bimp=subt-des;
iva=bimp*0.12;
tot=bimp+iva;
cout<<"\n El Subtotal es.........:"<
cout<<"\n Su Descuento es.......:"<< des;
cout<<"\n La base Imponible es...:"<< bimp;
cout<<"\n El IVA es..............:"<
cout<<"\n El Total a pagar es....:"<
getch();
}
2.-AREA DE DOS RECTANGULOS
#include
#include
main()
{
float bas1,alt1,bas2,alt2,ar1,ar2,sumar,promar;
cout<<" Ingrese la Primera base ..:";cin>>bas1;
cout<<"Ingrese La Primera Altura......:";cin>>alt1;
cout<<"Ingrese La Segunda Base......:";cin>>bas2;
cout<<"Ingrese La Segunda Altura......:";cin>>alt2;
ar1=bas1*alt1;
ar2=bas2*alt2;
sumar=ar1+ar2;
promar=sumar/2;
cout<<"\n La Primera Area es..........:"<
cout<<"\n La segunda Area.............:"<< ar2;
cout<<"\n La Suma de las Areas es.....:"<< sumar;
cout<<"\n El Promedio de las Areas....:"<
getch();
}
INGRESAR 3 NOTAS Y CALCULAR EL PROMEDIO SI EL PROMEDIO ES >30 APROBADO CASO CONTRARIO REPROBADO
#include
#include
main()
{
char nom [20], mat[15];
float not1,not2,not3,sum,prom;
cout<<" Ingrese su Nombre ..:";cin>>nom;
cout<<"Ingrese Materia......:";cin>>mat;
cout<<"Ingrese Primera Nota.:";cin>>not1;
cout<<"Ingrese Segunda Nota.:";cin>>not2;
cout<<"Ingrese Tercera Nota.:";cin>>not3;
sum=not1+not2+not3;
prom=sum/3;
cout<<"\n Su promedio es...:"<
if (prom>=30)
{
cout<<"\n Aprobado:";
}
else
{
cout<<"\n Reprobado:";
}
getch();
}
INGRESAR EL SUELDO SI EL SUELDO ES MAYO A 500,00 TENDRA UN INCREMENTO DEL 5% CASO CONTRARIO DEL 3% MOSTRAR EL INCREMENTO
Y EL NUEVO SUELDO
#include
#include
main()
{
float suel,inc,suelt;
cout<<" Ingrese su Sueldo Actual ..:";cin>>suel;
if (suel>=500)
{
inc=suel*0.05;
}
else
{
inc=suel*0.03;
}
suelt=suel+inc;
cout<<"\n El Incremento es..........:"<
cout<<"\n El Nuevo sueldo es.............:"<< suelt;
getch();
}
INGRESAR 3 NUMEROS SI LOS NUMEROS INGRESADOS SON IGUALES INGRESAR OTRO NUMERO Y GENERAR DESDE EL NUMERO INGRESADO HASTA EL TRIPLE CASO CONTRARIO DESDE EL 21 HASTA EL 1 DE DOS EN DOS ES DECIR 21,19,17.......1
#include
#include
main()
{
int n1,n2,n3,n,c,f;
gotoxy(30,2);printf("GENERADOR DE NUMEROS");
gotoxy(10,3);printf("INGRESE PRIMER NUMERO.....");scanf ("%d",&n1);
gotoxy(10,4);printf ("INGRESE SEGUNDO NUMERO....:");scanf("%d",&n2);
gotoxy(10,5);printf ("INGRESE TERCER NUMERO....:");scanf("%d",&n3);
if (n1==n2 && n2==n3)
{
gotoxy (10,6);printf ("INGRESE NUMERO....:");scanf("%d",&n);
f=7;
for (c=n;c<=n*3;c=c+1)
{
gotoxy(10,f);printf("%d",c);
f=f+1;
}
}
else
{
f=7;
for(c=21;c>=1;c=c-2)
{
f=f+1;
gotoxy(10,f);printf("%d",c);
}
}
getch();
}
Aporte al IESS
#include
#include
main()
{
char nom [25],car [20];
int edad;
float suel,apor;
gotoxy (33,1);printf ("EMPRESA A.B.C.");
gotoxy (8,2);printf ("NOMBRE...");scanf("%s",& nom);
gotoxy (8,3);printf ("EDAD...");scanf("%d",& edad);
gotoxy (8,4);printf ("CARGO...");scanf("%s",& car);
gotoxy (8,5);printf ("SUELDO...");scanf("%f",& suel);
apor=suel*0.0935;
gotoxy (8,7);printf ("APORTE AL IESS ES: %f",apor);
getch();
}
Centigrados a Fahrenheit con For
#include
#include
main()
{
int c ;
float far;
gotoxy (22,1);printf("CALCULO DE CENTIGRADOS A FAHRENHEIT");
gotoxy (6,3);printf(" CENTIGRADOS" );
gotoxy (47,3);printf(" FAHRENHEIT" );
for (c=1 ; c<=20;c=c+1)
{
gotoxy(10,c+4);printf("%d",c);
far=((c*9)/5+32);
gotoxy(50,c+4);printf("%.2f",far);
}
getch();
}
CONDICION IF
INGRESAR 1 NUMERO SI EL RECIDUO ES "0" INGRESAR DOS NUMEROS Y SACAR LA DIFERNCIA Y EL PRODUCTO
CASO CONTRARIO INGRESAR 3 NUMEROS Y SACAR EL PROMEDIO DE LOS 3 NUMEROS INGRESADOS MOSTRAR LOS RESULTADOS
#include
#include
main()
{
float n1,n2,n3,dif,mul,sum,prom;
int res,num;
cout<<" Un Numero ..:";cin>>num;
res=num%2;
if (res==0)
{
cout<<"Ingrese Primer Numero......:";cin>>n1;
cout<<"Ingrese Segundo Numero.:";cin>>n2;
dif=n1-n2;
mul=n1*n2;
cout<<"\n La Diferencia es...:"<
cout<<"\n El producto es...:"<
}
else
{
cout<<"Ingrese Primer Numero......:";cin>>n1;
cout<<"Ingrese Segundo Numero.:";cin>>n2;
cout<<"Ingrese Tercer Numero.:";cin>>n3;
sum=n1+n2+n3;
prom=sum/3;
cout<<"\n La suma es...:"<
cout<<"\n El Promedio es...:"<
}
getch();
}
INGRESAR DOS NUMEROS SI LOS NUMERO DIVIDIDO PARA 3 ES RESIDUO ES IGUAL ACERO
GENERAR EL TRIPLE DEL SEGUNDO NUMERO HASTA EL 1 EN FORMA DESEDENTE
#include
#include
main()
{
int n1,n2,m1,m2,c,f;
f=7;
gotoxy (29,2);printf("GENERADOR DE NUMEROS");
gotoxy (10,4);printf ("INGRESE PRIMER NUMERO....:");scanf("%d",&n1);
gotoxy (10,5);printf ("INGRESE SEGUNDO NUMERO....:");scanf("%d",&n2);
m1=n1%3;
m2=n2%3;
if (m1==0 || m2==0)
{
for (c=n2*3;c>=1;c=c-1)
{
gotoxy(10,f);printf("%d",c);
f=f+1;
}
}
getch();
}
SACAR EL PROMEDIO DE 5 PARCIALES CON EL WHILE
#include
#include
main()
{
char nom [30],mat [30];
int c,f;
float sum,prom,n;
gotoxy (30,1);printf("Colegio la Esperanza");
gotoxy (10,3);printf ("Nombre....:");scanf("%s",&nom);
gotoxy (50,3);printf ("Materia....:");scanf("%s",&mat);
f=5;
c=1 ;
sum=0;
while (c<=5)
{
gotoxy(10,f);printf ("Ingrese Parcial...: %d",c);scanf("%f",&n);
sum=sum+n;
c=c+1;
f=f+1;
}
prom=sum/5;
gotoxy (15,f+1);printf("La Suma es...:%.2f",sum);
gotoxy (15,f+2);printf("El Promedio es...:%.2f",prom);
if (prom>=30)
{
gotoxy (15,f+3);printf("Aprobado...:");
}
else
{
gotoxy (15,f+3);printf("Reprobado...:");
}
getch();
}
MATRICES Y VECTORES
CONVINACION DE MATRICES Y VECTORES
CREAR UN VECTOR DE 3x3 Y UN VECTOR DE 9 INGREASAR DATOS EN L AMATRIZ Y
PASAR LOS DATOS AL VECTOR EN EL M ISMO ORDEN COMO FUERON INGRESADO
#include
#include
main()
{
int mat[3][3],vec[9],fil,col,dirvec,posfil;
char s;
do
{
clrscr ();
posfil=5;
dirvec=0;
for(fil=0;fil<=2;fil++)
{
for(col=0;col<=2;col++)
{
gotoxy(10,posfil);printf ("Ingrese Matriz[%d][%d]",fil,col);scanf("%d",&mat[fil][col]);
vec[dirvec]=mat[fil][col];
dirvec++;
posfil++;
}
}
for (dirvec=0;dirvec<=8;dirvec++)
{
gotoxy(10,posfil+1);printf("Nueve vector es [%d]:%d",dirvec,vec[dirvec]);
posfil++;
}
gotoxy(10,30);printf("DESEA CONTINUAR S/N");scanf("%s",&s);
}
while(s=='s');
getch ();
}
5 VALORES CALCULAR LA SUMA CON ARRAY CON WHILE
#include
#include
main()
{
int vec[6], f,c;
vec[5]=0;
c=0;
f=5;
while(c<=4)
{
gotoxy (2,f);printf("Ingrese Valor :[%d]",c);scanf("%d",&vec[c]);
vec[5]=vec[5]+vec[c];
c=c+1;
f=f+1;
}
gotoxy (2,f);printf ("La Suma es...:%d",vec[5]);
getch ();
}
5 VALORES CALCULAR LA SUMA CON ARRAY SIN FOR
#include
#include
main()
{
int vec[6];
gotoxy (2,2);printf("Ingrese Valor 1:");scanf("%d",&vec[0]);
gotoxy (2,3);printf("Ingrese Valor 2:");scanf("%d",&vec[1]);
gotoxy (2,4);printf("Ingrese Valor 3:");scanf("%d",&vec[2]);
gotoxy (2,5);printf("Ingrese Valor 4:");scanf("%d",&vec[3]);
gotoxy (2,6);printf("Ingrese Valor 5:");scanf("%d",&vec[4]);
vec[5]=vec[0]+vec[1]+vec[2]+vec[3]+vec[4];
gotoxy (2,8);printf ("La Suma es...:%d",vec[5]);
getch ();
}
19 VALORES CALCULAR LA SUMA CON ARRAY CON FOR
#include
#include
main()
{
int vec[20], f,c;
vec[19]=0;
c=0;
f=5;
for(c=0;c<=18;c=c+1)
{
gotoxy (2,f);printf("Ingrese Valor :[%d]",c);scanf("%d",&vec[c]);
f++;
vec[19]=vec[19]+vec[c];
}
gotoxy (2,f);printf ("La Suma es...:%d",vec[19]);
getch ();
}
19 VALORES CALCULAR LA SUMA CON ARRAY CON WHILE
#include
#include
main()
{
int vec[20], f,c;
vec[19]=0;
c=0;
f=5;
while(c<=18)
{
gotoxy (2,f);printf("Ingrese Valor :[%d]",c);scanf("%d",&vec[c]);
vec[19]=vec[19]+vec[c];
c=c+1;
f=f+1;
}
gotoxy (2,f);printf ("La Suma es...:%d",vec[19]);
getch ();
}
CREAR DOS VECTORES INGREASAR DATOS EN EL PRIMER VECTOR PASAR LOS DATOS AL SEGUNDO VECTOR DE FORMA INVERSA
#include
#include
main()
{
int vec1[5],vec2[5],c,f,i;
char s;
do
{
clrscr ();
f=2;
i=4;
for(c=0;c<=4;c++)
{
gotoxy(2,f);printf("Ingresar Valor en el Vector..1[%d]",c);scanf("%d",&vec1[c]);
f++;
}
f=2;
for (c=0;c<=4;c++)
{
vec2[i-c]=vec1[c];
}
for (c=0;c<=4;c++)
{
gotoxy(40,f);printf("Nuevo Valor del vector[%d]:%d",c,vec2[c]);
f++;
}
gotoxy(5,f+8);printf("DESEA CONTINUAR S / N");scanf("%s",&s);
}
while(s=='s');
getch ();
}
CREAR UNA MATRIZ DE 3X3 Y SUMAR LOS DATOS INGRESADOS
#include
#include
main()
{
int mat[3][3],sum,fil,col,posfil,f;
char s;
do
{
clrscr ();
sum=0;
posfil=3;
for(fil=0;fil<=2;fil++)
{
for(col=0;col<=2;col++)
{
gotoxy(5,posfil);printf("Ingresar Valor la matriz..[%d][%d]",fil,col);scanf("%d",&mat[fil][col]);
sum=sum+mat[fil][col];
posfil++;
}
}
gotoxy(5,posfil);printf("La suma es[%d]:%d",sum);
f=7*2;
gotoxy(5,f);printf("DESEA CONTINUAR S/N");scanf("%s",&s);
}
while(s=='s');
getch ();
}
GENERARA UNA MATRIZ DIAGONAL CON 1
#include
#include
main()
{
int mat1[6][6],fil,col,posfil,poscol,c,f;
char s;
do
{
clrscr ();
for(fil=0;fil<=5;fil++)
{
for(col=0;col<=5;col++)
{
if (fil==col)
{
mat1[fil][col]=1;
}
else
{
mat1[fil][col]=0;
}
}
}
posfil=3;
for(fil=0;fil<=5;fil++)
{
poscol=5;
for(col=0;col<=5;col++)
{
gotoxy(poscol,posfil);printf("%d",mat1[fil][col]);
poscol=poscol+2;
}
posfil++;
}
f=15;
gotoxy(5,f);printf("DESEA CONTINUAR S/N");scanf("%s",&s);
}
while(s=='s');
getch ();
}
MULTIPLICAR DOS MATRICES MATRICES
#include
#include
main()
{
int mat1[3][4],mat2[4][3],mat3[3][4],sum,fil,col,posfil,f;
char s;
do
{
clrscr ();
sum=0;
posfil=3;
for(fil=0;fil<=2;fil++)
{
for(col=0;col<=3;col++)
{
gotoxy(5,posfil);printf("Matriz..1[%d][%d]",fil,col);scanf("%d",&mat1[fil][col]);
gotoxy(25,posfil);printf("Matriz..2[%d][%d]",fil,col);scanf("%d",&mat2[col][fil]);
posfil++;
}
}
posfil=3;
for(fil=0;fil<=2;fil++)
{
for(col=0;col<=3;col++)
{
mat3[fil][col]=mat1[fil][col]*mat2[col][fil];
gotoxy(44,posfil++);printf("La Nueva Matriz es[%d]:%d",mat3[fil][col]);
}
}
f=10*2;
gotoxy(5,f);printf("DESEA CONTINUAR S/N");scanf("%s",&s);
}
while(s=='s');
getch ();
}
CREAR UN VECTOR DE 10 INGRESAR DATOS EN LOS 5 PRIMEROS SI EL NUMERO IGRESADO ES PAR MOSTRAR UN 1 CASO CONTRARIO MOSTRAR 0
MOSTRAR EL VECTOR
#include
#include
main()
{
int vec[10],c,f;
char s;
do
{
clrscr ();
f=2;
for(c=0;c<=4;c++)
{
gotoxy(2,f);printf("Ingresar Valor en el Vector..[%d]",c);scanf("%d",&vec[c]);
if (vec[c]%2==0)
{
vec[c+5]=1;
}
else
{
vec[c+5]=0;
}
f++;
}
f=2;
for (c=9;c>=0;c--)
{
gotoxy(40,f++);printf("Valor del Vector[%d]:%d",c,vec[c]);
}
gotoxy(5,f+2);printf("DESEA CONTINUAR S / N");scanf("%s",&s);
}
while(s=='s');
getch ();
}
FUNCIONES
recibe_y_retorna
#include
#include
int mayor (int n1,int n2)
{
int may;
if (n1>n2)
may=n1 ;
else
may=n2;
return may;
}
main()
{
int num1,num2,may;
gotoxy(2,2);printf("Ingrese Primer número:..");scanf("%d",&num1);
gotoxy(2,3);printf("Ingrese Segundo Número:..");scanf("%d",&num2);
may=mayor(num1,num2);
gotoxy(2,4);printf("El Mayores :%d",may);
getch ();
}
recibe_y_no_retorna
#include
#include
void mayor (int n1,int n2)
{
int may;
if (n1>n2)
may=n1 ;
else
may=n2;
gotoxy(2,4);printf("El Mayor es :%d",may);
}
main()
{
int num1,num2;
gotoxy(2,2);printf("Ingrese Primer número:..");scanf("%d",&num1);
gotoxy(2,3);printf("Ingrese Segundo Número:..");scanf("%d",&num2);
mayor(num1,num2);
getch ();
}
no_recibe_y_retorna
#include
#include
int mayor ()
{
int num1,num2,mayor;
gotoxy(2,2);printf("Ingrese Primer número:..");scanf("%d",&num1);
gotoxy(2,3);printf("Ingrese Segundo Número:..");scanf("%d",&num2);
int may;
if (num1>num2)
may=num1 ;
else
may=num2;
return may;
}
main()
{
int may;
may= mayor();
gotoxy(2,4);printf("El Mayor es :%d",may);
getch ();
}
INGRESAR_2_NIMEROS_SI_EL_PRIMERO_ES_MAYOR_QUE_EL_SEGUNDO_CALCULAR_EL_RESIDUO_DEL_PRIMERO_PARA_EL_SEGUNDO
CASO_CONTRARIO_CALCULAR_LA_DIFERNCIA_DEL_PRIMERO_Y_EL_SEGUNDO
RECIBE_Y_RETORNA
#include
#include
int mayor (int n1,int n2)
{
int may,res,dif;
if (n1>n2)
{
may=n1;
res=residuo(n1,n2);
gotoxy(2,4);printf("El residuo es :%d",res);
}
else
{
may=n2;
dif=diferencia(n1,n2);
gotoxy(2,4);printf("La diferencia es :%d",dif);
}
return may;
}
int diferencia(int n1,int n2)
{
int dif;
dif=n1-n2;
return dif;
}
int residuo(int n1,int n2)
{
int res;
res=n1%n2;
return res;
}
main()
{

No hay comentarios:
Publicar un comentario