Solution for Exercise 12-8

ex1208

#include <stdio.h>

int main()
{
    char sentence[] = "Random text";
    int index;

    index = 0;
    while(sentence[index] != '\0')
    {
        putchar(sentence[index]);
        index++;
    }
    putchar('\n');
    return(0);
}

Output

Random text

Notes

* Can you re-write this code using a for loop instead of a while loop? Click here when you've completed this task to compare your solution with mine.