IHYPRESS PROGRAMMING
Tutorials and C programs with code and output for beginners
c programming
HOME | ASP | C | CSS | GNUPLOT | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
CStrings : Reverse Words
<08.08>
#include <stdio.h> #define WORDSIZ 25 void reverse_input_words (int n) { char word[WORDSIZ]; /* local variable for storing one word */ if (n <= 1) { /* simple case: just one word to get and print */ scanf("%s", word); printf("%s ", word); } else { /* get this word; get and print the rest of the words in reverse order; then print this word */ scanf("%s", word); reverse_input_words (n - 1); printf("%s ", word); } } int main (void) { int nw; printf ("How many words? "); scanf ("%d", &nw); reverse_input_words (nw); return (0); }
Hergestellt in Deutschland / Made in Germany
How many words? 4 the quick brown fox fox brown quick the
COPYRIGHT © 2015-2024 IHY PRESS Frankfurt am Main 60329 Deutschland