Help with function to print out a description of wht my program is about.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • idummi3
    New Member
    • Dec 2013
    • 3

    #1

    Help with function to print out a description of wht my program is about.

    So far,
    I got this
    #include <iostream>
    void introduction();
    int findsmallest(in t);
    void printmessage(in t);

    int main ()
    {

    how do it do this, thank you. that's the only think I need help with. I figure it should be the same as any other function but just need a little help. thank you.
    I don't know if anyone can see the full description. I need help writing a function to do the introduction. "the main program will start by calling a function named introduction which will print out a description of what the program does on the first output page. thank you
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Can you use printf?

    If so, I would write a printf in main() that displays the message you want. Then compile and run the program to be sure the message appears.

    Code:
    int main()
    {
     printf("Hello\n");
    }
    Next, write a function before main() and move the printf from main() to inside this function. Write the function call where you had the message.

    Code:
    void display()
    {
        printf("Hello\n");
    
    }
    
    int main()
    {
       display();
    }
    That's enough hints.

    Comment

    • idummi3
      New Member
      • Dec 2013
      • 3

      #3
      I can not use printf. how do I write a function before the main??

      for example I got.



      #include <iostream>
      using namespace std;
      void introduction();
      int findsmallest(in t,int,int);

      introduction();
      {
      cout<<"Hello, this program is to find the smallest out of three integers.";
      cout<<"A function called findsmallest will be used in order to enter 3 integers.";
      cout<<"then the smallest one will be chosen. Then send back to the main.";
      cout<<"Then printmessage will print the same amount of times as the integer chosen.";

      }
      int main()
      {
      int a;
      int b;
      int c;

      cout<<"Please enter three integers"<<endl ;
      cin>>a;
      cin>>b;
      cin>>c;

      }

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        You have written your introduction function before main. It looks good.

        Remember, your program starts with main() so you will need to call the introduction function inside main(). Look at my very last example.

        Comment

        • idummi3
          New Member
          • Dec 2013
          • 3

          #5
          Thanks a lot. I actually finished the program. I Just needed the introduction set. I'm too lazy to check it out. But thanks. It does make sense. Imma add that when I got time.

          Comment

          Working...