1. 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 names on two separate lines, and uses a pair of printf() calls to print your first and last names on one line. The output should look like this (but using your name): Gustav Mahler First print statement Gustav Second print statement Mahler EStill the second print statement Gustav Mahler Third and fourth print statements

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter4: Making Decisions
Section: Chapter Questions
Problem 3RQ
icon
Related questions
Question

Hello can you please solve all of the problems on these images using the C progaming language. I want to check my answers to see if I did my work correctly.  

54
Chapter 2 Introducing C
5. Write a program that produces the following output:
Brazil, Russia, India, China
India, China,
Brazil, Russia
Have the program use two user-defined functions in addition to main(): one named
br() that prints "Brazil, Russia" once, and one named ic() that prints "India, China"
once. Let main() take care of
any additional printing tasks.
6. 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.
7. Many studies suggest that smiling has benefits. Write a program that produces the
following 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.
8. In C. one function can call another. Write a program that calls a function named one
three(). This function should display the word one on one line, call a second function
named two ( ), and then display the word three on one line. The function two() should
display the word two on one line. The main () function should display the phrase
starting now: before calling one_three() and display done! after calling it. Thus the
output should look like the following:
starting now:
one
three
done!
Transcribed Image Text:54 Chapter 2 Introducing C 5. Write a program that produces the following output: Brazil, Russia, India, China India, China, Brazil, Russia Have the program use two user-defined functions in addition to main(): one named br() that prints "Brazil, Russia" once, and one named ic() that prints "India, China" once. Let main() take care of any additional printing tasks. 6. 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. 7. Many studies suggest that smiling has benefits. Write a program that produces the following 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. 8. In C. one function can call another. Write a program that calls a function named one three(). This function should display the word one on one line, call a second function named two ( ), and then display the word three on one line. The function two() should display the word two on one line. The main () function should display the phrase starting now: before calling one_three() and display done! after calling it. Thus the output should look like the following: starting now: one three done!
printf("%d %d\n", x, y);
return 0;
{
What is the program state after line 7? Line 8? Line 9?
Programming Exercises
Reading about C isn't enough. You should try writing one or two simple programs to see
whether writing a program goes as smoothly as it looks in this chapter. A few suggestions
follow, but you should also try to think up some problems yourself. You'll find answers to
selected programming exercises on the publisher's website.
1. 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 names on two separate
lines, and uses a pair of printf() calls to print your first and last names on one line.
The output should look like this (but using your name):
Gustav Mahler First print statement
ESecond print statement
Gustav
Mahler
EStill the second print statement
Gustav Mahler Third and fourth print statements
2. Write a program to print your name and address.
3. Write a program that converts your age in years to days and displays both values. At this
point, don't worry about fractional years and leap years.
4. Write a program that produces the following 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 named
jolly() that prints the "jolly good" message once, and one named deny() that prints
the final line once.
Transcribed Image Text:printf("%d %d\n", x, y); return 0; { What is the program state after line 7? Line 8? Line 9? Programming Exercises Reading about C isn't enough. You should try writing one or two simple programs to see whether writing a program goes as smoothly as it looks in this chapter. A few suggestions follow, but you should also try to think up some problems yourself. You'll find answers to selected programming exercises on the publisher's website. 1. 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 names on two separate lines, and uses a pair of printf() calls to print your first and last names on one line. The output should look like this (but using your name): Gustav Mahler First print statement ESecond print statement Gustav Mahler EStill the second print statement Gustav Mahler Third and fourth print statements 2. Write a program to print your name and address. 3. Write a program that converts your age in years to days and displays both values. At this point, don't worry about fractional years and leap years. 4. Write a program that produces the following 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 named jolly() that prints the "jolly good" message once, and one named deny() that prints the final line once.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,