Programa tamaño de tipo de DatosArchivo
Evelyn Lpz LitardoTrabajo9 de Febrero de 2023
6.929 Palabras (28 Páginas)48 Visitas
Programa tamaño de tipo de DatosArchivo
#include "stdio.h"
#include "iostream.h"
#include "conio.h"
void main (vacío) {
int x;
flotar y;
char a;
printf ("El tipo de dato int tiene% d bytes \ n", sizeof (x));
printf ("El tipo de dato float tiene% d bytes \ n", sizeof (y));
printf ("El tipo de dato char tiene% d bytes \ n", sizeof (a));
getch ();
}
Programa sobre arreglosArchivo
//INGRESAR 10 LA VALROES ENTEROS POR TECLADO
#include "stdio.h"
#include "conio.h"
void main(void){
int numero[10];
int i=0,j;
do{
printf("Ingrese el valor de la posic�on %d: ",i);
scanf("%d", &numero[i]);
i++;
}while(i<10);
j=1;
printf("Los valores ingresados son\n");
do{
printf("%d\n", numero[j-1]);
j++;
}while(j<=10);
getch();
}
Programa - Temperatura, mostrar mayores aArchivo
//ESCRIBIR UN PROGRAMA EN C QUE PERMITA INGRESAR N VALORES DE TEMPERATURA Y LUEGO MOSTRAR LAS MAYORES AL PRIMER VALOR INGRESADO.
//LA CANTIDAD DE TEMPERATURAS NO SERA MAYOR A 100
#include "stdio.h"
#include "conio.h"
void main(void){
float temperatura[100];
int cantidad;
int i;
printf("\n�Cuantos valores ingresara?: ");
scanf("%d",&cantidad);
for ( i=0 ; i<cantidad ; i=i+1 ){
printf("\nIngrese temperatura %d: ",i+1);
scanf("%f",&temperatura[i]);
}
printf("\n Valores mayores a %.2f",temperatura[0]);
for ( i=0 ; i<cantidad ; i=i+1 ){
if ( temperatura[i] > temperatura[0] ) {
printf("\n%.2f",temperatura[i]);
}
}
getch();
}
Programa - Temperatura, mostrar promedioArchivo
//ESCRIBIR UN PROGRAMA EN C QUE PERMITA INGRESAR 10 VALORES DE TEMPERATURA Y MUESTRE SU PROMEDIO
#include "stdio.h"
#include "conio.h"
void main(void){
float temperatura[10]; //declaracion de arreglo unidimensional
float acumulador=0, promedio;
int i;
for( i=0 ; i<10 ; i=i+1 ){
printf("\nIngrese temperatura %d: ",i+1);
scanf("%f",&temperatura[i]);
acumulador=acumulador+temperatura[i];
}
promedio=acumulador/10;
printf("\nEl promedio es %.2f",promedio);
getch();
}
Programa - Menor y Mayor de un grupo de números enterosArchivo
/*
REALIZAR UN PROGRAMA EN C QUE PERMITA INGRESAR UN MXIMO DE 100 NUMEROS ENTEROS
Y AL FINAL ME MUESTRE EL MENOR Y EL MAYOR DE LOS NUEMROS INGRSADOS
*/
#include "stdio.h"
#include "conio.h"
void main(void){
int numero[100],mayor, menor, cant;
printf("\nIngrese la cantidad de numeros: ");
scanf("%d",&cant);
if(cant>0){
for( int i=0 ; i<cant ; i=i+1){
printf("\nIngrese valor: ");
scanf("%d",&numero[i]);
if( i==0 ){
menor=numero[i];
mayor=numero[i];
}else{
if(numero[i]<menor){
menor=numero[i];
}
if(numero[i]>mayor){
mayor=numero[i];
}
}
}
printf("\nEl numero menor es %d\nEl numer mayor es %d",menor,mayor);
}else{
printf("\nCantidad de numeros incorrecta");
}
getch();
}
Programa Arreglo de caracteres - Contar letra en una fraseArchivo
//ESCRIBIR UN PROGRAMA EN C QUE PERMITA INGRESAR UNA FRASE Y UNA LETRA.
//EL PROGRAM DE BE INDICAR CUANTAS VECES SE REPITE LA LETRA EN LA FRASE.
#include "stdio.h"
#include "conio.h"
#define TAMANO_MAX 100
void main(void){
char frase[TAMANO_MAX]; //arreglo unidimensional tipo char, vector , cadena de caracteres
char letra;
int contador_letra=0;
int i;
printf("\nIngrese la frase: ");
// scanf("%s",frase);
gets(frase);
printf("\nIngrese una letra: ");
letra=(char)getch();
for( i=0 ; frase[i]!='\x0' ; i=i+1 ){
if( frase[i] == letra ){
contador_letra = contador_letra + 1 ;
}
}
Programa sobre manejo de arreglos Alumnos-NotasArchivo
//ESCRIBIR UN PROGRAMA EN C QUE PERMITA INGRESAR UN MAXIMO DE 100 NOMBRE Y ALUMNOS CON SU RESPECTIVA NOTA
//Y LUEGO MOSTRAR LA LISTA DE NOMBRES INGRESADOS CON SU NOTA.
//PERMITIR TMBIEN MOSTRAR SOLO AQUELOS NOMBRES QUE INICIEN CON UNA LETRA DETERMINADA
#include "stdio.h"
#include "conio.h"
#include "string.h"
int f_menu(void);
void main(void){
char alumnos[100][50];
float notas[100];
int cant=0;
char opc;
char letra;
do{
clrscr();
opc=(char)f_menu();
if(opc=='1'){
fflush(stdin);
if (cantidad<100){
printf("\nIngrese nombre %d: ",cant+1);
gets( alumnos[cant] );
printf("\nIngrese nota del alumno No. %d: ",cant+1);
scanf("%f",¬as[cant]);
cant++;
}else{
printf("\nYA INGRESO EL MAXIMO DE NOMBRES PERMITIDOS");
getch();
}
}else if(opc=='2'){
for( int i=0; i<cant ; i++){
printf("\nNombre : %s - Nota: %.2f",alumnos[i],notas[i]);
}
getch();
}else if(opc=='3'){
printf("\nIngrese letra: ");
letra=(char)getche();
for( int i=0; i<cant ; i++){
if(letra==alumnos[i][0]){
...