954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

help to give program for this output?

Give program for this output
abcdeedcba
abcdxxdcba
abcxxxxcba
abxxxxxxba
axxxxxxxxa

rohoni
Newbie Poster
20 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 
#include <stdio.h>

int main()
{
printf("abcdeedcba\nabcdxxdcba\nabcxxxxcba\nabxxxxxxba\naxxxxxxxxa\n");

return 0;
}
plgriffith
Junior Poster
100 posts since Feb 2008
Reputation Points: 10
Solved Threads: 6
 

thank u!
but i need this output using for loop

rohoni
Newbie Poster
20 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 
const char const * strings[] = {"abcdeedcba\n","abcdxxdcba\n","abcxxxxcba\n","abxxxxxxba\n","axxxxxxxxa\n",
     NULL};
for(char const ** ptr = strings; *ptr; ++ptr)
{
	printf(*ptr);
}
mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

I'd start with plgriffith's program and make a minor change

#include <stdio.h>

int main()
{
    char buf[] = "abcdeedcba\nabcdxxdcba\nabcxxxxcba\nabxxxxxxba\naxxxxxxxxa\n";
    int  i;

    i = 0;
    while (buf[i])
    {
        putchar (buf[i++]);
    }
    return 0;
}
WaltP
Posting Sage w/ dash of thyme
Moderator
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You