| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | RE: [C] C Puzzles one more solutions .. |
From:
One more way to print hello world with out using semi colon ;
-----Original Message-----
From: c-bounces{at}snippets.org [mailto:c-bounces{at}snippets.org] On Behalf
Of Darin McBride
Sent: Friday, June 04, 2004 9:03 AM To: SNIPPETS C programming conference
Subject: Re: [C] C Puzzles
On June 2, 2004 9:39 pm, Bruce D. Wedding wrote:
> I found these on a C Yahoo group and some look like fun.
>
> 1. Write a "Hello World" program in 'C' without using a semicolon.
> (Hint: this makes use of C99 to be legal)
Ok, that is something I'm not aware of... lemme guess...
int main()
{
return printf("hello world\n") \u3b
}
void main ()
{
if (printf("Hello world\n"))
{}
}
although I can't get it to work here ...
> 2. Write a C program without using any loop (if, for, while etc) to
> print numbers from 1 to 100 and 100 to 1;
Done. :-)
> 3. Find if the given number is a power of 2.
#include "bitcnt_1.c"
#include "stdlib.h"
int main(int argc, char* argv[])
{
int x = atoi(argv[1]);
if (bit_count(x) == 1)
printf("%d is a power of 2\n", x);
return 0;
}
> 4. Multiply x by 7 without using multiplication (*) operator.
x+x+x+x+x+x+x?
> 5. Write a function in different ways that will return f(7) = 4 and
> f(4) = 7
My favourite... ;-)
int func(int x)
{
switch (x) {
case 7:
return 4;
case 4:
return 7;
}
return 0;
}
> 6. Remove duplicates in array
>
> 7. Finding if there is any loop inside linked list.
>
> 8. Write code to determine if a TYPE is signed or unsigned. Got it?
> OK, write code to determine if a value is unsigned or signed.
_______________________________________________
C mailing list
C{at}snippets.org
http://www.snippets.org/mailman/listinfo/c
Gateway to the FidoNet C_Echo
--- BBBS/LiI v4.01 Flag-5
* Origin: Prism's_Point (1:261/38.1)SEEN-BY: 633/267 270 @PATH: 261/38 123/500 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.