Cpp Keywords and Functions-Introduction to Programming-Lecture Slides, Slides of Computer Programming

Dr. Mehandi Nandakumar delivered this lecture at Baddi University of Emerging Sciences and Technologies for Introduction to Computer Programming course. Its main points are: Basic, Data, Types, Bit, Width, Range, Interchange, American, Standard, Code, Information, ASCII

Typology: Slides

2011/2012

Uploaded on 07/13/2012

ekbaal
ekbaal 🇮🇳

3

(1)

30 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CP
Lecture 3
Fall 2011
September 16, 2011
Ghufran Ahmed
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Cpp Keywords and Functions-Introduction to Programming-Lecture Slides and more Slides Computer Programming in PDF only on Docsity!

CP Lecture 3Fall 2011September 16, 2011Ghufran Ahmed

C++ Keywordsasm dynamic_cast^ new^

template auto^ else^

operator^ this bool^ enum^

private^ throw break^ extern^

protected^ true case^ false^

public^ try catch^ float^

register^ typedef char^ for^

reinterpret_cast^ typeid class^ friend^

return^ union const^ goto^

short^ unsigned const_cast^ if^

signed^ using continue^ inline^

sizeof^ virtual default^ int^

static^ void delete^ long^

static_cast^ volatile do^ mutable^

struct^ wchar_t double^ namespace

switch^ while

-^ A number code used by C++ to store charactersinternally (it’s easy for a computer to store numbers)• Each character corresponds to a binary code• Most commonly used binary code is ASCII(American Standard Code for InformationInterchange)^ Character^ ASCII Code

Integer Equivalent% (^0100101 373 0110011 51) A (^1000001 65) a (^1100001 97) b (^1100010 98) c 1100011 99

-^ Larger character sets e.g. Unicode•^ Exercise: Use^ char^ as a small

int^ in a program

Type Modifiers• signed• unsigned• short• long

break^ for^

while

Control Keywordscase^ gotocontinue^ if default^ returnelse^ switch

CP Lecture 3Fall 2011September 16, 2011Ghufran Ahmed

/ This program contains two functions: main()and myfunc()./#include <iostream.h>void myfunc(); // myfunc's**

Protoype int main(){ cout << "In main()";myfunc(); // call myfunc()cout << "Back in main()";return 0;} void myfunc() // myfunc’s

Definition { cout << " Inside myfunc() ";}

Function Prototype void myfunc();^ //^ myfunc's^ Protoype • Like variable declaration; tells the compiler about thereturn type of the function and the number and typeof parameters it needs from the calling function: return_type^ FunctionName ( parameter list

-^ So, place prototypes before

main()

  • main()^ is predefined in C++ and does not need aprototype•^ Can’t the compiler look ahead and get definitions?•^ Prototype can be omitted if whole function placedbefore it is called; is that a good practice?

Library Functions• Pre-written functions in libraries that you can use• Just include the proper header file• Compiler gets prototype from the header file andsearches appropriate libraries itself to get functiondefinition• e.g. math library has mathematical functions in it #include <iostream.h>#include <math.h>^ //or int main(){ cout << sqrt(9.0);return 0;}