Not sure what you're asking other than missing a } your code works good and I'm guessing that's just a mistake in copping it. Your code outputs exactly that. Do you want white space between every number? If so add cout << '\n'; in your while loop. If not please be more specific where you want more white space.
#include <iostream>
int main() {
int userNum = 0;
std::cout << "number? " ;
std::cin >> userNum ; // accept userNum from standard input
for( int num = 0; num <= userNum; ++num ) { // for each number 'num' from 0, 1, ... userNum
// first print 'num' spaces
for( int num_sp = 0 ; num_sp < num ; ++num_sp ) {
std::cout << ' ' ; // print one space each time through the loop
// this inner loop executes 'num' times in all
// ergo 'num' spaces are printed
}
// then print the number 'num' followed by a new-line
std::cout << num << '\n' ;
}
}