dimanche 2 décembre 2018

Write a program that asks the user to give the initial value of variable X. As long ad the variable is less than 100 it keep doubling its value

// Hi there, I'm new to programming and I'm starting off with C++;

// The program for the task must be written using a while loop only; but I am open to any other ways of writing the program; this is what I have so far, but whenever I insert x it only doubles once and keeps repeating the result without doubling.

#include <iostream>
using namespace std;

int main()
{
int x = 0, ind = 2, prod;

cout << " Hey! What's the initial value of your variable ? ";
cin >> x;

while (x < 100)
{   
    prod = x * ind;             
    cout << prod;
}

return 0;
}

— Regards

Aucun commentaire:

Enregistrer un commentaire