What are some mind blowing C programs?

Hello Readers,

You may have played around a lot using C language during your college days in labs. Let’s dive back to those days and check out few of those.

Below are some of the mind blowing C programs:

This program will print 1 to 100 without using any loop and recursion.

#include<stdio.h>
int i;
void b(){
printf("%d\n",i++);}
void c(){
b(),b(),b(),b(),b();}
void a(){
c(),c(),c(),c(),c();}
void main(){
i=1;
a(),a(),a(),a();
}

Print hello without using any semicolon in the program.

1st method:

#include<stdio.h>
void main(){
switch(printf("hello")) {}
}

2nd method:

#include<stdio.h>
#define PRINT printf("hello")
void main(){
if(PRINT){}
}

3rd method:

#include<stdio.h>
void main(){
while(!printf("hello")){}

Program to print “Hello Quora” using if and else both statement.

#include <stdio.h>
void main(){
if(!printf("Hello "));
else printf("Quora\n");
}

C Program to print source code as program output

#include <stdio.h>
int main(void){
FILE *fp;
char c;
fp = fopen(__FILE__, "r");
do { c=fgetc(fp); putchar(c); }
while(c!=EOF); fclose(fp);
return 0;
}

Output (above source code is output):

mind blowing C programs

Credits: This article has been taken from Quora: Nitin Goswami’s Answer

What do you think?

Dear Reader,
If you have any questions or suggestions please feel free to email us or put your thoughts as comments below. I would love to hear from my readers. Please share along with your friends and help them to learn.

Keep Learning!