w3resource
w3resource.com › c-programming-exercises › string › c-string-exercise-4.php
C : Print individual characters of string in reverse order
#include <stdio.h> #include <string.h> #include <stdlib.h> int main() { char str[100]; /* Declares a string of size 100 */ int l=0; printf("\n\nPrint individual characters of string in reverse order :\n"); printf("------------------------------------------------------\n"); printf("Input the string : "); fgets(str, sizeof str, stdin); l=strlen(str); printf("The characters of the string in reverse are : \n"); for(str[l]='\0';l>=0;l--) { printf("%c ", str[l]); } printf("\n"); return 0; // Return 0 to indicate successful execution of the program } ... Print individual characters of string in reverse order : ----------------------------------------------------------- Input the string : w3resource.com The characters of the string in reverse are : m o c . e c r u o s e r 3 w ... Write a C program to print the characters of a string in reverse order using recursion.
myCompiler
mycompiler.io › view › 6dnlI5HKwsC
Write a program in C to print individual characters of a string in reverse order. (C) - myCompiler
December 7, 2023 - #include <stdio.h> #include <string.h> int main() { char str[50]=" "; int l,i ; fgets (str, sizeof str,stdin); l=strlen(str); for (i=l; i>=0; i--){ printf ("%c ",str[i]); } return 0; }
Published Dec 06, 2023
w3resource
w3resource.com.cach3.com › c-programming-exercises › string › c-string-exercise-4.php.html
C : Print individual characters of string in reverse order
#include <stdio.h> #include <string.h> ... printf("The characters of the string in reverse are : \n"); for(i=l;i>=0;i--) { printf("%c ", str[i]); } printf("\n"); }...
w3resource
w3resource.com › c-programming-exercises › for-loop › c-for-loop-exercises-57.php
C Program: Print a string in reverse order - w3resource
#include <string.h> void main() { // Variable declarations char str1[100], tmp; int l, lind, rind, i; // Prompting user for input printf("\n\nPrint a string in reverse order:\n "); printf("-------------------------------------\n"); // Getting user input printf("Input a string to reverse : "); scanf("%s", str1); // Calculating the length of the string l = strlen(str1); // Initializing left and right indices for swapping lind = 0; rind = l - 1; // Loop for swapping characters from left to right for(i = lind; i< rind; i++) { tmp = str1[i]; str1[i] = str1[rind]; str1[rind] = tmp; rind--; } // Prin
PREP INSTA
prepinsta.com › home › c program › c program to print the string in reverse order
C program to print the given string in reverse order | PrepInsta
May 27, 2022 - Step 1. Take the string which you have to reverse as the input variable says str. Step 2:- Calculate the length of the string. The actual length of the string is one less than the number of characters in the string. Let actual length be len. Step 3:- Use a for loop to iterate the string using a temporary variable to swap the elements. Step 4:- Print the reversed string.
Quora
quora.com › What-is-a-C-program-to-print-individual-from-a-string-in-reverse-order
What is a C program to print individual from a string in reverse order? - Quora
Answer (1 of 2): The answer C program is given below : [code]#include #include int rev() //Open rev function { char st[100]; int len,i; gets(st); //Input the string len=strlen(st); //Calculate length of the string using strlen() function printf("\nThe reverse string is:"); ...
TutorialsPoint
tutorialspoint.com › article › write-a-c-program-to-print-the-message-in-reverse-order-using-for-loop-in-strings
Write a C program to print the message in reverse order using for loop in strings
for(initialization; condition; increment/decrement) { // Read characters } for(reverse_initialization; reverse_condition; reverse_increment) { // Print characters in reverse } This approach reads each character individually using getchar() and ...
Chegg
chegg.com › engineering › computer science › computer science questions and answers › write a program in c to print individual characters of a string
in reverse order.
test data:
input the string : resource.com
expected output:
the characters of the string in reverse are:
m o c . e c r u o s e r
Solved Write a program in C to print individual characters | Chegg.com
April 22, 2021 - Write a program in C to print individual characters of a string in reverse order. Test Data: Input the string : resource.com Expected Output: The characters of the string in reverse are: m o c .
Tutipy
tutipy.com › write-a-program-in-c-to-print-individual-characters-of-string-in-reverse-order
Tutipy
We cannot provide a description for this page right now
w3resource
w3resource.com › c-programming-exercises › basic-declarations-and-expressions › c-programming-basic-exercises-4.php
C Program: Print characters in a reverse way - w3resource
September 18, 2025 - #include <stdio.h> int main() { ... Print the original and reversed characters printf("The reverse of %c%c%c is %c%c%c\n", char1, char2, char3, char3, char2, char1); return(0); } ... In the "main()" function, it declares three ...
CodeScracker
codescracker.com › c › program › c-program-reverse-string.htm
C Program to Reverse a String
Get the length of the string using the strlen() function and initialize the length of the string minus one to any variable, say j, that represents the last character of the string initially. Now create a while loop that runs until i is less than j. Now, inside any temporary variable, say temp, initialize the first character, then place the last character at the first character and the first character (the "temp" variable holds the first character) at the last character, and increment the value of i and decrement the value of j.
Saylor Academy
learn.saylor.org › mod › book › tool › print › index.php
C String Exercises | Saylor Academy
#include <stdio.h> #include <string.h> ... str, stdin); l=strlen(str); printf("The characters of the string in reverse are: \n"); for(i=l;i>=0;i--) { printf("%c ", str[i]); } printf("\n"); }...
GeeksforGeeks
geeksforgeeks.org › c language › reverse-string-in-c
Reverse String in C - GeeksforGeeks
#include <stdio.h> #include <string.h> void rev(char* s) { // Initialize l and r pointers int l = 0; int r = strlen(s) - 1; char t; // Swap characters till l and r meet while (l < r) { // Swap characters t = s[l]; s[l] = s[r]; s[r] = t; // Move pointers towards each other l++; r--; } } int main() { char s[100] = "abcde"; // Reversing s rev(s); printf("%s", s); return 0; }
Published December 5, 2024
Upgrad
upgrad.com › home › tutorials › software & tech › reverse a string in c
C Program to Reverse a String Using Different Ways
June 23, 2025 - ... #include <stdio.h> #include ... = str[length - i - 1]; } reversed[length] = '\0'; // Add null terminator printf("Reversed String: %s\n", reversed); } int main() { char str[] = "Hello, World!"; printf("Original String: %s\n", ...
Top answer 1 of 2
2
It seems like in this while loop:
while (my_strg[i] != '\0')
{
end_of_string++;
}
you should increment i, otherwise if my_strg[0] is not equal to '\0', that's an infinite loop.
I'd suggest putting a breakpoint and look what your code is doing.
2 of 2
1
I think you should look at your second while loop and ask yourself where my_string[i] is being incremented because to me it looks like it is always at zero...
Naukri
naukri.com › code360 › library › how-to-reverse-a-string-in-c
Reverse a String in C - Naukri Code 360
Almost there... just a few more seconds