0% found this document useful (0 votes)
2 views13 pages

Lecture #5

meow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views13 pages

Lecture #5

meow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

CS100: COMPUTATIONAL

PROBLEM SOLVING
(FALL 2022-23)
Lecture 5
REVISION

2
ASCI/ANSII CODE TABLE
u American Standard Code for Information Exchange (ASCI): 0-127
u American National Standards Institute (ANSI): 0-255

Code Value Type ASCII ANSII


0-31 Control YES YES
Characters
32-126 Printable YES YES
Characters
127 Control YES YES
Characters
128-159 More Printable NO YES
Characters
160-255 More Printable NO YES
Characters

Thanks to:https://simple.wikipedia.org/wiki/ASCII
Thanks to:https://simple.wikipedia.org/wiki/ASCII
Number System

u Revise
Binary, Decimal and Hexadecimal
System
§ Details will be covered in a tutorial
ASCI USAGE EXAMPLE IN C++

u ‘\x’ escape sequence denotes a hexadecimal


ASCI/ANSI code

§ cout << ”\x41”; // A will be printed


§ cout << ”Hello\x9\x9World”; // Hello World output
TODAYS TOPICS:

u Introduction to variables & Data Types


HELPFUL READINGS:

u Cay Horstmann:
§ Chapter 2: 2.1,2.3 (partial)
CHAPTER 2: FUNDAMENTAL
DATA TYPES
COMMENTS IN PROGRAM
u Do use comments in your programs; Programs
with comments may earn you more marks!

u ‘//’ delimiter used for comments

Examples:
§ cout << ”\x41”; // A will be printed
§ cout << ”Hello\x9\x9World”; // Prints Hello World
USING VARIABLES IN A PROGRAM

u Write a program that inputs a name


and print Hello with the name.
USING VARIABLES IN A PROGRAM
u Write a program that inputs a name and print
Hello with the name.
Hello_name.cpp
Examples Program
1 #include <iostream>
2 #include <string>
3 using namespace std;
4
5 int main()
6 {
7 string name; // name var. declared
8 cin >> name; //input name like Sher
9 cout<<"Hello”<<name<<endl;//Hello Sher printed
10 return 0;
11 }
USING VARIABLES IN A PROGRAM
u String variables holds strings
§ string name;\\declares name as string type
u Note: also include <string> library

u Integer variable can hold an integer value


§ integer cars;\\declares cars as integer type

These statements are called as declaration


statements

You might also like