PROGRAMA CON CICLOS
Programa que permite validar la clave y luego realizar depòsito o retiros
#include<stdio.h>
void main(){
int clave1=123;
int clave2=0;
int c =0;
int band = 0;
float saldo =0;
float depos=0;
float retiro=0;
int opcion=0;
char volver='n';
do{
printf("\n Ingrese su clave: ");
scanf("%d",&clave2);
if(clave2== clave1){
band = 1;
}
else
c = c +1;
} while(c<3&&band!=1);
if(band==0)
printf("\n SU CUENTA HA SIDO BLOQUEADA..!");
else
{
printf("\n BIENVENIDO..!");
do{
printf("\n MENU");
printf("\n 1 DEPOSITO");
printf("\n 2 RETIRO");
printf("\n INGRESE OPCION:__ ");
scanf("%d",&opcion);
if (opcion==1){
printf("\n INGRESE VALOR A DEPOSITAR: ");
scanf("%f",&depos);
saldo=saldo+depos;
printf("\n SU SALDO ES: %7.2f",saldo);
} if(opcion==2) {
printf("\n INGRESE VALOR A RETIRAR: ");
scanf("%f",&retiro);
if(retiro<saldo)
saldo=saldo-retiro;
else
printf("\n SALDO INSUFICIENTE");
printf("\n SU SALDO ES: %7.2f",saldo);
}
printf("\n DESEA VOLVER AL MENU S/N:__ ");
fflush(stdin);
scanf("%c",&volver);
}while(volver!='n');
}
}
#include<stdio.h>
void main(){
int clave1=123;
int clave2=0;
int c =0;
int band = 0;
float saldo =0;
float depos=0;
float retiro=0;
int opcion=0;
char volver='n';
do{
printf("\n Ingrese su clave: ");
scanf("%d",&clave2);
if(clave2== clave1){
band = 1;
}
else
c = c +1;
} while(c<3&&band!=1);
if(band==0)
printf("\n SU CUENTA HA SIDO BLOQUEADA..!");
else
{
printf("\n BIENVENIDO..!");
do{
printf("\n MENU");
printf("\n 1 DEPOSITO");
printf("\n 2 RETIRO");
printf("\n INGRESE OPCION:__ ");
scanf("%d",&opcion);
if (opcion==1){
printf("\n INGRESE VALOR A DEPOSITAR: ");
scanf("%f",&depos);
saldo=saldo+depos;
printf("\n SU SALDO ES: %7.2f",saldo);
} if(opcion==2) {
printf("\n INGRESE VALOR A RETIRAR: ");
scanf("%f",&retiro);
if(retiro<saldo)
saldo=saldo-retiro;
else
printf("\n SALDO INSUFICIENTE");
printf("\n SU SALDO ES: %7.2f",saldo);
}
printf("\n DESEA VOLVER AL MENU S/N:__ ");
fflush(stdin);
scanf("%c",&volver);
}while(volver!='n');
}
}
Comentarios
Publicar un comentario