- 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();
- }
2. 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")){}
3.Program to print "Hello Quora" using if and else both statement.
- #include <stdio.h>
- void main(){
- if(!printf("Hello "));
- else printf("Quora\n");
- }
4. 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):
No comments:
Post a Comment