lunes, 20 de octubre de 2014

PUNTO # 4 TALLER 2 
SOLUCIÓN CON DOS TIPOS DE FUNCIONES

1. IF

#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
int num;
cout<<"digite un numero"<<endl;
cin>>num;
if (num <0)
cout<<"el numero es negativo"<<endl;
if (num>0)
cout<<"el numero es positivo"<<endl;
return 0;
}

2.SWITCH

#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
int num,opc;
cout<<"seleccione una opcion 1 o 2"<<endl;
cin>>opc;
cout<<"digite un numero"<<endl;
cin>>num;
  switch(opc){
{
case 1:
cout<<"el numero es negativo"<<endl;
break;
case 2:
cout<<"el numero es positivo"<<endl;
}
}
return 0;
}
 

No hay comentarios.:

Publicar un comentario