What's new

Closed Need help optimizing your program code? pasok!

Status
Not open for further replies.
Yan ba instruction sa inyo? Through function ang pagtawag ng question?
Simple array maaachieve mo yung gusto mo maachieve.
Kasi sa case na yan, malaki ang possibility na maulit ng maulit yung question.
pano mawala yung 3 sir? haha
 

Attachments

Hindi makita yung code kaya hindi ko malalaman kung paano maaalis yan.
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;



void q1e(){
cout << "What is the shape of the moon?" << endl;
cout << "A. Circle B. Square C. Oval D. Triangle " << endl;
}


int main()
{
start:
{
int total_number = 15;
int first_number = 1;
srand(time(0));
int RandomNum = rand() % total_number + 1;


for (int a = 0; a < 1; a++)
{
RandomNum = rand() % total_number + 1;
cout << RandomNum << endl;

switch (RandomNum)
{
case 3:
{
q1e();
break;
}
}
}

}
system("pause");
goto start;
}

pano sir maiwasan na magulit yung number?
 
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;



void q1e(){
cout << "What is the shape of the moon?" << endl;
cout << "A. Circle B. Square C. Oval D. trïânglê " << endl;
}


int main()
{
start:
{
int total_number = 15;
int first_number = 1;
srand(time(0));
int RandomNum = rand() % total_number + 1;


for (int a = 0; a < 1; a++)
{
RandomNum = rand() % total_number + 1;
cout << RandomNum << endl;

switch (RandomNum)
{
case 3:
{
q1e();
break;
}
}
}

}
system("pause");
goto start;
}

pano sir maiwasan na magulit yung number?
Naka cout yung randomNumber mo that's why.
Sa approach mo mag-uulit talaga yan.
 
Ano pala last topic niyo?
Vector? Array? Queue?
bale sir freshmen palng po ako. yung last topic po namin ay if else. then ngayon po nagbigay po siya nang problem. kahit di padaw namin na topic pwedi daw namin gamitin.


yan po sana yung code perodo di po ako marunong mag apply sa c++.
 

Attachments

bale sir freshmen palng po ako. yung last topic po namin ay if else. then ngayon po nagbigay po siya nang problem. kahit di padaw namin na topic pwedi daw namin gamitin.


yan po sana yung code perodo di po ako marunong mag apply sa c++.
Then ang machine problem niyo? Random Multiple Choice Questionare?
 
mag assign po ako nang questions na 15
then ang progrma po yung amg chochoose nang 5 question.
Aba. Ikaw yung dati. Hahaha!

Tulungan kita paunti unti.
Binigay ko sayo yung array. Hindi mo ata binasa.
Simula tayo sa easy questions. Gawin mo na!
Declare ka ng array variable ng easy question.
Pero wag kang mahiya kung hindi mo alam. sabihin mo.
 
Aba. Ikaw yung dati. Hahaha!

Tulungan kita paunti unti.
Binigay ko sayo yung array. Hindi mo ata binasa.
Simula tayo sa easy questions. Gawin mo na!
Declare ka ng array variable ng easy question.
Pero wag kang mahiya kung hindi mo alam. sabihin mo.
oo sir di ko alam yung array. di pa namin na takle yan sir. sorry to say :(
 
oo sir di ko alam yung array. di pa namin na takle yan sir. sorry to say :(
Ito basic ng array:
Ilagay mo sa IDE mo. Tapos iapply mo sa easy question. Pakita mo sa akin.
I-run mo tapos. Tapos palitan mo yung names ng easyQuestion tapos lagay ka lang ng example "Easy Question1?" examples lang. Saka ka na mag-isip ng questions.

Code:
#include <iostream>

using namespace std;

int main()
{
    string names[3] = {"Hazan1", "Hazan2", "Hazan3"};
   
    cout<< names[0] << endl;
    cout<< names[1] << endl;
    cout<< names[2] << endl;

    return 0;
}
 
Ito basic ng array:
Ilagay mo sa IDE mo. Tapos iapply mo sa easy question. Pakita mo sa akin.
I-run mo tapos. Tapos palitan mo yung names ng easyQuestion tapos lagay ka lang ng example "Easy Question1?" examples lang. Saka ka na mag-isip ng questions.

Code:
#include <iostream>

using namespace std;

int main()
{
    string names[3] = {"Hazan1", "Hazan2", "Hazan3"};
  
    cout<< names[0] << endl;
    cout<< names[1] << endl;
    cout<< names[2] << endl;

    return 0;
}
di sir e. Last question nlng sir. pano sir mag elimnate ng question sir?
 
di sir e. Last question nlng sir. pano sir mag elimnate ng question sir?
You're not willing to learn. Yung binibigay ko sayo papunta dun sa gusto mo. Pero gusto mo laktawan. Which hindi maganda.
Kasi kahit ibigay ko sayo yung sagot hindi mo maiitindihan.
Kung sa approach mo.
Kailangan mo i-keep yung values ng randomNumber. Tapos after another question, generate ng randomNumber, tapos compare mo sa values na nakeep ko kapag nandun, generate ulithanggang maging unique. Hanggang sa 5.
Kapag unique na show the question.
Pero hindi mo rin naman maiintidhan.
Kasi ilalagay mo sa array yung nakuha nang questions. A R R A Y. Pero ayaw mo i-grasp.
 
Yan ba instruction sa inyo? Through function ang pagtawag ng question?
Simple array maaachieve mo yung gusto mo maachieve.
Kasi sa case na yan, malaki ang possibility na maulit ng maulit yung question.
Sir bale ano gagamitin dyan array gusto ko kasi itry sa java.
 
Status
Not open for further replies.
Back
Top