lecture_1a_vars_data_types_formatted_IO (2)

lecture_1a_vars_data_types_formatted_IO (2) - 1 Beginning...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Beginning Concepts for Problem Solving in C: variables, data types, operators, and formatted IO BJ Furman 30JAN2010 2 The Plan for Today The concept of data Constants vs. variables Variables naming rules data types Operators and their precedence Practice writing and executing C programs in ChIDE 3 Learning Objectives Following completion of todays lab, you should be able to: List and explain the basic kinds of data Distinguish between variables and constants Declare integer, floating point, and character variables List the basic data types used in C Identify and explain commonly used operators in C Use C operators correctly according to their placement in the hierarchy chart Write and execute simple C programs in ChIDE Set up and evaluate expressions and equations using variables, constants, operators, and hierarchy of operations 4 What and Why? Data => pieces of information we deal with in the problem solving process Why is it important to know about data types? Need to know about data types to effectively use a programming language Its all just bits the lowest level! What would you rather work with int i; float r; i = 3; r = cos(2*i*PI); or 00000010 10000000 00000000 00000110 10000010 10000000 01111111 11111100 11001010 00000001 00000000 00000000 etc. 5 Kinds of Data (simplified view) The basic kinds of data that we will mostly use: Numeric Integers: Real (floating point) numbers: Character (are enclosed by single quotes in C) All letters, numbers, and special symbols Ex. A, +, 5 String (are enclosed by double quotes in C) Are combinations of more than one character Ex. programming, ME 30 Logical (also called Boolean named after George Boole an English mathematician from the early 1800s) True or False (1 or 0) 6 Kinds of Data - Practice Data Type 1. 17 2. George 3. 2.35 4. 0.0023 5.-25 6. m 7. 4.32E-6 8. 185.3 9. 10. 1 If kind is numeric, then is it an integer or a floating point number? 7 Constants and Variables Constant A data element that never changes in your program 5, 62.37, 4.219E-6, record_string, $ i = j + 7; /* which one is the constant? */ first_letter = a; /* which one is the constant? */ Variable A data element that can take on different values Its name represents a location (address) in memory i = j + 7; /* which are variables? */ second_letter = b; /* which is the variable? */ Values are assigned using a single equal sign ( = ) Read the statement: i = j + 7; NOTE!! Variables in C must be declared before they can be used! 8 Declaring Variables and Data Types Variables must be declared before they can be used Gives info to the compiler about: How many bytes of memory to set aside How to interpret the bytes (data)...
View Full Document

Page1 / 54

lecture_1a_vars_data_types_formatted_IO (2) - 1 Beginning...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online