It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming C and C++ Forum

Help with C++ program

Help with C++ program

Postby Kotik on Fri Nov 12, 2004 5:43 pm

I gotta make a C++ program untill Monday for school. Its the deadline for handing in our programs. So I gotta make one by the end of this weekend. But the problem is I dont know what to make a program about?

The things that the program should have is a Switch funtion and some IF, ELSE commands.

Now, does anyone have a suggestion of what kind of a program I could make?

Any help is very much appreciated. Thanks in advance.
DEVPPL : News Publisher
User avatar
Kotik
1000+ Club
 
Posts: 1086
Joined: Mon Aug 23, 2004 12:25 am
Location: Sweden

Postby Malcolm on Fri Nov 12, 2004 8:54 pm

make a simple input game, like a choose your own adventure type of thing
User avatar
Malcolm
100+ Club
 
Posts: 198
Joined: Thu Oct 07, 2004 9:53 pm
Location: Ontario, Canada

Postby Kotik on Sat Nov 13, 2004 12:29 am

Malcolm wrote:make a simple input game, like a choose your own adventure type of thing


Like what? I dont really get what you mean.

HELP ME SOMEBODY. I'm getting a panic.
DEVPPL : News Publisher
User avatar
Kotik
1000+ Club
 
Posts: 1086
Joined: Mon Aug 23, 2004 12:25 am
Location: Sweden

Postby Kotik on Sat Nov 13, 2004 12:33 am

Any sites where I could get some simple c++ programs that I could use as examples?
DEVPPL : News Publisher
User avatar
Kotik
1000+ Club
 
Posts: 1086
Joined: Mon Aug 23, 2004 12:25 am
Location: Sweden

Postby Kotik on Sat Nov 13, 2004 2:03 am

#include <iostream.h>

main ()
{
int val;
int num = 1;

cout << "Please choose a number between 1 to 9 \n";
cin >> val;

if (val < 10)
{
num += 1
cout << val " * " num " = " val(num) "\n";
}
else cout << "This is a multiplying program";

return 0;
}


It gives an error where the red text appears. Anyone knows whats wrong there?

I'm trying to make a program that multiplies the digit you choose (val). Num is the digit val has to multiply with.

I want it to be like
val * num = val*num (num here is 1)
num = num+1 (num now becomes 2)
val * num = val*num (now val multiplies with 2)

The program is to go on in the same manner untill num=10.
DEVPPL : News Publisher
User avatar
Kotik
1000+ Club
 
Posts: 1086
Joined: Mon Aug 23, 2004 12:25 am
Location: Sweden

Postby Malcolm on Sat Nov 13, 2004 3:10 am

you're not using cout with the correct syntax

try something like
Code: Select all
#include <iostream.h>

int main()
{
  int val;
  int num=0;

  cout << "Enter a value, kthx:";
  cin >> val;

  if(val < 10){
    cout << "You entered a very small number\n\n";
  }else if (val < 20){
    cout << "You entered a decent sized number\n\n";
  }else{
    cout << "You entered a pretty big number\n\n";
  }

  cout << "Lets check out a times tables based on your number!\n\n";

  while(num < 10){
    cout << val << " * " << num << " = " << val * num << endl;
    num++;
  }

  cout << "Well, thats all!\n";

  return 0;
}
User avatar
Malcolm
100+ Club
 
Posts: 198
Joined: Thu Oct 07, 2004 9:53 pm
Location: Ontario, Canada

Postby Kotik on Sat Nov 13, 2004 4:03 am

Malcolm wrote:you're not using cout with the correct syntax

try something like
Code: Select all
#include <iostream.h>

int main()
{
  int val;
  int num=0;

  cout << "Enter a value, kthx:";
  cin >> val;

  if(val < 10){
    cout << "You entered a very small number\n\n";
  }else if (val < 20){
    cout << "You entered a decent sized number\n\n";
  }else{
    cout << "You entered a pretty big number\n\n";
  }

  cout << "Lets check out a times tables based on your number!\n\n";

  while(num < 10){
    cout << val << " * " << num << " = " << val * num << endl;
    num++;
  }

  cout << "Well, thats all!\n";

  return 0;
}


Thanx alot dude !! That is an ideal program I would need to make!!!

Just one question. Does the program work on Borland C++? I forgot to say that I must program everything in Turbo C++ IDE. Pretty dull but I got no choice.
DEVPPL : News Publisher
User avatar
Kotik
1000+ Club
 
Posts: 1086
Joined: Mon Aug 23, 2004 12:25 am
Location: Sweden

Postby Kotik on Sat Nov 13, 2004 4:07 am

Malcolm wrote:
Code: Select all
     while(num < 10){
       cout << val << " * " << num << " = " << val * num << endl;
       num++;
     }



The program is great but I will still need to understand every part of it incase the teach asks me a question.

What does endl; and num++; do?
DEVPPL : News Publisher
User avatar
Kotik
1000+ Club
 
Posts: 1086
Joined: Mon Aug 23, 2004 12:25 am
Location: Sweden

Postby Malcolm on Sat Nov 13, 2004 4:25 am

Kotik wrote:
Malcolm wrote:
Code: Select all
     while(num < 10){
       cout << val << " * " << num << " = " << val * num << endl;
       num++;
     }



The program is great but I will still need to understand every part of it incase the teach asks me a question.

What does endl; and num++; do?


endl = end line
num++ = ( num = num + 1 )

{EDIT}
Oh, this code will work in any Windows-based compiler, if you want Unix/Linux based code just ask :)
User avatar
Malcolm
100+ Club
 
Posts: 198
Joined: Thu Oct 07, 2004 9:53 pm
Location: Ontario, Canada

Postby Kotik on Sat Nov 13, 2004 4:39 am

num++; will come handy !

Thanks alot man !! You have no idea how much your help will imorove my grades!
DEVPPL : News Publisher
User avatar
Kotik
1000+ Club
 
Posts: 1086
Joined: Mon Aug 23, 2004 12:25 am
Location: Sweden


Who is online

Users browsing this forum: No registered users and 0 guests