What's new
  • Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as: All that and more! Registration is quick, simple and absolutely free. Join our community today!

Help C and C++ Basic C programming problem but till now di ko masolusyunan

PHC-KILATIS12

Honorary Poster
Established
Joined
Apr 4, 2017
Messages
630
Reaction score
321
Age
24
, Last edited:
So here it is guys I'm doing this project since last last week I'm almost done but till now di ko parin masolusyunan tong problema ko taeeee hahahhaah so here's the sample of what I'm doing Screenshot_20190805-095019.png Screenshot_20190805-095024.png

So my problem is hindi ko mapalabas na ang score per questions ay true = 1 and false = 0 , ang laging score na lumalabas after 5 questions ay 300+ Sinubukan ko narin yung sinuggest saken na imbis na qc='A'; ay gawin kong if statement like this

if(qc=='A')
{
score++;
}

but still hindi parin gumana 😟 ano po kayang problema o baka ako na yung problema hahahahaha sana po matulungan nyo po ako 😊


EDITED :

#include <stdio.h>
#include <conio.h>
#include <dos.h>

int pass,level,topic,score=0,score1=0;

main()
{

clrscr();

printf(" Enter Password :");
scanf("%d",&pass);
clrscr();
if(pass==1234)
{
textcolor(2);
printf(" Entering please wait ...");
delay(2000);
}
else
{
textcolor(4);
clrscr();
printf(" Invalid password exiting ... ");
delay(1000);
clrscr();
printf("\n3...");
delay(1000);
printf("\n2...");
delay(1000);
printf("\n1...");
delay(1500);
return 0;
}
clrscr();
printf(" What is programming ? ");
delay(3000);
printf("\n\nPlease select difficulty\n1. Easy Level\n2. Hard Level\n3. Difficult Level\n\nInput Here : ");
scanf("%d",&level);
clrscr();
printf(" Easy Level Week 1 ");
delay(5000);
switch(level)
{
char qc,qv;
case 1:
printf("\n\nQuestion 1 : Expand IT. \n\nA. Information Technology\nB. Incorporated technology\nC. Information torture\n\nInput Here : ");
qc='A';
scanf("%s",&qc);
delay(2000);
clrscr();
printf("\n\nQuestion 2 : Expand CPU. \n\nA. Central processing universe\nB. Center phone user\nC. Central processing unit\n\nInput Here :");
qc='C';
scanf("%s",&qc);
delay(2000);
clrscr();
printf("\n\nQuestion 3 : Expand RAM.\n\nA. Read and memorize\nB. Random Access Memory\nC. Read and mark\n\n Input Here : ");
qc='B';
scanf("%s",&qc);
delay(2000);
clrscr();
printf("\n\nQuestion 4 : Expand ROM.\n\nA. Random only memory\nB. Read only memory\nC. Read on motherboard\n\n Input Here :");
qc='B';
scanf("%s",&qc);
delay(2000);
clrscr();
printf("\n\nQuestion 5 : Expand GPU.\n\nA. Graphics processing unit\nB. Google para umandar\nC. Gold processing unit\n\n Input Here:");
qc='A';
scanf("%s",&qc);
delay(2000);
clrscr();
score=qc;
printf("Total score :%d",score);
delay(2000);
clrscr();
if(score>=3)
{
printf(" You passed 1st week proceeding to week 2 please wait ...");
}
else
{
printf(" you failed better luck next time exiting ... ");
delay(2000);
return 0;
}
delay(2000);
clrscr();
printf(" Week 2 ");
delay(3000);
clrscr();
printf("\n\nQuestion 1 : Which one is the first search engine in internet. \n\nA. Google \nB. Archie\nC. Altavista\n\n Input Here : ");
qv='B';
scanf("%s",&qv);
delay(2000);
clrscr();
printf("\n\nQuestion 2 : Number of bit used by the IPv6 address. \n\nA. 32 bit\nB. 64 bit\nC. 128 bit\n\n Input here : ");
qv='C';
scanf("%s",&qv);
delay(2000);
clrscr();
printf("\n\nQuestion 3 : Which one is the first web browser invented in 1990. \n\nA. Nexus\nB. Internet Explorer\nC. Mozilla\n\n Input Here :");
qv='A';
scanf("%s",&qv);
delay(2000);
clrscr();
printf("\n\nQuestion 4 : Which of the following programming language is used to create program like applets ? \n\nA. COBOL\nB. C Language\nC. Java\n\n Input Here : ");
qv='C';
scanf("%s",&qv);
delay(2000);
clrscr();
printf("\n\nQuestion 5 : First computer virus is known as. \n\nA. Rabbit\nB. Creeper Virus\nC. SCA Virus\n\n Input Here : ");
qv='B';
scanf("%s",&qv);
delay(2000);
clrscr();
score1=qv;
printf(" Total score :%d",&qv);
delay(2000);
clrscr();
if(score1>=3)
{
printf(" You passed week 2 proceeding to week 3...");
}
else
{
printf(" You failed ... exiting ");
delay(2000);
clrscr();
return 0;
}

delay(2000);
clrscr();
}

getch();
}
 

