CSE 1310 -- Lec 7

CSE 1310 -- Lec 7 - Variables Variables are names locations...

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

View Full Document Right Arrow Icon
Variables Variables are names locations in the computer's main memory. Each location can store exactly one value at a time. The type of the Value that is stored depends on the variable's declaration. There are four ways to give a value to a variable in CL Assign a value through an assignment statement a = 7 Give variable initial value at declaration count = 0; Read a value as input scanf(“%d”, &count); Pass the value to a parameter in a function What is the product of 6 * 7?? if (a == 42); printf(“correct answer”); Assignment Statements Variable = expression; Assignment operator is = The type of the value produced by the expression should be the same as the type of the variable. Integers The int data type is used to store integers. Due to the size of memory locations, only a fixed range of integer values can be stored. This range must include at least the values -32768 to 32768; however this range may differ for various compilers. \ Sample
Background image of page 1

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

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

Page1 / 3

CSE 1310 -- Lec 7 - Variables Variables are names locations...

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

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