Boolean Stuff

Discuss Programming

Boolean Stuff

Postby Doogee » Thu Mar 13, 2003 3:42 am

Hey, im trying to learn the boolean cpp stuff but cant get a simple program to compile.

Code: Select all
#include <iostream.h>

int main()

{
  int mark;
  cout << "If Statement Examlple\n\n\n\n";
  cout << "Please enter your mark for the test today\n";
  cin >> mark; // asks user input, sets variable as "mark"
  if(mark == 20) // if the mark is exactly equal to 20 do:
  {
    cout << "Wow! Full marks, thats great!\n";
    return 0;
  }
  if(mark > 20) // if mark is more than 20 do:
  {
    cout << "Thats Impossible, the test was out of 20, liar\n";
    return 0;
  }
  if(mark > 15 && < 20) // if mark is above 15 and below 20 do:
  {
    cout << "Thats a great mark, top effort!\n";
    return 0;
  }
  if(mark > 10 && < 15) // if mark is above 10 and below 15 do:
  {
    cout << "Comeon, better effort next time matey\n";
    return 0;
  }
  if(mark < 10) // if mark is below 10 do:
  {
    cout << "Pretty average\n";
    return 0;
  }
 return 0;
}
Doogee
administrator
administrator
 
Posts: 261
Joined: Fri Jan 10, 2003 1:40 am

Postby Void Main » Thu Mar 13, 2003 7:53 am

Code: Select all
#include <iostream.h>

int main()
{
  int mark;

  cout << "If Statement Examlple\n\n\n\n";
  cout << "Please enter your mark for the test today\n";
  cin >> mark; // asks user input, sets variable as "mark"

  if(mark == 20) {
    cout << "Wow! Full marks, thats great!\n";
    return 0;
  }

  if(mark > 20) {
    cout << "Thats Impossible, the test was out of 20, liar\n";
    return 0;
  }

  if(mark > 15 && mark < 20) {
    cout << "Thats a great mark, top effort!\n";
    return 0;
  }

  if(mark > 10 && mark < 15) {
    cout << "Comeon, better effort next time matey\n";
    return 0;
  }

  if(mark < 10) {
    cout << "Pretty average\n";
    return 0;
  }

  return 0;

}
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby Doogee » Thu Mar 13, 2003 6:05 pm

thankyou
Doogee
administrator
administrator
 
Posts: 261
Joined: Fri Jan 10, 2003 1:40 am


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests