Thread: help

  1. #1
    Registered User
    Join Date
    Oct 2013


    hey everyone. I'm a complete programming noob. I'm working on a program that prints every even number from 100 to 200. Can someone tell me how i would be able to print 10 numbers per line?
    #include <iostream>
    using namespace std;
    int main()
    	int x;
    	for (x=100; x<=200; x++)
    		cout <<x++<< endl;
    return 0;

  2. #2
    11DE784A SirPrattlepod's Avatar
    Join Date
    Aug 2013
    There are a couple of ways. The most common way you'll probably encounter uses modulus operator

  3. #3
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    To print ten numbers per line, you can't call "endl" because endl prints a new line. Instead, just print a number (with spaces so it's not all clumped together) and once you hit 10 prints, print a new line.

    Also, to print every even number, read up on modulo and modulus operator. Basically, if you have a mod b, the mod part performs a/b and returns the remainder as the mathematical representation is a = n*b + m, where m is the remainder and n is an integer.

Popular pages Recent additions subscribe to a feed