Skip to Content
Absolute Beginner's Guide to Programming, Third Edition
book

Absolute Beginner's Guide to Programming, Third Edition

by Greg Perry
November 2002
Beginner content levelBeginner
432 pages
11h 44m
English
Que
Content preview from Absolute Beginner's Guide to Programming, Third Edition

Declaring Variables

Keeping in mind that no string variables exist in C, declaring variables in C is about as simple as declaring them in Visual Basic. Consider the following section of a main() function:

main()
{
  char initial;
  mt age;
  float amount;

This code declares three variables: initial, age, and amount. They hold three different types of data: a character, an integer, and a floating-point value. These variables are local to the function and cannot be used outside main(). (You can declare variables before main(), and those variables are known as global, but global variables are generally not recommended.)

C does not initialize variables to zero as Visual Basic does. The assignment statement works just as it does in Visual Basic. You can ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Absolute Beginner's Guide to Programming, Second Edition

Absolute Beginner's Guide to Programming, Second Edition

Greg Perry

Publisher Resources

ISBN: 0789729059Purchase book