Major Beginner looking for simple pointers

This is a discussion on Major Beginner looking for simple pointers within the C++ Programming forums, part of the General Programming Boards category; I just started my C++ programming class and I am having trouble. I understnd what the book says but not ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    2

    Unhappy Major Beginner looking for simple pointers

    I just started my C++ programming class and I am having trouble. I understnd what the book says but not how to use it.
    I have a program that allows the user to specify the number of lines in a tree of X's and asks if they would like to repeat. The part that I am having trouble with is that while the tree is 30 lines long, if the user enters a number larger than 30 I need to have the program default to 30 lines and then print the tree of 30 lines. If anyone could maybe point me in the right direction I would sure appreciate it. If you need more specifics let me know. Thank you soooo much.....Peace

  2. #2
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Talking well...

    you jsut said the answer

    if( lines > 30 )
    {
    lines = 30;
    }

    If you would like some lessons in C++ and logic, just email .

    SPH

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    154

    Re: well...

    Originally posted by minime6696
    you jsut said the answer

    if( lines > 30 )
    {
    lines = 30;
    }

    If you would like some lessons in C++ and logic, just email .

    SPH
    Leave out the braces if you want:

    Code:
    if (lines > 30)
      lines = 30;

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    2
    Thank you both for the answers. I'm going to post the code that I have so far. I have no idea what's going on. A friend of mine wrote it for me. So maybe you could help me a bit.
    minime6696-----if you are serious I would love to take you up on your offer.Thank you....
    Here's what I have...#include <iostream>
    #include <conio.h>

    using namespace std;

    int main (void)
    {
    int line, n, w;
    char rep = 'y';
    while(rep == 'y' || rep == 'Y')
    {
    cout<<"Enter number of lines."<<endl;
    cout<<"(1 through 30)"<<endl;
    cin>>line;
    if(line<=30 && line >=0)
    {
    for(w = 0; w < line; w ++)
    { for(n=30; n>w ; n--) {
    cout<<" "; }
    for(n=0 ; n<w*2+1 ; n++)
    {
    cout<<"x";
    }
    cout << endl;
    }
    }
    else
    cout <<"Default to 30 lines."<<endl;
    cout << "Repeat? Y to repeat."<< endl;
    cin >> rep;

    }
    cout<<"Press any key to exit."<<endl;

    getch();
    return 0;
    }
    Sorry it's long, and rememeber I am just starting out at this programming mumbo jumbo...Thanks again...Peace

  5. #5
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    im sierious

    My aim handle (wierd as it is) is:

    aGaBoOgAmOnGeR - Add me to AIM and I will give you some lessons... oh yes and wut compiler do u have?

    SPH

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 06:59 AM
  2. Replies: 4
    Last Post: 12-10-2006, 07:08 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 01:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21