c++ - Simple for loop I can't figure out -


i'm kind of new c++ last night thought of something. want print out numbers 1-100 10 numbers per line. i'm aware code below wrong prints 1-100 vertically. if can shed light question, appreciated. reading :)

#include <iostream> using namespace std;  int main() {      for(int x = 1; x <= 100; x++) {         cout << x << endl;      } } 

so want print 10 numbers, carriage return, , 10 numbers, carriage return, , on, correct?

if so, how like:

for(int x = 1; x <= 100; x++) {     cout << x << " ";     if ((x%10)==0) cout << endl; } 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -