I try to make program the user selects the first number and last number
so show the evens numbers between the first number and the last number that user is selects
the code:
i use while loop to make the program and i sorry
thats the code:
# include <iostream>
using namespace std ;
int main ()
{
double fri=0 , num=1 , last=0 ;
cout<<"Enter the frist number"<<endl ;
cin>> fri ;
cout<<"Enter the last number"<<endl ;
cin>> last ;
while ((fri>num) && (last <num) ){
cout<< num ;
num +2;
This would work fine except for two things. If the variable fri's value was an odd number it would print out all of the odd numbers between fri and last, or if fri's value was a decimal it would print out numbers with decimals. The other problem is that you have no exception handling. If the user entered a letter instead of a number for some reason, the program would crash.
Two less important things are that you don't need those parenthesis around fri>num or last<num, and first is spelled F-I-R-S-T. I'm assuming you're not a native speaker, but I might as well tell you, I guess.