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
(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.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Understanding C language data types3m 4s
-
Declaring variables2m 49s
-
Working with variables2m 55s
-
Exploring the printf() function3m 4s
-
Using constants2m 53s
-
Challenge: Make variables and constants47s
-
Solution: Make variables and constants1m
-
Understanding variable scope3m 8s
-
Making new data types3m 24s
-
Specifying characters and strings3m 17s
-
Specifying integers and real numbers4m 14s
-
Typecasting a variable3m 11s
-
Challenge: Basic I/O1m 10s
-
Solution: Basic I/O1m 35s
-
-
-
-
-