473,324 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

just a question to see if legal or not in c++

4
i already have my whole program working how im suppose to, however, theres this part im trying to determine if its true or false with an if statement and that if its false to go on and do the rest of the program.

this is the beginning of the program, i want to know if its legal to put a while loop after an if and else statement , because the compiler gives me an error.

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
int id, Students;
double rright, wrong, Tanswered, Omitted, Grade, Total, Percent;
cout << "Enter ID with right and wrong answers followed by spaces and press enter: " << endl;
cin >> id >> rright >> wrong; //read id with right and wrong answers

if (rright >= 51) { //determines if theres more than 50 questions answered and to print error
cout << endl << "This is an error, you cant have more than 50 questions right, please try again" << endl << endl;
else
cin >> id >> rright >> wrong;

while (id != -1)
{
Tanswered = rright + wrong;


as i said this is the beginning of the program, where you see the else, i want to know if its possible to put it there
Feb 25 '08 #1
1 1123
weaknessforcats
9,208 Expert Mod 8TB
There's no restriction on where you can put a loop. Provided, of course, that you have your braces correctly coded.
Feb 25 '08 #2

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

Similar topics

8
by: madcap | last post by:
Hi, Our company was looking for contract programmer to develop an internet/intranet application. We were approached by a freelancer who have quite a lot experience and his resume was...
14
by: Frank Rizzo | last post by:
I realize that this maybe the wrong forum, but maybe someone has run into this situation before. I sell an app and I want to offer my customers a migration path from a competing product. However,...
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
5
by: Steve Schlesinger | last post by:
Suppose you have class A {}; class B {} template<class T> void SomeFcn( T t ) {…}; A a; B b;
10
by: John T. | last post by:
Hi all Figure this scenario: - My Company develops an assembly (a controls DLL) - Since an obfuscation software is too expensive, my Company engages a consultant and delegates him the...
4
by: Martitza | last post by:
Hi. I work for a small company (actually in process of forming) interested in embedding or extending python as part of our commercial non-open-source product. We have legal counsel, but are...
7
by: linq936 | last post by:
Hi, I am puzzled on this C puzzle: How to interpret this C statement: sizeof (int) * p Is that the size of integer type multiplies p or the size of whatever p points to in integer type? I...
11
by: Bartholomew Simpson | last post by:
I need to store two float values (each of which requires less 16 bit storage), in a double data type. Can anyone give me some macros to retrive/store values in the double ? something along the...
16
by: jackie | last post by:
i know that in c plus plus,++x returns l-value while x++ returns r- value,but what is the situation in c,are both ++x and x++ return r- value? i don't know how C99 defines it,thx.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.