Calling function in C++ -
i'm trying call function no return type doesn't seem getting called.
the code looks this(summarized):
#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int itemsinquestion[4]; void getquestions(int numquests); int main() { int numberofquestions = 0; srand((unsigned)time(null)); cout << "how many questions like?" << endl; cin >> numberofquestions; cout << numberofquestions << " questions asked."; getquestions(numberofquestions); system ("pause"); return 0; } void getquestions(int numquests) { for(int questions=numquests; questions>numquests; questions++) { itemsinquestion[0]=(rand()%(263))+1; itemsinquestion[1]=(rand()%(263))+1; itemsinquestion[2]=(rand()%(263))+1; itemsinquestion[3]=(rand()%(263))+1; cout << itemsinquestion[0] << ' ' << itemsinquestion[1] << ' ' <<itemsinquestion[2] << ' ' << itemsinquestion[3]; } } the line outputs values in array never comes up. causing this?
because
int questions=numquests; and
questions>numquests; don't each other.
you set questions numquests , tell loop keep going long questions strictly greater numquests, isn't start off with.
even if was, you'd run overflow , undefined behavior.
Comments
Post a Comment