






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This document from lecture 5 of cs 192, fall 2011, covers the concepts of constants and variables in c++ programming. Constants are specific values of various data types, including character, numeric, hexadecimal, octal, and string constants. The document also explains the difference between character and string constants and the use of backslash constants. The lecture then moves on to discuss variables, which are needed to store information, and their properties, such as where they are located, their values, and their types. The document also covers the scope of variables, including local, global, block, function, file, and program scopes.
Typology: Slides
1 / 10
This page cannot be seen from the preview
Don't miss anything!







1
2
4
#include
<iostream.h>
int
main() {
char
ch
//assign
code
for
to
c
int
number
ch;
//store
same
code
in
an
int
cout
“The
code
for
ch
is
in
‘\n’;
cout
“Add
one
to
the
character
code\n”;
ch
ch
in
ch; cout
“The
code
for
ch
is
in
endl;
return
5
age; age
double
radius
7
8
#include
<iostream.h>
void
func() { int
x;
local
to
func()
x^
cout
x;
displays
} int
main() { int
x;
local
to
main()
x^
func();cout
"\n";
cout
x;
displays
return
10
#include <iostream.h>int i = 2;
//global
void func(){
cout << i << endl;int i = 3;
//local
cout << i << endl; } int main(){
cout << i << endl;func();cout << i << endl;int i = 5;cout << i << endl;return 0; }