TACNA
“SENTENCIAS CONDICIONALES”
TACNA – PERÚ
2019
I.OBJETICO
SENTENCIAS CONDICIONALES.
Las sentencias de control gobiernan el flujo de la ejecución del programa y hace que la
computadora deje de comportarse como una simple calculadora de bolsillo que sólo
realiza operaciones aritméticas
if (x<=y || y>z) p = x + y;
else q = z - y;
III. DESARROLLO
PSEINT
INICIO
Leer A,B,C
PF <- (A+B+C)/3
Si 70>=PF Entonces
Escribir 'aprobado'
SiNo
Escribir 'reprobado'
FinSi
FinAlgoritmo
DIAGRAMA DE FLUJO
C++
PRUEBA DE ESCRITORIO
entrada salida
A B C PF ESCRIBIR
80 70 90 80 aprobado
20 30 90 46.6666667 desaprobado
2. Un trabajador desea saber su sueldo si al ganar menos que 1900 soles recibirá
una bonificación del 10%
PSEINT
Algoritmo ejercicio_9
Leer S
Si(S<1900) entonces
NS=S+S*0.1
Sino
FinSi
FinAlgoritmo
DIAGRAMA DE FLUJO
C++
PRUEBA DE ESCRITORIO
PSEINT
Proceso sin_titulo
Leer NUM
Si NUM>=19 Entonces
NUM=A
Sino
Si NUM>=15 Entonces
NUM=B
Si NUM>=13 Entonces
NUM=C
Sino
Si NUM>=10 Entonces
NUM=D
Sino
FinSi
FinSi
FinSi
FinSi
FinProceso
DIAGRAMA DE FLUJO
C++
#include<conio.h>
#include<iostream>
int main()
int E;
cin>>E;
if (E=19 || E<=10){
}
getch();
PRUEBA DE ESCRITORIO
4. Realice un algoritmo para determinar si una persona puede votar con base
en su edad en las próximas elecciones.
PSEINT
Algoritmo votar
Leer edad;
si edad<18 entonces;
SiNo
FinSi
FinAlgoritmo
DIAGRAMA DE FLUJO
C++
#include<conio.h>
#include<iostream>
int main()
int E;
cin>>E;
if(E<18){
else{
getch();
PRUEBA DE ESCRITORIO
PSEINT
Proceso horas_de_trabajo
Leer horasT
Escribir "digite el pago que recibe por las horas trabajadas"
Leer pagoHT
Si horasT<40 Entonces
sueldoS=horasT*pagoHT
Escribir "el sueldo semanal del trabajador es: " sueldoS " dolares"
FinSi
Si horasT>40 Entonces
SueldoS=(pagoHT*2)
Escribir "el sueldo semanal del trabajador es: " sueldoS " dolares"
Fin Si
FinProceso
DIAGRAMA DE FLUJO
C++
#include<conio.h>
#include<iostream>
int main()
int HT,PH,HE,SC;
float SS;
cin>>HT;
cin>>PH;
if(HT>40){
HE=HT-40;
SC=(HE*2*PH)+(40*PH);
else{
SS=HT*PH;
getch();
}
PRUEBA DE ESCRITORIO
PSEINT
INICIO
Leer NK
Si (NK>60) entonces
M=NK+(2.5*(NK-60))
Escribir M
SINO
Escribir “felicitaciones”
FIN SI
FIN
DIAGRAMA DE FLUJO
C++
#include<conio.h>
#include<iostream>
using namespace std;
int main(){
int NK,M;
cin>>NK;
if(NK>60){
M=NK+(2.5*(NK-60));
cout<<M;
}
else{
cout<<"felicitaciones";
}
getch();
}
PSEINT
Algoritmo sin_titulo
P=(N1+N2+N3) /3
Si (P>14) entonces
FinSi
Si (P<14 y P=11) entonces
Sino
Si(P<11) entonces
A=P+0.25*P
Escribir A
FINSI
FINSI
FinAlgoritmo
DIAGRAMA DE FLUJO
C++
#include<conio.h>
#include<iostream>
using namespace std;
int main()
{
char N1,N2,N3,P,A;
cin>>N1>>N2>>N3;
P=(N1+N2+N3)/3;
if(P>14){
cout<<"Alumno Excelente";
}
else{
if(P<14 / P>11){
cout<<"Alumno Regular";
}
else{
if(P<11){
P=P+0.25*P;
cout<<"A";
}
}
}
getch();
}
8. Una frutería ofrece las manzanas con descuento según la siguiente tabla: No. de
manzanas compradas % descuento 0 – 2 0% 3 – 5 10% 6 – 10 15% 11 en adelante 20%
Determinar cuánto pagará una persona que compre manzanas en esa frutería..
PSEINT
DIAGRAMA DE FLUJO
C++
#include<conio.h>
#include<iostream>
using namespace std;
int main()
{
float M,CK,T;
cin>>M>>CK;
if(M>0 and M<=2){
T=M*CK;
cout<<"total de descuento 0 "<<T;
}
else{
if(M>3 and M<=5){
T=M*CK-M*CK*0.10;
cout<<"total de descuento 0.10"<<T;
}
else{
if(M>6 and M<=10){
T=M*CK-M*CK*0.15;
cout<<"total de descuento 0.15"<<T;
}
else{
T=M*CK-M*CK*0.20;
cout<<"total de descuento 0.20"<<T;
}
}
}
getch();
}
9. Un proveedor de computadores ofrece descuento del 10%, si cuesta $1.000.000 o
más. Además, independientemente, ofrece el 5% de descuento si la marca es
ABACO. Determinar cuánto pagará, con lVA incluido, un cliente cualquiera por la
compra de una computadora.
DIAGRAMA DE FLUJO
C++
#include<conio.h>
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
int carpetas;
float total;
cin>>carpetas;
if(carpetas<5){
cout<<"su descuento es el 10% ";
total=carpetas*800-(carpetas*800*0.1);
cout<<total;
}else{
if(carpetas<10){
cout<<"su descuento es el 20% ";
total=carpetas*800-(carpetas*800*0.2);
cout<<total;
}else{
cout<<"su descuento es el 40% ";
total=carpetas*800-(carpetas*800*0.4);
cout<<total;
}
}
getch();
Entrada Salida
7 “su descuento es el 20%”,4480
PSEINT
INICIO
Leer discos
LEER a,b,c,d;
SI(b<a && c<a && d<a)
ESCRIBIR a;
SINO
SI(a<b && c<b && d<b)
ESCRIBIR b;
SINO
SI(a<c && b<c && d<c)
ESCRIBIR c;
SINO
SI(a<d && b<d && c<d)
ESCRIBIR d;
FINSI
FINSI
FINSI
FINSI
FIN
DIAGRAMA DE FLUJO
C++
#include<conio.h>
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d;
cin>>a>>b>>c>>d;
if (a>b and a>c and a>d){
cout<<a;
}
else {
if (b>a and b>c and b>d){
cout<<b;
}
else {
if (c>a and c>b and c>d){
cout<<c;
}
else{
if (d>a and d>b and d>c){
cout<<d;
}
}
}
}
getch();
}
PRUEBA DE ESCRITORIO
Entrada Salida
a|b|c|d Resultado
1|2|3|4 4
IV. CONCLUSIONES
V. BIBLIOGRAFÍA
LOGICA-DE-PROGRAMACION-EFRAIN-OVIEDOARCHIVO EJERCICIOS
http://aula.upt.edu.pe/pluginfile.php/36610/mod_resource/content/0/Introduccion%20al
%20dev%20c%2B%2B.pdf.
https://juanobligado.wordpress.com/2007/11/05/interfaces-con-c/
https://www.programarya.com/Cursos/C++/Ciclos/Ciclo-for
http://caromeroshlp.blogspot.com/2011/02/sentencias-selectivas.html