Networking Chapter 10 Homework Linux When She Tries Compile A program Called First start c Using GCC First start c She

subject Type Homework Help
subject Pages 7
subject Words 380
subject Authors Michael Palmer

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
1
Guide to UNIX Using Linux Fourth Edition
Chapter 10 Solutions
Answers to the Chapter 10 Review Questions
1. A new programmer whom you are training is writing a C program and he wants to place comment
lines in the program. Which of the following characters should be used at the beginning and end of
the comments?
2. You’ve written a C program, but are now getting an error message about the use of standard input
and output statements when you compile the program. Which of the following might be the cause?
3. Which of the following is in the proper format for a character constant? (Choose all that apply.)
4. Which of the following are performed by functions in the C library? (Choose all that apply.)
5. A daemon is a _____________..
6. A colleague of yours is just learning to use the C compiler in Linux. When she tries to compile a
program called firststart.c using gcc firststart.c she is expecting the executable file to have the
name firststart, but there is no firststart file. What is the executable file’s name?
7. You have written a C program using the variables num, enum, sum, and long. When you compile
the program you get an error message about using a variable the compiler finds unacceptable.
Which of the following is likely to be the problem?
8. Which of the following are examples of data types in the C language? (Choose all that apply.)
9. Which of the following is the right way to use the string constant, Enter your ID:, in the C
language?
10. Which of the following functions must be in a C program? (Choose all that apply.)
11. Which of the following statements enables you to print File updated on the screen when a C++
program is finished?
12. Which of the following are important characteristics of C++ programming? (Choose all that
apply.) Answer: b. object-oriented programming and c. use of classes for specialized
page-pf2
2
13. Your program to calculate values in physics requires working with positive and negative whole
numbers between -14,242 and 12,528. What data types would you use to work with these numbers
in a C program?
14. In your C program, you want to use a while loop and decrement the value, counter, each time the
program goes through the while loop. Which of the following operators enables you to decrement
the value in counter?
15. Which of the following functions is used to open a file in the C language?
16. What started as a simple C program has now turned into several program modules as you have
refined it over the past several months. The problem is that now you do not always remember
which modules you have changed at what time. What should you do?
17. What compiler is started by using the g++ command?
18. The programmer you are training wants to write code to determine when the end of a file has been
19. Your C++ program needs to access the system date in different ways. Which of the following
enables you to do this?
20. Which of the following is an acceptable way to insert a comment line in a C++ program? (Choose
all that apply.)
21. What character shows that you are starting a block of code in the C and C++ languages?
22. What is an automatic variable?
23. Name a function that enables you to read the contents of a file and another function that enables
you to write to the file in the C language.
24. What are three examples of looping logic structures that can be used in the C language?
25. Most programmers have to do some debugging of a C or C++ program at some point. Suggest a
series of steps to follow when debugging a program.
page-pf3
3
Hands-On Projects Tips and Solutions for Chapter 10
Project 10-1
In this project, students create a simple C program to get their feet wet.
Project 10-2
This project enables to students to create a C program that uses an if-else statement.
Project 10-3
In this project, students create a C program using a for loop
Project 10-4
.
For this project, students write a program that contains functions that accept arguments and return a
value.
Project 10-8
In this project students use scanf() in a C program to accept input from the keyboard.
Project 10-9
Projects 10-9 and 10-10 are designed to enable students to put together their introduction to C
programming to write programs for encoding and decoding information in a file. In Hands-on Project
10-9, students create the encoding programs.
Project 10-10
page-pf4
This project is a continuation of Project 10-10. For this project, students create the decoding programs.
Next they create the make files for the encoding and decoding programs. Finally, students run their
new programs to test them.
Project 10-11
Discovery Exercises
Students should compile each program they write and test it. For example, to compile a C program they
should enter gcc sourcefile -o executablefile and to compile a C++ program, they should enter g++
sourcefile -o executablefile. To run an executable file, type ./ plus the file name and press Enter.
1. Write a C program called fedora.c that displays the line “Fedora is a version of Linux.”
}
2. Create a simple C program which declares the variable number as a local variable that is an
integer.
{
}
3. Modify the rain.c program you created in this chapter so that the total of all inches of rain when
added together is 136 inches.
page-pf5
4. Write a program in which a prompt asks for your first name and after you enter your first name the
program displays it.
}
5. Write a program in which you enter a number and the program calculates and displays that number
cubed.
}
6. Create a program that enables you to input a positive integer and that will then tell you if it is a prime
number or if it can be divided by 2.
page-pf6
6
7. Create a program in which the user enters the outside temperature in Fahrenheit. If the temperature
is 60 or over, print a comment that states “It is just fine outside.” If the temperature is under 60,
print a comment that states “It’s not so warm outside.”
8. Write a small C++ program that writes to the screen the make and model of the car or bicycle you
own (or one that you wish to own).
9. Rewrite the C program keyboard.c that you created earlier in this chapter to compile as a C++ program.
Answer: Create the following program (students may also add their own comment lines):
page-pf7
7
10. Create a C++ program that tests to see if the file accounts exists and prints a message to say
whether the file exists.

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.