1 sistema educativo universitario azteca Instituto de estudios superiores “sor Juana Inés de la cruz” plantel Tapilula EJERCICIOS DE PROGRAMACIÓN EN LENGUAJE “C” /*CALCULA EL DIA QUE LE CORRESPONDE UNA FECHA*/ DOCENTE: LSC CONCEPCIÓN LAGUNAS RODRÍGUEZ
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
sistema educativo universitario aztecaInstituto de estudios superiores “sor Juana Inés de la cruz”
plantel Tapilula
EJERCICIOS DE PROGRAMACIÓN EN LENGUAJE “C”
/*CALCULA EL DIA QUE LE CORRESPONDE UNA FECHA*/
DOCENTE: LSC CONCEPCIÓN LAGUNAS RODRÍGUEZ
1
sistema educativo universitario aztecaInstituto de estudios superiores “sor Juana Inés de la cruz”
plantel Tapilula
EJERCICIOS DE PROGRAMACIÓN EN LENGUAJE “C”
/*CALCULA EL DIA QUE LE CORRESPONDE UNA FECHA*/#include <stdio.h>#include<conio.h> #include <stdlib.h> #include<dos.h> #include <string.h> main () { int mes, dt, r, dia; char nmes [15] ,ndia [10]; clrscr () gotoxy (10,5); printf (“indicar el número del mes:”);scanf(“%d”,&mes);gotoxy (10,6);printf(“indicar el dia:”); scanf(“%d”,&dia); switch(mes)
{ case 1:{strcpy(nmes,”enero”); dt=0;break;} case 2:{strcpy(nmes, “febrero”); dt=31;break} case 3:{strcpy(nmes, “marzo” ); dt=59; break;} case 4:{strcpy(nmes, “abril “ ); dt=90;break;} case 5:{strcpy(nmes, “mayo” ); dt=190:break;} case 6:{strcpy(nmes, “junio”); dt=151;break;} case 7:{strcpy(nmes, “julio”); dt=181;break;}case 8:{strcpy(nmes, “agosto”); dt=212;break;}case 9:{strcpy(nmes, “septiembre”); dt=243;break;} case10:{strcpy(nmes, “octubre”); dt=273;break;}case 11:{strcpy(nmes, “noviembre”): dt=304;break;}case 12:{strcpy(nmes , “diciembre”) dt=334;break;}
}r= (dt+dia) %7);switch(r){ case 0: {strcpy(ndia, “martes”); break;}
}printf(“\n %-15s: %s”, nmes, ndia);gotoxy(10,22); printf(“pulsar cualquier tecla para continuar”);getch();}
DOCENTE: LSC CONCEPCIÓN LAGUNAS RODRÍGUEZ
1
sistema educativo universitario aztecaInstituto de estudios superiores “sor Juana Inés de la cruz”
plantel Tapilula
EJERCICIOS DE PROGRAMACIÓN EN LENGUAJE “C”
/* IDENTIFICA SI ES NUMERO PRIMO O NO */
#include <stdio.h>#include<conio.h> #include <stdlib.h> #include<dos.h> #include <string.h> main () {
int c, x, r;clscr ();gotoxy (28,5); printf (“introduce el numero”)scanf(“%d”, &x);c= 2;r= 1;while ( (c<x) && (r!=0) )
{r= x%c;if (r!=0)c= c+1;
}if(r!=0){
gotoxy(20,15);printf(“es un numero primo”);
}else{
gotoxy(20,15);printf(“ no es un numero primo”);
}getch();}
DOCENTE: LSC CONCEPCIÓN LAGUNAS RODRÍGUEZ
1
sistema educativo universitario aztecaInstituto de estudios superiores “sor Juana Inés de la cruz”
plantel Tapilula
EJERCICIOS DE PROGRAMACIÓN EN LENGUAJE “C”
CALCULO DE PAGO
#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<dos.h>#include<string.h>main(){float p,c,t;clrscr();gotoxy(10,8);printf("indica el valor de p");scanf("%f",&p);gotoxy(10,9);printf("indica el valor de c");scanf("%f",&c);if(c<11)t=(p*.95)*c;elseif(c<21)t=(p*.90)*c;elseif(c<36)t=(p*.85)*c;elset=(p*.75)*c;printf("\n total a pagar %f",t);gotoxy(18,36);printf("pulsa una tecla");getch();}
sistema educativo universitario aztecaInstituto de estudios superiores “sor Juana Inés de la cruz”
plantel Tapilula
EJERCICIOS DE PROGRAMACIÓN EN LENGUAJE “C”
MEMORAMA, IMPRIME 2 VECES UN MISMO NUMERO#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<dos.h>#include<string.h>int x[5][5];main(){int i, b, f, c, y, fil, col;clrscr();srand(time(NULL));for(i=1;i<=6;i=i+1){b=1;while(b==1){y=rand()%51;b=0;for(f=1;f<=4;f=f+1){for(c=1;c<=3;c=c+1){if(y==x[f][c])b=1;}}{do{fil=(rand()%4)+1;col=(rand()%3)+1;}while(x[fil][col]!=0);x[fil][col]=y;do{fil=(rand()%4)+1;col=(rand()%3)+1;}while(x[fil][col]!=0);x[fil][col]=y;}
DOCENTE: LSC CONCEPCIÓN LAGUNAS RODRÍGUEZ
1
sistema educativo universitario aztecaInstituto de estudios superiores “sor Juana Inés de la cruz”
plantel Tapilula
EJERCICIOS DE PROGRAMACIÓN EN LENGUAJE “C”
CARRERA
DOCENTE: LSC CONCEPCIÓN LAGUNAS RODRÍGUEZ
1
sistema educativo universitario aztecaInstituto de estudios superiores “sor Juana Inés de la cruz”
Case 1:{strcpy (nmes,"Enero"); tm=31; td=31; break;}Case 2:{strcpy (nmes,"Febrero"); tm=28; td=59; break;} Case 3:{strcpy (nmes,"Marzo"); tm=31; td=90; break;} Case 4:{strcpy (nmes,"Abril"); tm=30; td=120; break;} Case 5:{strcpy (nmes,"Mayo"); tm=31; td=151; break;} Case 6:{strcpy (nmes,"Junio"); tm=30; td=181; break;} Case 7:{strcpy (nmes,"Julio"); tm=31; td=212; break;} Case 8:{strcpy (nmes,"Agosto"); tm=31; td=243; break;} Case 9:{strcpy (nmes,"Septiembre"); tm=30; td=273; break;} Case 10:{strcpy (nmes,"Octubre"); tm=31; td=304; break;} Case 11:{strcpy (nmes,"Noviembre"); tm=31; td=334; break;} Case 12:{strcpy (nmes,"Diciembre"); tm=31; td=365; break;}
}
r= td%7; Switch(r); {
Case 0:{rr=2; break;} Case 1:{rr=3; break;} Case 2:{rr=4; break;} Case 3:{rr=5; break;} Case 4:{rr=6; break;} Case 5:{rr=0; break;} Case 6:{rr=1; break;}
}
DOCENTE: LSC CONCEPCIÓN LAGUNAS RODRÍGUEZ
1
sistema educativo universitario aztecaInstituto de estudios superiores “sor Juana Inés de la cruz”
plantel Tapilula
EJERCICIOS DE PROGRAMACIÓN EN LENGUAJE “C”
PRUEBA DE CADENA
DOCENTE: LSC CONCEPCIÓN LAGUNAS RODRÍGUEZ
1
sistema educativo universitario aztecaInstituto de estudios superiores “sor Juana Inés de la cruz”
sistema educativo universitario aztecaInstituto de estudios superiores “sor Juana Inés de la cruz”
plantel Tapilula
EJERCICIOS DE PROGRAMACIÓN EN LENGUAJE “C”
CONTEO DE CAMPANAS
# include<stdio.h># include<conio.h># include<stdlib.h># include<dos.h># include<string.h>Main(){Int CQ,CM,CH, ME, H1, M1, MS, H2, M2;Clrscr();CQ=0;CM=0;CH=0;gotoxy(15,8);printf(“hora de llegada”);scanf(“%d”,&H1);gotoxy(15,9);printf(“minuto de llegada”);scanf(“%d”,&M1)gotoxy(15,10);printf(“hora de retirarse”);scanf(“%d”,&H2);gotoxy(15,11);printf(“minuto de retirarse”);scanf(“%d”,M2);ME=(H1*60)+M1;MS=(H2*60)+M2;While(ME<Ms){ME=ME+1;MS=M1+1;Switch(M1){
Case 15:CQ=CQ+1; break;Case 30:CM=CM+1;breakCase 45: CQ=CQ+1;breakCase 60: CH=CH+1;M1=0;Break;}}gotoxy(10,15);printf(“campanadas de cuartos”=”%d”,CQ);gotoxy(10,17);printf(“campanadas de media=”%d”,CQ);gotoxy(10,15);printf(“campanadas de cuartos”=”%d”,CH);getch();}
DOCENTE: LSC CONCEPCIÓN LAGUNAS RODRÍGUEZ
DA LA FECHA DEL ULTIMO DOMINGO DEL MES DEL AÑO 2011
DA LA FECHA DEL ULTIMO DOMINGO DEL MES DEL AÑO 2011# include<stdio.h># include<conio.h>
#include <stdio.h>#include <conio.h>#include <stdlib.h>#include <dos.h>#include <string.h>Main(){Int C,CP,CI,N,X,R;Clrscr();C=0;CP=0;CI=0;Gotxy(10,5);Printf(“INTRODUCIR EL NUMERO DE DATOS”);
Scanf(“%d”,&N);While(C<N){Gotoxy(10,6+c);Printf(“INTRODUCIR LA CANTIDAD”);Scanf(“%d”,&X);R=X%2;If(R!=0){Textcolor(13);Gotoxy(60,6+C);cprintf(“NUMERO IMPAR”);CI=CI+1;}Else {Textcolor(13);Gotoxy(60,6+C);cprintf(“NUMERO PAR”);CP=CP+1;}C=C+1;}Gotoxy(10,20);Printf (“TOTAL DE NUMEROS IMPARES INTRODUCIDOS= %d”,CP);Gotoxy(10,21);Printf(“TOTAL DE NUMEROS IMPARES INTRODUCIDOS= %d”,CI);Getch();}
/*INTRODUCE DATOS, IMPRIME LA SUMA DE CADA FILA Y COLUMNA GENERANDO DATOS DOS VECES*/
main(){int a,b,x,y;clrscr():gotoxy(5,6);printf(“introducir el valor de a:”);scanf(“%d”,&a);gotoxy(5,7);printf(“introducir el valor de b:”);scanf(“%d”,&b);if(a>b){x=1;printf(“x=%d”,x);}else{y=4;printf(”y=%d”,y);}gotoxy(10,8);printf(“hola”);getch();}