I have recently started with c++ programming.
I am Reading a book about the subject and only have done this for 3 Days.
So please dont judge me. I know this problem is easy to solve.
I am writng a program which should be capable of Printing out all variabels
between the starting value and the end value. both values is selected by the
user. however, when i input a starting and an ending value, it then prints out the starting value.
here is the code:
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
cout<<"Input any StartValue."<<endl;
char check_ing;
float x;
cin>> x;
cout<<"Input any EndValue"<<endl;
float y;
cin>> y;
if (x<y)
{ cout<<x<<endl;
x=x+1;}
if (x>y)
{ cout<<x<<endl;
x=x-1;}
int main(){
int x;
int y;
cout<<"Enter a starting value: ";
cin>>x;
cout<<"Enter an end value: ";
cin>>y;
for(int c=x; c<=y;c++){
cout<<c <<endl;
}
return 0;
}
In order to solve it you need a loop I.E 'for'. If statements only output one value.