WHAT'S NEW?
Loading...
Showing posts with label Strings in C. Show all posts
Showing posts with label Strings in C. Show all posts

/*Check if a phrase is Palindrome*/
#include<stdio.h>
#include<string.h>

void main() {
    char phr[50], phrs[50];
    int i, j;
    printf("\nEnter the phrase: ");
    gets(phr);
    i = strlen(phr);
    for (j = 0; j < i; j++) {
        phrs[j] = phr[i - 1 - j];
    }
    if (strcmpi(phr, phrs) == 0)
        printf("\nIt is a palindrome");
    else
        printf("\nIt is not a palindrome");
}


/*Convert lowercase letters to uppercase*/
#include<stdio.h>
#include<string.h>

void main() {
    char phr[50];
    int i;
    clrscr();
    printf("\nEnter the phrase in small letter:\n");
    gets(phr);
    for (i = 0; i < 50; i++)
        phr[i] = toupper(phr[i]);
    puts(phr);
}