Thread: Code translating

  1. #1
    In your face... ha ha ha Liger86's Avatar
    Join Date
    Dec 2002
    Motorcity Capital

    Post Code translating

    I'm following a tutorial on and I come across a program, well code.

    It is as follows:

    include <stdio.h>
     int main()
       int a=5;
       int b=6;
       int result=a*b;
       printf("%d * %d = %d\n", a, b, result);
       return 0;
    So in the tutorial it say that this program is for c not c++. Well its obvious 'cause they use print not cout to print on screen, so how would this look like if you were to converet this to c++?

    Are there sertain things I need to delete or put in other plases?
    From Ukraine with love!

    Internationally known – widely respected

    - Digitally yourz -

  2. #2
    Registered User
    Join Date
    Sep 2002
    It would look like this:

     include <iostream>
    int main()
       int a=5;
       int b=6;
       int result=a*b;
       cout << a << "*" << b << "=" << result << endl;
       return 0;

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Why not read a C++ tutorial, or simply take a look at some of the code on the C++ board. This is afterall the C board, and your question is about C++.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    About 99.95% of valid C code is valid C++. Your program would compile as C++ as well.

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM