Hello everyone so this is the piece of code i'm wokingon..
the program ask to input an integer. If the integer is even the program will divide it by two and if the integer is odd the number will be multiplied by three and then after it is multiplied it will be added by one. if the input value is less than one , an error message will be displayed...
at the end I tried to print out how many of these operations were performed but this seems to do not want to work :(.
-several functions were added.
any help will be appreciated :). at the end I will be posting the final edit so someone else could benefit from this code ...
#include <iostream>
#include<cmath>
#include <cmath>
using namespace std;
void errorCheck(int number);
void counting(int number,int count);
void whileLoop(int number,bool finished);
void askNumber(int number);
int main()
{
int number;
int count;
bool finished;
//variables
//asking the twice
errorCheck(number);
whileLoop(number,finished);
counting(number,count);
askNumber(number);
system("pause");
return 0;
}
void errorCheck(int number)
{
int number=0;
while (!(cin >> number))
{
cout<<"input error";
cin.clear();
cin.ignore(1000,'\n');
}
}
void counting(int number,int count)
{
count=0;
number=0;
cin.get(number);
while(number !='1')
{
count++;
cin.get(number);
}
}
void whileLoop(int number,bool finished)
{
number=0;
while (number%2)!==0
{
cin>>number;
(number/2);
}
number=0;
while(number%2)!=0
{
cin>>number;
((number*3)+1);
}
if(number==1)
{
finished=true;
}
}
void askNumber(double number)
{
cout<<"input a number"<<endl;
cin>>number;
}