473,566 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C++ : Help prog does not fully work

3 New Member
Hey guys,
I have some work for university and i never used C++ in my life so i'm kinda lost..
But i've still managed to write something woth it.
But too bad for me the prog does compile and lunch propely, but once i enter "-1" for the second while, nothing more is happening..

This is the code
http://rafb.net/paste/results/rHKKIF94.html
Could you guys tell me whats wrong because it looks okay for me :(


Ps: I'm from Belgium so i wrote the prog in french (sorry sorry).
If u need help tell me ;)
Ps2: THIS IS NOOB STUFF :x

THX !
Oct 26 '06 #1
4 1387
Banfa
9,065 Recognized Expert Moderator Expert
The problems I see are in this code chunk
Expand|Select|Wrap|Line Numbers
  1.                 while (cdt=false){
  2.                       if (-1<cote>20){ // S'assure que la cote est bien sur 20
  3.                          cdt=false;
  4.                          cout << "Erreur, veuillez entrer une cote sur 20" << "Veuillez recommencer" << endl; 
  5.                       }   
  6.                       if (ponderation==0){ // La pondération devant obligatoirement être supérieure à 1
  7.                          cdt=false;
  8.                          cout << "Erreur, la pondération ne peut être nulle." << "Veuillez recommencer" << endl;
  9.                       }
  10.                       else
  11.                           cdt=true;
  12.                 } 
  13.  
if (-1<cote>20)

The condition of this if statement awlays evaluates to FALSE did you mean

if (-1<cote && cote<20)


In this code chunk once ponderation has a value of 0 the while loop

while (cdt=false)

will go into an infinite loop.
Oct 26 '06 #2
Signeg
3 New Member
Yep i've noted this error an hour ago :$
Thank you !

I'm trying to fix it, but not sure it will work :(
Oct 26 '06 #3
Signeg
3 New Member
Could you tell me if this is correct ?

Expand|Select|Wrap|Line Numbers
  1. while (!verf){
  2.                       if (-1>cote || cote>20){ // S'assure que la cote est bien sur 20
  3.                          verf=false;
  4.                          cout << "Erreur, veuillez entrer une cote sur 20 " << "Veuillez recommencer" << endl; 
  5.                       }   
  6.                       if (ponderation<1){ // La pondération devant obligatoirement être supérieure à 0
  7.                          verf=false;
  8.                          cout << "Erreur, la pondération ne peut être inférieure à 1." << "Veuillez recommencer" << endl;
  9.                       }
  10.                       else
  11.                           verf=true;
  12.                 } 
  13.                 total=total+(cote*ponderation);
  14.                 pondtotale=pondtotale+ponderation;
  15.                 cout << "Veuillez introduire la cote obtenu pour ce cours" << endl;
  16.                 cout << "Introduisez -1 pour obtenir votre moyenne" << endl;
  17.                 cin >> cote; 
  18.                 verf=false;

Because the first two have the same importance..
It's

- Check Cote
- Check pond
- IF OK proceed

How do i do that ?
Oct 26 '06 #4
Banfa
9,065 Recognized Expert Moderator Expert
This will still go into an infiniteloop if either of the 2 conditions fail because the loop does not encompass any code that changes the variables that are tested. If the values are bad you probably want to give the user a chance to re-enter them.

for 2 coditions the pseudo code looks some like

Expand|Select|Wrap|Line Numbers
  1. IF CONDITION 1 OK AND CONDITION 2 OK
  2.     PERFORM SUCCESS OPERATION
  3. ELSE
  4.     PERFORM FAILED OPERATION
  5.  
  6.     IF CONDITION 1 NOT OK
  7.         PRINT CONDITION 1 ERROR MESSAGE
  8.     ENDIF
  9.     IF CONDITION 2 NOT OK
  10.         PRINT CONDITION 2 ERROR MESSAGE
  11.     ENDIF
  12. ENDIF
  13.  
Oct 26 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2236
by: gong | last post by:
hi i recently looked at alexandrescu's book on c++, and i found it pretty much unintelligible. i have a few points which i wonder about. 1. as a developer, it is important, from a bottom line standpoint, to make code as transparent as possible. through its lifecycle, code inevitably becomes larger and more complex to cope with unexpected...
2
1272
by: nooneinparticular | last post by:
I sat down last night and decided to try and teach myself something about programming in C++. I have always had an interest in it, so I went for it. This is what I have to show for my efforts. What I came up with is simply nothing more than a text encrypter/decrytper of kindergarden proportions ;) My problem is this - anytime the prog...
4
1442
by: Theron NightStar | last post by:
I am trying to teach myself c++. This is the first program I have ever written that might have an practical use to me. I rather proud of it since like implied - I have no real knowledge of c++. Anyways, here is my problem - This prog does what it is supposed to (a very very crude encryption/decryption of text files) but for some reason it...
14
1546
by: Matt Suther | last post by:
I just bought The C Programming Language, by the guy who made C and so...I have 2 different compilers, free ones, and I don't know if I typed the code in wrong or if it's a problem with my compilers, do any of you know? They were free compilers: Icc-win32 and Bloodshed Dev C++(uses C too). Are there and compilers that are free besides mars,...
2
1677
by: Matt Suther | last post by:
Does it matter if I use "The C Programming Language" with Windows XP? I've gotten some of the scripts from it to work, but some don't. Could this be an issue with Windows? Or an issue with the compiler? And I've already made sure I didn't mistake parts of the coding. So does anyone know? Thanks.
2
1848
by: facicad | last post by:
I would like to set topmost another prog. from my program. Ex: I use AutoCAD, run my prog. from autocad. My prog. is topmost but went I would like to pick some object in autocad, I set TopMost to false and I would like to autocad bring to front, but for autocad object, it not have TopMost properties
5
3872
by: =?Utf-8?B?SmltIFJvZGdlcnM=?= | last post by:
My question is simple: How does one debug ASP Classic with Microsoft Visual Web Developer Express 2005 ("VWD")? Looming in the back of anyone's mind when you see a posting like this on any newsgroup is "didn't this guy read the docs?" Frankly, I "sort of did" a number of times. I feel the days of "things that are intuitively obvious" to...
0
344
by: jerstlouis | last post by:
I'm hoping to generate some interest in the Ecere SDK which is the result of many years of software development. With the Ecere SDK, you can: Build Cross Platform GUI Applications: Develop applications once, deploy them on all platforms alongside a lightweight runtime environment.
8
9492
by: tvnaidu | last post by:
I am running prog with GDB - throws SIG32, why? @localhost config]# gdb prog GNU gdb Red Hat Linux (5.3.90-0.20030710.40rh) Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show...
0
7666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8108
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7644
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.