dak1la

Eternal Poster
Siguro need mo gumawa ng variable na mag hohold ng tamang sagot? Siguro try ko din bukas c# kasi cl ko eh nga nga na sa c++
 

homer_simpson

Honorary Poster
, Last edited:
Few suggestions:
  • rather than in image format, can you post the relevant section of your program as text in CODE blocks here? No one will type in the entire program from an image.
  • check scoping
  • break it down into smaller chunks by using functions

When you test the input, were you testing the variable or its dereferenced value? Baka when you did the testing, out of scope na yung variable?
 

xShiro_2

Journeyman
, Last edited:
Imbis na :

qc = 'A';
scanf("%s",&qc);

palitan mo ng :

scanf("%c",&qc);
if(qc == 'A' || qc == 'a') {
score++;
}

Tapos wag mo nang lagyan ng score=qc;

Ganyan din gawin mo sa week two. Imbis na qc gawin mong qv tas ang score gawing mong score1
 

PHC-KILATIS12

Honorary Poster
Few suggestions:
  • rather than in image format, can you post the relevant section of your program as text in CODE blocks here? No one will type in the entire program from an image.
  • check scoping
  • break it down into smaller chunks by using functions

When you test the input, were you testing the variable or its dereferenced value? Baka when you did the testing, out of scope na yung variable?
Updated na po sir pasensya na po sa abala
 

PHC-KILATIS12

Honorary Poster
Imbis na :

qc = 'A';
scanf("%s",&qc);

palitan mo ng :

scanf("%c",&qc);
if(qc == 'A' || qc == 'a') {
score++;
}

Tapos wag mo nang lagyan ng score=qc;

Ganyan din gawin mo sa week two. Imbis na qc gawin mong qv tas ang score gawing mong score1
I've already tested that sir pero wala parin ayaw talaga
 

homer_simpson

Honorary Poster
, Last edited:
Sakit sa mata nito. Dapat i-format mo nang maayos. Mainam na maging habit mo yun, for your sanity's sake.

Anyway, you have a switch-block, pero as far as I can see meron ka lang isang case conditional.

Tapos, kung ako sa iyo, alisin mo muna yung mga delay, clrscrn functions. Pasimplehen mo muna while you are still working out.

Finally, mas mainan na i-declare mo properly yung main block, ie

Code:
int main(int argc, char* argv[])
kesa sa
Code:
main()
lang basta.

Best practices lang, para sa atin din iyan.
 

PHC-KILATIS12

Honorary Poster
Sakit sa mata nito. Dapat i-format mo nang maayos. Mainam na maging habit mo yun, for your sanity's sake.

Anyway, you have a switch-block, pero as far as I can see meron ka lang isang case conditional.

Tapos, kung ako sa iyo, alisin mo muna yung mga delay, clrscrn functions. Pasimplehen mo muna while you are still working out.

Finally, mas mainan na i-declare mo properly yung main block, ie

Code:
int main(int argc, char* argv[])
kesa sa
Code:
main()
lang basta.

Best practices lang, para sa atin din iyan.
Thank you po sa payo master freshman IT palang po kase ako ehh kaya yan pa lang po yung mga alam ko kaya malaking tulong sakin yung mga simple tips para maayos ko yung pagcocoding ko , pero master pasagot po ng tanong ko wala naman akong ibang problem sa program ko ang hindi ko lang magawa is yung kapag tama yung sagot sa isang question ay magiging equals to 1 tapos pag mali equals to 0 yun lang po talaga 😊
 

homer_simpson

Honorary Poster
Teka hindi ako master. Katulad mo, nag-aaral pa din ako ng C at C++.

Una muna, ano ba gusto mo ma-achieve? Ano ba goal ng program mo? Medyo kasi magulo. Tapos as per my previous reply, kulang yung switch-block mo. Yung switch can be used as an alternative to if-else conditionals. And in some cases it is more preferred.
 

Funyarinpa

Forum Veteran
ano kinalabasan ts nung modified code mo?
tsaka yung sa may passing condition mo sa week 1... yung sa if block hindi nasama yung contents ng week 2 exam...
so kahit magfail yung kukuha nun... magproproceed pa rin sya sa week 2 exam...
 

PHC-KILATIS12

Honorary Poster
ano kinalabasan ts nung modified code mo?
tsaka yung sa may passing condition mo sa week 1... yung sa if block hindi nasama yung contents ng week 2 exam...
so kahit magfail yung kukuha nun... magproproceed pa rin sya sa week 2 exam...
No it will not proceed sir , it will automatically shut down kase pag nagfail may code na return 0; kaya mag o auto shut down yung program
 

Trending Topics

Trending On This Forum

Unanswered Topics

Top