#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char ch[200];
void print() {
printf("\nEnter the message: ");
gets(ch);
}
void ntime() {
int n, i;
n = strlen(ch);
printf("The above message is printed %d times below:", n);
for (i = 0; i < n; i++)
printf("\n%s", ch);
printf("\n");
}
void revo() {
printf("The message in reverse order is: ");
printf("%s\n", strrev(ch));
}
void change() {
int i, j;
i = strlen(ch);
for (j = 0; j < i; j++) {
if (ch[j] >= 'a' && ch[j] <= 'z')
ch[j] -= 32;
else if (ch[j] >= 'A' && ch[j] <= 'Z')
ch[j] += 32;
else
continue;
}
puts(ch);
}
void block() {
int i, j, n;
n = strlen(ch);
printf("The given message in block staircase pattern is: \n");
for (i = 0; i < n; i++) {
for (j = 0; j <= i; j++)
printf("%c", ch[j]);
printf("\n");
}
printf("\n");
}
void main() {
int a;
while (1) {
printf("\nMENU");
printf("\n1.Print message no. of time as per its length");
printf("\n2.Print the message in reverse order");
printf("\n3.Print the message in block staircase pattern");
printf("n4.Print the message in capital letters and vice versa");
printf("\n5.Exit from program");
printf("\n\nEnter your choice: ");
scanf("%d", &a);
switch (a) {
case 1:
ntime();
break;
case 2:
revo();
break;
case 3:
block();
break;
case 4:
change();
break;
case 5:
exit(1);
default:
printf("Invalid choice\n");
}
}
}
WHAT'S NEW?
Loading...
0 comments:
Post a Comment