The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 327 Weeks Ago, 4 Days Ago |
| Questions Answered: | 12843 |
| Tutorials Posted: | 12834 |
MBA, Ph.D in Management
Harvard university
Feb-1997 - Aug-2003
Professor
Strayer University
Jan-2007 - Present
EE140 Intro to Programming Concepts for Engineers Lab 10 Please turn in the assignment electronically, as usual. Turn in a tar archive of a directory called
assignment_10; turn in code and executables for the remaining problems named question1.txt,
question2.c, question2.out, etc. Make a compressed tarball of the directory, call it LastnameFirstname_lab10_XXXX.tar.gz
and copy it to my dropbox.
1. Write a printf or scanf statement for each of the following:
a. Print 200 with and without a ‘+’ sign.
b. Print 1.234 in a 9-digit field with preceding zeros.
c. Read characters into array s until the letter p is encountered.
d. Read a time of the form hh:mm:ss, storing the parts of the time in the integer
variables hour, minute, and second. Skip the colons (:) in the input stream. Use the
assignment suppression character.
e. Repeat (d) without using the assignment suppression character.
2. Write a program that reads a whole line into a string variable exactly as it is typed (including
spaces) up until the newline character.
3. Write a brief (one sentence) answer to each of the following questions:
a. What is meant by field width control in relation to printf()’s display? How is it
specified?
b. What happens if printf()’s output does not fit within a specified width? Will you get
errors?
c. What do the following statements display?
printf( "%12d%012d\n", 5, 5);
printf( "%12f%012f\n", 23.0, 23.0);
printf( "%-5d%-5.3f\n", 500, 223.4566);
4. Using a loop running on Celsius values starting at 10.0 and decrementing by 5 each iteration
to display the following data in exactly the format shown, where F = 1.8C+32. There are
exactly six spaces left of the capital C in “Celsius” Celsius
+10.0
+5.0
+0.0
-5.0
-10.0
-15.0
-20.0
-25.0 Fahrenheit
+50.00
+41.00
+32.00
+23.00
+14.00
+5.00
-4.00
-13.00
-----------