I l @ ve RuBoard |
Reading about C isn't enough. You should try writing one or two simple programs to see if writing a program goes as smoothly as it looks in this chapter. Here are a few suggestions, but you should also try to think up some problems yourself.
Write a program that uses one printf() call to print your first name and last name on one line, uses a second printf() call to print your first and last name on two separate lines, and uses a pair of printf() calls to print your first and last name on one line. The output should look like this (but using your name):
Mae West | First print statement |
Mae | Second print statement |
West | Still the second print statement |
Mae West | Third and fourth print statements |
Write a program to print your name and address.
Write a program that converts your age in years to days. At this point, don't worry about fractional years and leap years.
Write a program that produces this output:
For he's a jolly good fellow! For he's a jolly good fellow! For he's a jolly good fellow! Which nobody can deny!
Have the program use two user -defined functions in addition to main() : one that prints the jolly good message once, and one that prints the final line once.
Write a program that creates an integer variable called toes . Have the program set toes to 10 . Also have the program calculate what twice toes is and what toes squared is. The program should print all three values, identifying them.
Write a program that produces this output:
Smile!Smile!Smile! Smile!Smile! Smile!
Have the program define a function that displays the string Smile! once, and have the program use the function as often as needed.
I l @ ve RuBoard |