Program to display inputted string in ascending triangle and descending triangle in C





#include
#include
void main(){
char str[]="C Programming For You..";
int i,choice;
while(1){
clrscr();
printf("*****C Programming For You*****\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 Stylefor(i=0;str[i]!='\0';i++)
printf("%.*s\n",i,str);
printf("%.*s\n",i,str);
getch();
break;
case 2: //Decending Stylefor(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();
}
}
}


No comments:

Post a Comment