UNIVERSIDAD DE OCCIDENTE

COMPUTACION VIII


EJEMPLOS



1.- Tabla de Multiplicar 2.- Operaciones Aritmeticas 3.- Expresión 4.- Ascendente y Desendente 5.- Dígitos al Cubo



EJEMPLO 1

/****************************************************** HACER UNA TABLA DE MULTIPLICACION DEL 1 AL 10 ******************************************************/ #include int main() { int y,z,x,r,c; clrscr(); gotoxy(15,1);printf("TABLA DE MULTIPLICAR"); Z=0;R=3; for(x=1;x=<10;x++) { c="2;" for(y="1;y<=10;y++)" { z="x*y;" gotoxy(c,r);printf("%d",z); c+="5;" } r+="2;" } gotoxy(15,24);printf("ELABORADO POR: "); gotoxy(16,24);printf("\n MARIO MONJARDIN JIMENEZ "); gotoxy(18,24);printf("\n APOLONIA TAPIA GÓMEZ "); getch(); return 0; }

REGRESAR AL EJEMPLO 1
REGRESAR




EJEMPLO 2

/*********************************************************** PROGRAMA CON LAS OPERACIONES BASICAS ARITMETICAS ***********************************************************/ #include int main() { int x,y,s,r,m,d;char op; clrscr(); gotoxy(5,5);printf("[1].SUMA"); gotoxy(5,6);printf("\n[2].RESTA"); gotoxy(5,7);printf("\n[3].MULTIPLICACION"); gotoxy(5,8);printf("\n[4].DIVISION"); gotoxy(5,9);printf("\n[5].TERMINAR"); gotoxy(5,11);printf("\n[].OPCION"); gotoxy(5,12);scanf("%d",&op); switch(op); { case´1´: printf("\n SUMA"); printf("\n Teclee el 1er. num:"); scanf("%d",&x); printf("\n Teclee el 2do. num:"); scanf("%d",&y); s=x+y; printf("\n\nEl resultado de la suma es:%d",s); break; case´2´: printf("\n RESTA"); printf("\n Teclee el 1er. num:"); scanf("%d",&x); printf("\n Teclee el 2do. num:"); scanf("%d",&y); r=x-y; printf("\n\nEl resultado de la resta es:%d",r); break; case´3´: printf("\nMULTIPLICACION"); printf("\n Teclee el 1er. num:"); scanf("%d",&x); printf("\n Teclee el 2do. num:"); scanf("%d",&y); m=x*y; printf("\n\nEl resultado de la multplicación es:%d",m); break; case´4´: printf("\n DIVISION"); printf("\n Teclee el 1er. num:"); scanf("%d",&x); printf("\n Teclee el 2do. num:"); scanf("%d",&y); d=x/y; printf("\n\nEl resultado de la division es:%d",d); break; case´5´: break; } getch(); return0; }

REGRESAR AL EJEMPLO 2
REGRESAR




EJEMPLO 3

/********************************************************* HACER UN PROGRAMA QUE IMPRIMA LA SIGUIENTE EXPRESION Y SU RESULTADO **********************************************************/ #include int main() { float s,num,d,dv; num=12;d=4;s=1; clrscr(); printf(" 1 12 8 4 "); printf("\nsuma --- + --- + --- + --- = "); printf("\n 1 4 6 8 "); do { dv=num/d; s=s+dv; num=4; d+=; } while((num>4=)&&(<=8)); printf("\n\n\n suma="%f",);" getch(); return0;

REGRESAR AL EJEMPLO 3
REGRESAR




EJEMPLO 4

/***************************************************************** HACER UN PROGRAMA QUE ORDENE LOS NUMEROS EN FORMA ASCENDENTE Y DESENDENTE E IMPRIMA LOS NUMEROS IGUALE. *****************************************************************/ #include int main() { int num[10],x,y,z,cont; clrscr(); for(x=0;x<=9;x++) { printf("Teclee el valor de %d=",x); scanf(" %d",&num[x]); } x="0;" for(x="0;x<9;x++)" { for(y="x+1;y<=9;y++)" { if(num[x]>num[y]) { z=num[y]; num[y]=num[x]; num[x]=z; } } } printf("\n\nLos números Ascendentes son:"); for(x=0;x<=9;x++) printf("\n %d="%d",x,num[x]);" x="0;" for(x="0;x<9;x++)" { for(y="x+1;y<=9;y++)" { if(num[x]1) { { printf("\n El número %d,se repite % veces",num[x],cont); } } x++; } getch(); return0; }

REGRESAR AL EJEMPLO 4
REGRESAR




EJEMPLO 5

/***************************************************************** PROGRAMA QUE IMPRIME TODOS AQUELLOS NUMEROS DE 3 DIGITOS QUE CUMPLAN CON LA SIGUIENTE CONDICION. LA SUMA DE SUS DIGITOS AL CUBO SEA IGUAL A MISMO NUMERO. *****************************************************************/ #include int main() { int n,c,xd,d,v,sc; clrscr(); n=100; while(n<999) { c="n/100;" xd="n%100;" d="xd/10;" v="xd%10;" sc="(c*c*c)+(d*d*d)+(v*v*v);" if(n="=sc)" printf("\n %d",n); n++; } getch(); return0; }

REGRESAR AL EJEMPLO 5
REGRESAR


IR A LA PAGINA ANTERIOR