Thread: first step towards C++

  1. #16
    Registered User
    Join Date
    Mar 2011
    Posts
    254
    Quote Originally Posted by jackson6612 View Post
    Hi

    Code:
    #include <iostream>
    
    int main()
    {
    	float a, b, c, d, Mean;
    	std::cout << "Enter first number: ";
    	std::cin >> a;
    	std::cout << "Enter second number: ";
    	std::cin >> b;
    	std::cout << "Enter third number: ";
    	std::cin >> c;
    	std::cout << "Enter fourth number: ";
    	std::cin >> d;
    	std::cout << "The mean is: " << (a + b + c + d) / 4;
    }
    1: As you see above every "std::cout" is followed "std::cin", is this possible in some situation where "std::cout" or "std:cin" is followed another "std::cout" or "std::cin" respectively?

    2: I want the line "The mean is:" to appear red and bold? How do I do this?

    3: I have seen my friend use commands "\endl" and "\n" (hope I have them right). What functions do they serve?

    It is very kind of you to help me. I'm much obliged.

    Best wishes
    Jackson
    Help, please.

  2. #17
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by jackson6612 View Post
    Help, please.
    1. Yeah sure:
    Code:
    	std::cout << "Enter first number ";
    	std::cout << "and second number\n";
    	std::cin >> a;
    	std::cin >> b;
    2. Platform specific I believe. I'm sure you can google it.

    3. They are about the same and make the next bit of text start on a new line.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. debugging - step into issue
    By barneygumble742 in forum C++ Programming
    Replies: 7
    Last Post: 03-15-2009, 12:30 PM
  2. recursion
    By paulmedic555 in forum C Programming
    Replies: 26
    Last Post: 01-28-2005, 12:43 AM
  3. robot step sizes
    By n00by in forum C Programming
    Replies: 2
    Last Post: 04-29-2004, 03:29 PM
  4. step by step debug != run debug
    By bonkey in forum Windows Programming
    Replies: 8
    Last Post: 09-09-2002, 12:55 PM
  5. this sites Compiler Resources Specs.
    By Powerfull Army in forum C++ Programming
    Replies: 9
    Last Post: 07-08-2002, 06:12 PM