Ejercicios Resuletos De Visual Basic En Lenguaje C
CARLOS ADRIAN GOMEZ ALMARAS
ACT. 1.- PROJECTOS EN C++
06/08/2012
2012
CARLOS ADRIAN GOMEZ ALMARAS
ACT. 1.- PROJECTOS EN C++
06/08/2012
PROFESOR: DOMINGO ORNELAS PÉREZ
PROFESOR: DOMINGO ORNELAS PÉREZ
PROGRAMACION ESTRUCTURADA
PROGRAMACION ESTRUCTURADA
/**********arreglos bidimensionales*********/
#include <stdio.h>
#include <conio.h>
void main ()
{
intmatrix [3] [3], r=0, c=0;
for (r=0; r<=2; r++)
{
for (c=0; c<=2; c++)
{
printf ("Ingrese el valor ");
scanf ("%d", & matrix [r] [c]);
}
c=0;
}
for (r=0; r<=2; r++)
{
for (c=0; c<=2; c++)
{
printf ("%d\t ", matrix [r] [c]);
}
c=0;
}
getch ();
}
Ingrese el valor 9
Ingrese el valor 8
Ingrese el valor 7
Ingreseel valor 6
Ingrese el valor 5
Ingrese el valor 4
Ingrese el valor 3
Ingrese el valor 2
Ingrese el valor 1
9 8 7 6 5
4 3 2 1
/***********matriz cuadrada***********/
#include <stdio.h>
#include <conio.h>
void main()
{
int matrix [3][3], r=0, c=0, suma=0;
for (r=0; r<=2; r++)
{
for (c=0; c<=2; c++)
{
printf ("Ingrese el valor ");
scanf ("%d", & matrix [r] [c]);
}
c=0;
}
for (r=0; r<=2; r++)
{
for (c=0; c<=2; c++)
{
printf ("%d ", matrix [r] [c]);
}
c=r;
suma=suma+matrix[r][c];
}
if (r=c)
{
printf ("\nla suma es %d", suma);
}
getch ();
}Ingrese el valor 9
Ingrese el valor 8
Ingrese el valor 7
Ingrese el valor 6
Ingrese el valor 5
Ingrese el valor 4
Ingrese el valor 3
Ingrese el valor 2
Ingrese el valor 1
9 8 7 6 5 4 3 2 1
la suma es 15
/**********cadena funcion strlen**************/
#include <stdio.h>#include <conio.h>
#include <string.h>
void main ()
{
char cad[35]; int x=0, i=0;
printf("ingrese el nombre ");
scanf("%s", & cad);
x= strlen(cad);
for (i=0; i<x; i++)
{
printf("%c\n", cad[i]);
}
getch();
}
ingrese el nombre carlos
c
a
r
l
o
s
/*****cadena funcion strcmp*******/
#include <stdio.h>
#include <conio.h>#include <string.h>
void main ()
{
char nombre[35], apellido[35];
int i=0;
printf("ingrese su nombre ");
scanf("%s", & nombre);
printf("ingrese su apellido ");
scanf("%s", & apellido);
i= strcmp (nombre, apellido);
if (i==0)
printf("las dos cadenas %s y %s son iguales", nombre, apellido);
if (i>0)
printf("la cadena %s es mayor que %s", nombre, apellido);
if (i<0)printf ("la cadena %s es menor que %s", nombre, apellido);
getch();
}
ingrese su nombre carlos
ingrese su apellido gomez
la cadena carlos es menor que gomez
/*********funcion con cadena strcat*********/
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main ()
{
char nombre[35], apellido[35];
printf("ingrese su nombre ");scanf("%s", & nombre);
printf("ingrese su apellido ");
scanf("%s", & apellido);
strcat(nombre , apellido);
puts(nombre );
getch();
}
ingrese su nombre carlos
ingrese su apellido gomez
carlosgomez
/****2 cadenas mezcladas*****/
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main ()
{
char cad[5],nom[5]; int x=0, i=0;
printf("ingrese unnombre de 5 letras ");
scanf("%s", cad);
printf("ingrese otro nombre de 5 letras ");
scanf("%s", nom);
x=strlen(cad);
for (i=0;i<=x;i++)
{
printf("%c", cad[i]);
printf("%c", nom[i]);
}
getch();
}
ingrese un nombre de 5 letras carlo
ingrese otro nombre de 5 letras gomez
cgaormleoz
/********cadena con funcion strcpy**********/
#include <stdio.h>
#include...
Regístrate para leer el documento completo.