How can i make this code loop

I have this code but i cant seem to figure out where and what to put exactly in it to make it loop sorry but i am a beginner and i would be grateful if you guys could tell me and explain please.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
double Sumar(double,double);
double Restar(double,double);
double Multiplicar(double,double);
double Dividir(double,double);

int main()
{

    cout << "Calculadora" << endl;

    double val1;
    cout << "Introduce el primer valor: ";

     cin >> val1;
    double val2;
    cout << "Introduce el segundo valor: ";

    cin >> val2;

    int operador;
    cout << "Le gustaria Sumar (1), Restar (2), Multiplicar (3), Dividir (4) o Salir (5)?: ";
    cin >> operador;

    switch(operador)
    {
        case 1:
            cout << "\n";
            cout << Sumar(val1,val2) << endl;
            cout << "\n";
        break;
        case 2:
            cout << "\n";
            cout << Restar(val1,val2) << endl;
            cout << "\n";
        break;
        case 3:
            cout << "\n";
            cout << Multiplicar(val1,val2) << endl;
            cout << "\n";
        break;
        case 4:
            cout << "\n";
            cout << Dividir(val1,val2) << endl;
            cout << "\n";
        break;
    }
    return 0;
}


double Sumar(double x,double y)
{
    return x + y;
}


double Restar(double x,double y)
{
    return x - y;
}


double Multiplicar(double x,double y)
{
    return x * y;
}


double Dividir(double x,double y)
{
    return x / y;
}
Hola @LOL123;

Esta puede ser una
idea, utilizando una
variable booleana;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//Loop.cpp
//##


#include <iostream>

using namespace std;

bool isEven(int num);


int main(){

bool CONTINUE=true;

        while(CONTINUE){
                cout<<"Introduce un numero (-1 salir): ";
                int number;
                cin>>number;
                if(number!=-1)
                cout<<"Tu numero "<<(isEven(number)?"es par.":"no es par")<<endl;
                else 
                CONTINUE=false;
        }//end while

        cout<<"\nBYE!"<<endl;

}//@end of main


bool isEven(int num){
        if(num%2==0)return true;


return false;
}//end function isEven




---
./Loop 
Introduce un numero (-1 salir): 1
Tu numero no es par
Introduce un numero (-1 salir): 2
Tu numero es par.
Introduce un numero (-1 salir): -1

BYE!
Gracias enrique me ha ayudado mucho te lo agradezco! :)
De nada!
Topic archived. No new replies allowed.