...

View Full Version : is there any other method to write Hello World?



hackerzlab
08-04-2009, 03:05 PM
have to make a simple program and was wondering if there would be any other better way to have an output like this:



H
H E
H E L
H E L L
.,................

and goes on for the next few lines...



#include<stdio/h>
main()
{
printf(“H\nH E \nH E L\n”);

}


do you think there's a better way to have an output instead of using spaces in the code?

Fou-Lu
08-04-2009, 03:15 PM
You can use a tab with \t.

abduraooft
08-04-2009, 03:28 PM
Check
#include <stdio.h>
int main(){
char a[]="HelloWorld!";
int i,j,k;
for(i=0;i<strlen(a);i++){
for(k=0;k<strlen(a)-i+1;k++)
printf(" ") ;
for(j=0;j<=i; j++)
printf("%c ",a[j]);
printf("\n\n");
}
}

Fou-Lu
08-04-2009, 03:37 PM
Oh I see now, its supposed to be a triangle :P
I missed that when I was looking at the original, seemed a little... lopsided lol.

I demand you change the algorithm to do the christmas tree instead!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum