C++ code problem!

cppnewbie Messages postés 2 Date d'inscription samedi 10 décembre 2005 Statut Membre Dernière intervention 12 décembre 2005 - 10 déc. 2005 à 22:17
Darkneon Messages postés 56 Date d'inscription vendredi 18 mai 2001 Statut Membre Dernière intervention 13 décembre 2005 - 13 déc. 2005 à 07:05
run the program please and let me know whats wrong wit it .. I'm receiving some crazy numbers at the end of the program. and on each line it should take only one letter .. but on mine it can take more and then it craches my code. and u can hit enter without putting a letter in .. that shouldn't be happening. so these are my problems. here is the code:

/* Alex Talbi


Problem statement: Make a program that asks the user to input a student's
answers for a DMV test. The program is to compares these
answers with a set of stored correct answers. If the
student recieved a 75% or better on the test, then the
program will return a message saying that the student
has passed the test.
Approach: I will start by making three different arrays for each category.
I will place the answer key in the first array and continue with
the second array for the input of answers and the result of
the inputed answers in the last array.
Input: Twenty numbers are inputed.


Process: Compare inputed answers with the correct answers. come up with a
percentage of correct answers.


Output: The percentage of the correct answers that the student earned.
Even if the student did not pass the test.*/


#include
#include
using namespace std;


int main()
{
const int array2=21, array1=20, Avg=15,
const1=0, const2=1, const3=7, const4=5;

int correct_answers = 0
char ansInp[array1],
ansRight[array2] = "BDAACABACDBCDADCCBDA";
int numBOOL[array1],
Wrong=0,
Right;

bool answrBOOL[array1];


cout <<"This program will grade your driver's license exam." <<endl;
cout <<"Enter your answers using either A, B, C, or D." <<endl;

for (int index=const1, loop=const1; index>ansInp[index];
while (ansInp[index]!='A' && ansInp[index]!='B' &&
ansInp[index]!='C' && ansInp[index]!='D' )
{
cout <<"Invalid entry. Enter A, B, C, or D."<<endl;
cin >>ansInp[index];
}
}


for (int indexICHI=const1, num=const2; indexICHI=Avg)
{
cout <<"======================================"<<endl
<<"answers will be displayed as 0"<<endl
<<"======================================"<<endl;
for (int indexSAN=const1; indexSAN<array1; indexSAN++)
{
cout <<setw(const4) <<ansInp[indexSAN]
<<setw(const3) <<" : "
<<setw(const3) <<numBOOL[indexSAN]
<<setw(const3) <<" : "
<<setw(const3) <<ansRight[indexSAN] <<endl;
}
cout <<"Total wrong: " <<Wrong <<endl;
cout <<"Total right: " <<Right <<endl;
cout <<"...PASSED..." <<endl;


}


return 0;
}

Alex

9 réponses

cs_coq Messages postés 6349 Date d'inscription samedi 1 juin 2002 Statut Membre Dernière intervention 2 août 2014 101
10 déc. 2005 à 22:22
Hello,

Csharpfr is a french speaking website dedicated to the C# programming langage, not C++.

/*
coq
MVP Visual C#
*/
0
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
11 déc. 2005 à 03:43
Hello
0
MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 57
11 déc. 2005 à 13:50
Normalement, les français aux notions d'anglais ont tendance a ajouter un 'u' au mot langage.
Coq c'est l'inverse, il reste bien français ^^

Mx
0
cs_coq Messages postés 6349 Date d'inscription samedi 1 juin 2002 Statut Membre Dernière intervention 2 août 2014 101
11 déc. 2005 à 13:56
/*
coq
MVP Visual C#
*/
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_badrbadr Messages postés 475 Date d'inscription jeudi 19 juin 2003 Statut Membre Dernière intervention 3 novembre 2008 1
12 déc. 2005 à 03:50
Je pense qu'on a trouvé notre représentant à l'étranger

@++
0
MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 57
12 déc. 2005 à 08:19
Oui
On mettra un beret sur son avatar quand noel sera fini, et ce sera parfait.

Mx
0
cppnewbie Messages postés 2 Date d'inscription samedi 10 décembre 2005 Statut Membre Dernière intervention 12 décembre 2005
12 déc. 2005 à 11:10
en fait j'parle francais ossi .. j'voulais juste un pe d'aide ac mon code .. dezole .. chave po k'c't po pr C++ ici.

Alex
0
cs_coq Messages postés 6349 Date d'inscription samedi 1 juin 2002 Statut Membre Dernière intervention 2 août 2014 101
12 déc. 2005 à 12:10
Lol

Pour le C/C++ tu peux aller demander sur les forums du site CodeS-SourceS dédié : CPPFrance.Com (même compte)
:-)

/*
coq
MVP Visual C#
*/
0
Darkneon Messages postés 56 Date d'inscription vendredi 18 mai 2001 Statut Membre Dernière intervention 13 décembre 2005
13 déc. 2005 à 07:05
WOW!



J'ai juste une chose a dire, bravo pour le professionalisme les gars.
0
Rejoignez-nous