The instructor reviews a solution for the challenge, pointing out the multiple ways the code can be crafted. As with many C programs, multiple solutions arise for a typical problem. There are no perfect solutions, only different approaches.
(upbeat music) … - [Instructor] For my solution I declared variables … a and c as integers, but variable b is a float, … that's because it's expression … shown at line 11 involves division. … And in the challenge Source Code, … I set a hint at the printf statement in line 16 … using the %f place-holder … which indicates a floating-point value, … I hope you picked up on this hint. … Assignments in math are done starting at line 10, … a is assigned 15, b is assigned … the value of a divided by two. … And if you didn't write 2.0 here, … at floating-point value the result will be wrong, … as the compiler interprets two by itself as an integer. … And variable c is assigned to the value variable b … multiplied by four which will be an integer value. … I'll build and run my solution. … a is 15, b is seven and a half and c is 30. … If you obtained this results, you passed the challenge, … but if you saw only seven as a result for variable b … you probably didn't specify 2.0 in the Source Code file, …
- Writing your first C program
- Working the C development cycle
- Adding comments to code for clarity
- C language data types
- Declaring variables
- Making new data types
- Typecasting variables
- Using math, assignment, and logical operators
- Creating for and while loops
- Nesting loops
- Creating functions
- Returning values from functions
- Passing arguments to functions
- Creating recursive functions
Skill Level Intermediate
C: Data Structures, Pointers, and File Systemswith Dan Gookin2h 57m Intermediate
1. The Fundamentals of C
2. Variables and Values
3. Operators and Math
4. Decisions and Loops
Next steps1m 38s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.