Está en la página 1de 4

FUNDAMENTOS DE PROGRAMACION

UNIDAD 3. Estructuras de control y arreglos


Actividad 2.Arreglos

Primer programa

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
int x,tabla[100];

for (x=1;x<=100;x++)
{
tabla[x]=x;
}

for (x=1;x<=100;x++)
{
printf("%d\n",tabla[x]);
}

system("PAUSE");
return 0;
}

Segundo programa

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])


{

int i,x=0,vector[20], n=20, dato, centro,inf=0,sup=n-1;

for (i=0;i<20;i++){
printf("Escriba un número");
scanf("%d",&vector[i]);
}

printf("Escriba el número a buscar");


scanf("%d",&dato);

while(inf<=sup)
{
centro=(sup+inf)/2;
if (vector[centro]==dato)
{

Mtra.Yadira Rodríguez Marcelo


FUNDAMENTOS DE PROGRAMACION
UNIDAD 3. Estructuras de control y arreglos
Actividad 2.Arreglos
printf("Existe\n");
x=1;
break;
}
else if(dato < vector [centro] )
{
sup=centro-1;
}
else
{
inf=centro+1;
}
}

if (x==0)
{
printf("No existe\n");
}

system("PAUSE");
return 0;

Tercer programa

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])


{

int x,y,num=0, numeros[4][4];

for (x=0;x<3;x++)
{
for (y=0;y<3;y++)
{
numeros[x][y]=num;
num++;
}
}

printf("El array original es: \n\n\n");

for(x = 0;x < 3;x++)

Mtra.Yadira Rodríguez Marcelo


FUNDAMENTOS DE PROGRAMACION
UNIDAD 3. Estructuras de control y arreglos
Actividad 2.Arreglos
{
for(y = 0;y < 3;y++)
{
printf(" %d ", numeros[x][y]);
}
printf("\n\n\n");
}

printf("La traspuesta es: \n\n\n");

for(x = 0;x < 3;x++)


{
for(y = 0;y < 3;y++)
{
printf(" %d ", numeros[y][x]);
}
printf("\n\n\n");
}

system("PAUSE");
return 0;
}

Cuarto programa

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])


{

int x,y,sum, numeros[11][10];

for (y=0;y<10;y++)
{
sum=0;
for (x=0;x<10;x++)
{
numeros[x][y]=(x*10)+1+y;
sum=sum+numeros[x][y];
}
numeros[10][y]=sum;
}

for (x=0;x<11;x++)

Mtra.Yadira Rodríguez Marcelo


FUNDAMENTOS DE PROGRAMACION
UNIDAD 3. Estructuras de control y arreglos
Actividad 2.Arreglos
{
for (y=0;y<10;y++)
{
printf("%d ",numeros[x][y]);
}
printf("\n");
}

system("PAUSE");
return 0;
}

Quinto programa

#include <stdio.h>
#include <stdlib.h>

int main()
{
char nom[20];
int x;
typedef char cadenaCaracteres [50];
cadenaCaracteres arrayCadenas[5];

for(x=0;x<5;x++){
printf("Ingrese nombre del alumno: ");
scanf("%s",arrayCadenas[x]);
}
printf("\n");
for(x=0;x<5;x++){
printf("%d | %s \n", x, arrayCadenas[x]);
}

system("PAUSE");
return 0;
}

Mtra.Yadira Rodríguez Marcelo

También podría gustarte