From the course: C Essential Training

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Solution: Basic I/O

Solution: Basic I/O - C Tutorial

From the course: C Essential Training

Start my 1-month free trial

Solution: Basic I/O

(upbeat music) - [Instructor] Here is my solution which builds upon my solution from the previous chapter. You can see the comments are all in place but some new statements have been added. Line seven declares integer variable rows, I hope you didn't forget this step. Input must be stored somewhere. Line 10 has a printf statement outputting the user prompt, How many rows (18 max)? No new line is added here, this is because users expect this type of prompt on a text screen. Next comes this scanf statement, it uses %d as the placeholder for a decimal integer value and then &rows is prefixed by an ampersand. This is how the scan function works and how it's been configured for integer input in various movies in this chapter. After the variable is input and assigned a value, the printf statement at line 15 outputs the value. Build and run. And let's see we want 15 rows. The computer will dutifully process 15 rows.…

Contents