C Programming Tutorial

 
 
 
 

Image

#include <stdio.h>
#include <conio.h>
void main(){
     char str[]=\"C Programming\";
     int i,choice;
     while(1){
     clrscr();
     printf(\"*****C Programming*****\\n\\n\");
     printf(\"1) Ascending style\\n\");
     printf(\"2) Decending style\\n\");
     printf(\"3) Exit\\n\");
     printf(\"Enter your choice : \");
     scanf(\"%d\",&choice);
     printf(\"\\n\\n\");
     switch(choice){
     case 1:   //Ascending Style
           for(i=0;str[i]!=\'\\0\';i++)
        printf(\"%.*s\\n\",i,str);
        printf(\"%.*s\\n\",i,str);
        getch();
        break;
     case 2:   //Decending Style
           for(i=0;str[i]!=\'\\0\';i++);
           while(i>0){
          printf(\"%.*s\\n\",i,str);
          i--;
           }
           getch();
           break;
     case 3:   exit(1);
     default : printf(\"\\n\\nInvalid choice\\n\\n\");
           getch();
     }
  }
}

 
 
Didn't find what you were looking for? Find more on Program to display inputted string in ascending triangle and descending triangle