Monday, May 24, 2010

Write a c program to display ur name, without using semi colon,quotes, array?

is it possible to do. if so write the program for me

Write a c program to display ur name, without using semi colon,quotes, array?
Sounds like you want us to do your home work. So I will not give you a program that will do it. But if I was doing it I would try using a while loop





something like:





while( printf( (char)65 + (char)66 ) { }





this is just a starting point you will have to work on it from here





UPDATE:


Ok people are still saying it can't be done so here is the code to do it.





#include %26lt;stdio.h%26gt;


void main( int arg, char *argv[] )


{


while( printf( argv[1] ) %26amp;%26amp; false ) { }


}





No semi colon, no quotes. And if need be I could do it with out a command line parameter. (I just dont feel like looking up the ascii codes)
Reply:first - you do need one semicolon, otherwise there's no way to do it.





second - figure out what each letter in your name is numerically. a quick way to find out - write a different program. a *very* basic version is the following:





---





main()


{


char name[4]="joe";


char i;





for(i=0;i%26lt;3;i++)


printf("%d ",name[i]);


}





---





let's assume you found out "joe" is 12 92 43. (which in reality it's not.) a very basic version of the program you could write is:





---





main()


{


cout %26lt;%26lt; (char)12,(char)92,(char)43;


}
Reply:No way, semi colons to C are like period points to English. Without ever using quotes in C is also impossible.
Reply:Not that I know of. The not using an array is the tricky part...a string (which would be neccisary to hold a name) needs to be an array of chars. I guess you could have a seperate variable for each letter. But then you're faced with actually calling some kind of output function which will need to be terminated with a semicolon. Sorry, I don't think it's possible, even using super god like macro power.
Reply:thier is no way at all, especially the semi colon


No comments:

Post a Comment