the output should be...

"1
  2
   3

     5
      6
       7
        8
         9
           Merry christmas"

using for loop..
here's my code !

</ #include<stdio.h>
   #include<conio.h>

   main()
  {
      int x;

     for(x=0;x<9;x++){
                       printf("\n %d ",x);

                       }

      getch();
      }


>

I'm just a beginner..help please :'(

try like this(not tested but it will give you a hint):

for(x=1;x<=9;x++)
    {
        for(sp=1;sp<x;sp++)
        {
            printf(" ");
        }
        printf("%d\n",x);
    }
    printf("Merry chirstmas");

this should work.

for more information on loops visit my tutorial here.

okay..Thank you so much :)

please mark your thread as solved.

Or if you want to use Cout to print instead

#include <iostream>
using namespace std;

for(int i =1, i<10,i++){
    cout<<"The current number is: "<<i<<endl;
}
cout<<"Merry xmas"<<endl;

have a look at the setw() from the lib iomanip.

for(int c=0;c<10;c++){
    cout << std::setw(c+5)<<c<<endl;
}
cout <<setw(25)<<"Merry xmas "; // simple alc (10*2)+5

//out put
   0
     1
      2
       3
        4
         5
          6
           7
            8
             9
              Merry xmas 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.