Sunday, April 2, 2017

  1. This program will print 1 to 100 without using any loop and recursion.
  1. #include<stdio.h>
  2. int i;
  3. void b(){
  4. printf("%d\n",i++);}
  5. void c(){
  6. b(),b(),b(),b(),b();}
  7. void a(){
  8. c(),c(),c(),c(),c();}
  9. void main(){
  10. i=1;
  11. a(),a(),a(),a();
  12. }
2. Print hello without using any semicolon in the program.
1st method:
  1. #include<stdio.h>
  2. void main(){
  3. switch(printf("hello")) {}
  4. }
2nd method:
  1. #include<stdio.h>
  2. #define PRINT printf("hello")
  3. void main(){
  4. if(PRINT){}
  5. }
3rd method:
  1. #include<stdio.h>
  2. void main(){
  3. while(!printf("hello")){}
3.Program to print "Hello Quora" using if and else both statement.
  1. #include <stdio.h>
  2. void main(){
  3. if(!printf("Hello "));
  4. else printf("Quora\n");
  5. }
4. C Program to print source code as program output
  1. #include <stdio.h>
  2. int main(void){
  3. FILE *fp;
  4. char c;
  5. fp = fopen(__FILE__, "r");
  6. do { c=fgetc(fp); putchar(c); }
  7. while(c!=EOF); fclose(fp);
  8. return 0;
  9. }
Output (above source code is output):

No comments:

Post a Comment