reverse String in C
reverse String in C
#include <stdio.h>
int main() {
char str1[] = "Girish"; // String 1
char str2[8]; // Variable to store reverse string
int length = 0;
int length2 = 0;
while(str1[length] != '\0') {
length2++;
}
printf("\nPrinting in reverse - ");
for(length2 = --length; length2>=0; length2--)
printf("%c", str1[length2]);
length2 = 0;
printf("\nStoring in reverse - ");
while(length >= 0) {
str2[length] = str1[length2];
length--;
length2++;
}
str1[length2] = '\0'; // Terminates the string
printf("%s\n", str2);
return 0;
}
Sort String Characters in C
stdio.h>
#include <
#include < string.h>
int main() {
char s[] = "girish"; // String Given
int i = 0;
int vowels = 0; // Vowels count
int consonants = 0; // Consonants count
int main() {
char str1[] = "Girish";
char str2[] = "PavanTejas";
char ch;
int index = 0;
//Character by Character approach
printf("Before Swapping - \n");
printf("Value of str1 - %s \n", str1);
printf("Value of str2 - %s \n", str2);
while(str1[index] != '\0') {
ch = str1[index];
str1[index] = str2[index];
str2[index] = ch;
index++;
}
printf("After Swapping - \n");
printf("Value of str1 - %s \n", str1);
printf("Value of str2 - %s \n", str2);
return 0;
}
//String Anagram Program in C
stdio.h>
#include <
#include < string.h>
//fried , fired
//triangle integral
//heart, earth
//race, care
//part, trap
har temp;
c
stdio.h>
#include <
#include < string.h>
n = string_length(line);
string_reverse(temp);
strcat(reverse, temp);
strcat(reverse, " ");
}
return 0;
}
C Program to reverse a line
stdio.h>
#include <
#include < string.h>
string_reverse(temp);
strcat(reverse,temp);
strcat(reverse," ");
}
return 0;
}