Sunday, January 1, 2017

Reversing a word entered from keyboard in C without using 'stack'

Hello friends !                                                Happy New Year 2017 !

To  coders and code lovers all over  the world.........

I hope you will find this piece of code interesting. Please respond with alternative ideas/modifications to improve the code.
//Input a word at console from keyboard and get its reverse (without using STACK !)
#include<stdio.h>
int main()
{
    char c[]="                                            "; // Put enough white spaces (more than expected word size)
    printf("type a word :");
    scanf("%s",&c);
    for(int i=(sizeof(c)-1);i>=0;i--)
    {
        printf("%c",c[i]);
    }
return 0;
}

No comments:

Post a Comment

Sacred Thought

5 May 2024 Hari Om Verse 50-51, chapter two:  In this chapter two Shree krishna explains a simple way of living. Free from desires and void ...