Jump to content


Photo

C/C++ Programming: Beauty of C


  • Please log in to reply
4 replies to this topic

#1 linuxuser

linuxuser

    Honourable Member

  • WNSO Addict
  • PipPipPipPip
  • 1,147 posts

Posted 16 June 2004 - 08:47 PM

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, 16 June 2004 - 08:50 PM.

:)

#2 Bhaskar

Bhaskar

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 19 July 2004 - 10:37 AM

I think it is ugliness, rather than beauty of C.

#3 linuxuser

linuxuser

    Honourable Member

  • WNSO Addict
  • PipPipPipPip
  • 1,147 posts

Posted 19 July 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.
:)

#4 Bhaskar

Bhaskar

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 20 July 2004 - 03:58 AM

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++.

#5 linuxuser

linuxuser

    Honourable Member

  • WNSO Addict
  • PipPipPipPip
  • 1,147 posts

Posted 20 July 2004 - 08:22 PM

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.
:)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users