Problem:
Practice writing printf statements.
You will write several printf statements to achieve the results below, including the line spacing. There is no room for creativity in this assignment. I want you to be able to control your print output to a specification. Use the quote that is given below.
Start your code with (Approximate the number of dashes):
/**/
/* Your Name */
/* Lab 3 */
#include <stdio.h>
#include <stdlib.h>
int main(void)
{ int age = 22; // You must use this variable double average = 246.23689;
- Obviously, your output (shown below) will not say bielr on it.
- I want the line spacing just as it appears below.
- Yes, you may move the starting brace to the end of the line above if you desire.
- Write one printf for each line that appears below.
- Regarding the quote and its attribution, you may do it in either one or two printf statements.
- Do not use a different quote for this assignment.
- When printing the friends age, write the printf so it will only print 2 digits.
- When printing average, you must use both a total width and the after-the-decimal-point value in your conversion specifier.
- Remember to print your name and Lab 3 in the output.
Output:
[[email protected] lab3]> a.out
Ruthann Biel. Lab 3.
Jane went to the store.
My friend is 22 years old.
So many books, so little time.
Frank Zappa
The average = 246.2
The average = 246.237
The average = 2.46e+02
[[email protected] lab3]>
Lab 3. printf practice CSC 60. Fall 2019. Page 2 of 2
Preparing your work for grading:
When all is well and correct, type: script StudentName_lab3.txt Script will keep a log of your session. type: gcc lab3.c to compile the program. type: a.out to run the program. type: exit to leave the session.
PS: If you dont type exit to leave your script session,
you will end up with an empty file.
Turn in your completed session.
Go to Canvas and turn in two files:
- c
- txt
Worth 14 points.
Reading Assignment:
Read the Power Point files named C-3 ControlStructures and C-4 Loops
Mostly you will all know the concepts of the material. You just need to pay attention to how to spell it. I will give everyone a few points for this. There is nothing to turn in.
You should have read these before you start on Lab 4.
Reviews
There are no reviews yet.