Jump to content
Sign in to follow this  
linuxuser

C/C++ Programming: Beauty of C

Recommended Posts

Check out some of these C codes I found in the Web!!! Simply amazing. No wonder C is a cooool language.

 

1)

#include <stdio.h>

int main()

{

int a=3, b = 5;

 

printf(&a["Ya!Hello! how is this? %s\n"], &b["junk/super"]);

printf(&a["WHAT%c%c%c %c%c %c !\n"], 1["this"],

2["beauty"],0["tool"],0["is"],3["sensitive"],4["CCCCCC"]);

return 0;

}

 

2)

#include <stdio.h>

int main()

{

int i = 6;

if( ((++i < 7) && ( i++/6)) || (++i <= 9))

;

printf("%d\n",i);

return 0;

}

 

3)

#include<stdio.h>

#include<ctype.h>

 

char t[]={

0,0,0,0,0,0,12,18,33,63,

33,33,62,32,62,33,33,62,30,33,

32,32,33,30,62,33,33,33,33,62,

63,32,62,32,32,63,63,32,62,32,

32,32,30,33,32,39,33,30,33,33,

63,33,33,33,4,4,4,4,4,4,

1,1,1,1,33,30,33,34,60,36,

34,33,32,32,32,32,32,63,33,51,

45,33,33,33,33,49,41,37,35,33,

30,33,33,33,33,30,62,33,33,62,

32,32,30,33,33,37,34,29,62,33,

33,62,34,33,30,32,30,1,33,30,

31,4,4,4,4,4,33,33,33,33,

33,30,33,33,33,33,18,12,33,33,

33,45,51,33,33,18,12,12,18,33,

17,10,4,4,4,4,63,2,4,8,

16,63 };

int main(int argc,char** argv)

{

int r,pr;

for(r=0;r<6;++r)

{

char *p=argv[1];

while(pr&&*p)

{

int o=(toupper(*p++)-'A')*6+6+r;

o=(o<0||o>=sizeof(t))?0:o;

for(pr=5;pr>=-1;--pr)

{

printf("%c",( ( (pr>=0) && (t[o]&(1<<pr)))?'#':' '));

}

}

printf("\n");

}

return 0;

}

 

4)

#include<stdio.h>

#define f ( a, b ) a##b

#define g(a) #a

#define h(a) g(a)

 

int main()

{

printf("%s\n",h(f(1,2)));

printf("%s\n",g(f(1,2)));

return 0;

}

Edited by rs_1915

Share this post


Link to post
Share on other sites
QUOTE (rs_1915 @ Jul 19 2004, 06:18 PM)
Bhaskar, u think C++ syntax is ugly or language itself is ugly?? smile.gif could u explain bit more and what languages u like the most? i noticed u r CS major.

C as said by its creator is an elegant programming language. I agree with that. The syntax of C++ is elegant too. But people make it ugly. Writing hard to read programs is often easy in C and C++. I believe in writing readable programs.

 

The language that I like most is without doubt C and C++.

Share this post


Link to post
Share on other sites

QUOTE

Writing hard to read programs is often easy in C and C++. I believe in writing readable programs.

 

Readable programs are good. But i like to explore the power of C/C++. I dont see any fun in straight forward codes.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.