hi, i'm trying to solve a basic assignment, but cannot get it right. anyone has any idea why my test_input() function is not working properly?
My assignment:
Make a new projekt called my-sudoku in eclipse
Make the program print out to the screen Welcome to my sudoko input row,col,val
Get input using cin and make use of integers row,col,val
Display the values by using cout
Debug the program and run it, see what happens on the console.
In youre my-sudoku project make a function called get_input() that will take 3 integers from the user (row,col,val). The function shall be called from main
Make a function test_input(), which will test if the inputs are in the legal range of 1..9. The function should be called from get_input
Print a message to the screen whether the inputs are legal or not.
My code:
#include <iostream>
using namespace std;
void get_input();
void test_input();
int main()
{
cout<< "Welcome to my sudoku input row, col, val \n";
get_input();
return 0;
}
void get_input()
{
int row, col, val;
cout<< "Please enter number of rows: ";
cin>> row;
test_input();
cout<< "Please enter number of columns: ";
cin>> col;
test_input();
cout<< "Please enter value: ";
cin>> val;
test_input();
}
void test_input()
{
int row, col, val, number;
row=col=val=number;
if(0<number<10)
cout << "Allowed number. \n";
else
cout << "Number not allowed. Please insert a number between 1 and 9. \n";
}
Thanks for your help.
My assignment:
Make a new projekt called my-sudoku in eclipse
Make the program print out to the screen Welcome to my sudoko input row,col,val
Get input using cin and make use of integers row,col,val
Display the values by using cout
Debug the program and run it, see what happens on the console.
In youre my-sudoku project make a function called get_input() that will take 3 integers from the user (row,col,val). The function shall be called from main
Make a function test_input(), which will test if the inputs are in the legal range of 1..9. The function should be called from get_input
Print a message to the screen whether the inputs are legal or not.
My code:
#include <iostream>
using namespace std;
void get_input();
void test_input();
int main()
{
cout<< "Welcome to my sudoku input row, col, val \n";
get_input();
return 0;
}
void get_input()
{
int row, col, val;
cout<< "Please enter number of rows: ";
cin>> row;
test_input();
cout<< "Please enter number of columns: ";
cin>> col;
test_input();
cout<< "Please enter value: ";
cin>> val;
test_input();
}
void test_input()
{
int row, col, val, number;
row=col=val=number;
if(0<number<10)
cout << "Allowed number. \n";
else
cout << "Number not allowed. Please insert a number between 1 and 9. \n";
}
Thanks for your help.