Documentos de Académico
Documentos de Profesional
Documentos de Cultura
50 Programas Basicos en C PDF
50 Programas Basicos en C PDF
50 PROGRAMAS
DE
ESTRUCTURAS
BASICAS
PUNO PER
2007
-2-
DEDICATORIA
HUMBERTO
FLORES
-3-
PRESENTACION
-4-
-5-
-6-
-7-
-8-
getch();
}
-9-
- 10 -
- 11 -
- 12 -
- 13 -
f(x)
X2 +1
X2 + 3x +2
X +1
, si X<=0
, si 0<X<3
, si X>=3
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{ int x, f;
cout<<"tenemos una funcin f(x), ingrese un valor para X: ";cin>>x;
if(x<=0)
{ f=x*x+1;
cout<<"la funcin es igual a: "<<f;}
else
{ if(0<x&&x<3)
{ f=x*x+3*x+2;
cout<<"la funcin es igual a: "<<f;}
else
{ if(x>=3)
{
f=x*1;
cout<<"la funcin es igual a: "<<f;}
else
{
cout<<" ";}
}
}
getch();
}
25. Lea 2 enteros a, b, y obtenga el valor numrico de la funcin:
f(x)
2a + b
a2 -2b
a+b
, a2 b2 < 0
, a2 b2 = 0
, a2 b2 > 3
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{ int a, b, f;
cout<<"tenemos una funcion f(x), ingrese valores para: "<<"\na = ";cin>>a;
cout<<"\nb = ";cin>>b;
if(a*a-b*b<0)
{
f=2*a+b; cout<<"la funcion es igual a: "<<f;}
else
{ if(a*a-b*b==0)
{ f=a*a-2*b; cout<<"la funcion es igual a: "<<f;}
else
{ if(a*a-b*b>0)
{ f=a+b; cout<<"la funcion es igual a: "<<f;}
}
}
getch();
}
- 14 -
- 15 -
- 16 -
- 17 -
- 18 -
- 19 -
- 20 -
- 21 -
- 22 -
- 23 -
- 24 -
- 25 -
- 26 -
- 27 -
- 28 -
//mostrar resultados
printf("\nEl menor de los datos ingresados es : %d", menor);
printf("\nEl mayor de los datos ingresados es : %d", mayor);
printf("\nEl promedio es : %f \n", suma/n);
getch();
}
48. Cargar un array de n enteros y calcular la media de los que estn en
posiciones pares.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
- 29 -
- 30 -
- 31 -
- 32 -