148
বাংলা ǯদেখ ǯকউ কিরসেন ভয় বɆনীেত ইংেরজী আেছ িসিপিপ পিরগণনা c++ programming িনউটন ম. আ. হািকম

C++

Embed Size (px)

Citation preview

  • c++ programming

    . .

  • (Developing c++ Programs) . (Online Editing Compilation) . . . . . . . (Offline Editing Compilation) . . . . . .

    (Program Structure) . (Wishing Program) . . . . . . . . . . . . . . -- (Detailing Program) . . . . . . . . . . . . (Writing Program Comments) . . . . . . . (Spacing and Indentation) . . . . . . . . . (Exercise Problems) . . . . . . . . . . . . . . . . (Computing Terminologies) . . . . . . . . . . . .

    (Variables and Constants) . (Using Variables) . . . . . . . . . . . . . . . . . . . (Using Constants) . . . . . . . . . . . . . . . . . . (Variable Declarations) . . . . . . . . . . . . . . . . (Initial Assignment) . . . . . . . . . . . . . . . . (Exercise Problems) . . . . . . . . . . . . . . . . (Computing Terminologies) . . . . . . . . . . . .

    (Naming Identifiers) . (Well-formed Names) . . . . . . . . . . . . . . . . . . (Meaningful Names) . . . . . . . . . . . . . . . . . (Case Sensitivity) . . . . . . . . . . . . . . . . (Reserved & Key Words) . . . . . . . . . . . . (Exercise Problems) . . . . . . . . . . . . . . . . (Computing Terminologies) . . . . . . . . . . . .

    (Input and Assignment) . (Data Input) . . . . . . . . . . . . . . . . . . . . . . (Input Prompt) . . . . . . . . . . . . . . . . . . . . . (Value Assignment) . . . . . . . . . . . . . . . . . . - (Value Swapping) . . . . . . . . . . . . . . . . .

  • . (Assignment Left and Right) . . . . . . . . - (Self-Referential Assignment) . . . . . . . . . (Exercise Problems) . . . . . . . . . . . . . . . . (Computing Terminologies) . . . . . . . . . . . .

    (Mathematical Processing) . (Unary Operators) . . . . . . . . . . . . . . . . . . (Binary Operators) . . . . . . . . . . . . . . . . . . (Division and Remainder) . . . . . . . . . . . . (Assignment Operator) . . . . . . . . . . . . . (Compound Assignment) . . . . . . . . . . . . . (Increment and Decrement) . . . . . . . . . . (Comma Operator) . . . . . . . . . . . . . . . . . . (Precedence Order) . . . . . . . . . . . . . . . . (Mathematical Problems) . . . . . . . . . . . . . cmath (Header File cmath) . . . . . . . . . . . . . . . . (Exercise Problems) . . . . . . . . . . . . . . . . (Computing Terminologies) . . . . . . . . . . . .

    (Conditional Programming) . (If Then Else) . . . . . . . . . . . . . . . . . . . . (Relational Operators) . . . . . . . . . . . . . . . - (If-Else Ladder) . . . . . . . . . . . . . . . . . . . . - (Nested If-Else) . . . . . . . . . . . . . . . . . . (Dangling Else) . . . . . . . . . . . . . . . . . . . . . (Compound Statement) . . . . . . . . . . . . . . . (Error Detection) . . . . . . . . . . . . . . . . . . (Boolean Connectives) . . . . . . . . . . . . . . . , , (Boolean, Integer, Float) . . . . . . . . . . . . . (Boolean Algebra) . . . . . . . . . . . . . . . . . . (Boolean Equivalence) . . . . . . . . . . . . . . . . . (Truth Table) . . . . . . . . . . . . . . . . . . . . . . (Boolean Simplification) . . . . . . . . . . . . . . , , (Ladder, Nesting, Connectives) . . . . . . . - (If-Else Optimisation) . . . . . . . . . . . . . (Ternary Operator) . . . . . . . . . . . . . . . . . (Switch Cases) . . . . . . . . . . . . . . . . . . . . . (Nested Switch Cases) . . . . . . . . . . . . . (Switch Cases Breaks) . . . . . . . . . . . . . . - (Swtich Cases If Else) . . . . . . . . . . . . (Global & Local Variables) . . . . . . . . . . (Exercise Problems) . . . . . . . . . . . . . . . . (Computing Terminologies) . . . . . . . . . . . .

  • . (Wishing Program) . . . . . . . . . . . . -- (Detailing Program) . . . . . . . . . . . . (Commenting in Programs) . . . . . . . . . (Spacing in Programs) . . . . . . . . . . . (Inspiring Programming) . . . . . . . . . . . . (Program Drawing Designs) . . . . . . . . . (Variables in Programs) . . . . . . . . . (Constants in Programs) . . . . . . . . (Program Declaring Variables) . . . . . . . (Arithmetic Program) . . . . . . . . (Celcius to Fahrenheit) . . . . (Fahrenheit to Celcius) . . . . (Convert Time to Seconds) . . . . . . . . (Programs with Data Input) . . . . . . . . (Program with Input Prompt) . . . . . . . (Input Output Program) . . . . . . . . . (Input Process Output) . . . . . . . . . . . . (Input Order Reverse Order) . . . . . (Result Processing Program) . . . . . . . (Arithmetic Positive Negative) . . . (Arithmetic Plus Minus Times) . . . . (Arithmetic Division Operation) . . . (Arithmetic Remainder Operation) . (Distance Between Two Points) . . . . . . (Arithmetic Series Problem) . . . . . . . . . (Binary Operation Results) . . . . . . . . (Triangle's Area From Sides) . . . . . . (Time in Seconds) . . . . . . . . . . . . . . (Triangle's Angles From Sides) . . . . . . . (Adding Two Times) . . . . . . . . . . . . . . . . (Simultaneous Equations) . . . . . . . . . . . (Solving Motion Equations) . . . . . . . . . (Program from Pseudocode) . . . . - - (Pass Fail Star Marks) . . . . . . . . .

  • . (Leap Year Determination) . . . . . . . . . . . . . . (Solving Quadratic Equations) . . . . . . . (Lucky & Unlucky Numbers) . . . . . . . (Trigonometry with Menu) . . . . . . . . . (Menu with Nested Switch) . . . . . . . . (Using Local & Global Variables) . . - (Small and Big of Three Numbers) . . . . . (Median of Three Numbers) . . . . . . . . . . (Three Numbers in Ascending Order) . . . . (Letter Grades from Numbers) . . . . . . . . . . (Quadrant of a Point) . . . . . . . . . . . . . . (Bengali Month Names) . . . . . . . . . . . . . . (Largest of Five Numbers) . . . . . . . . . . (Weekly Wage Calculation) . . . . . . . . .

  • (Developing Programs)

    (programmer) (program) , ,

    , , , ,

    , ,

    (computer) (execution) (program) , (edit) (programming language) - (executable) , , -

    (compile) (machine language) (execute)

    . (Online Editing Compilation)

    (online) (editing and compilation) cpp.sh (webpage) - (internet browser) - cpp.sh (browser) (Editor Area) , ,

  • .. (Online Editing Compilation)

    (run button) - (click) (compile) (execution) - " " Please Wait Compiling

    (cancel button) - (tabs) , (options tab) (compilation tab)

    (error) - Compilation successful (execution tab) (input and output) (cancel button) (stop button), (option tab) (run button)

    (options tab) - (editing) (execution) cpp.sh

  • .. (Online Editing Compilation)

    (program) - , (execution tab) - What is your name? gonimia

    (enter) , Hello, gonimia! - What is your name? (inputprompt) gonimia (input) Hello, gonimia! (output)

    / / Example program#include #include

    i n t main ( ){

    std : : s t r i n g name ;std : : cout

  • .. (Offline Editing Compilation)

    (options tab) (option) , (program) (editing), (compile) (execute)

    . (column) (standard) , , - c++14

    . , (compile) (compiler) Many (-Wall)

    . (optimisation) - (program) (compiler) (compile)

    (execute) , - ,

    Full (-O2)

    . (standard input) (interactive) (keyboard) (input) (none) - (text)

    (program) (keyboard)

    . (Offline Editing Compilation)

    codeblocks -

    http://www.codeblocks.org/ codeblocks

    (software)

    http://www.codeblocks.org/downloads

    (user manual)

    http://www.codeblocks.org/user-manual

    (install) (video)

    https://www.youtube.com/watch?v=zOGU8fC3bvU

  • .. (Offline Editing Compilation)

    https://www.youtube.com/watch?v=3B4hPHZNtNw

  • (Program Structure)

    (computer) (executable) (instruction) - (program) (c++) -

    (editor) (software) cpp.sh (webpage) - (compiler) (compile) (code) (run) (execution) (console) (monitor) (output) (keyboard) (mouse) (input) - (console) (input) (keyboard and mouse) (output) (monitor) (console) (input) (console) (output)

    . (Wishing Program)

    (c++) (program) (run)

    - (compile) (execution) (run) (output) (statement) shuvessa nin cout

  • .. (Wishing Program)

    cout (statement) -

    .: (Wishing Program)#include using namespace std ;i n t main ( ){

    cout

  • .. -- (Detailing Program)

    cout endl std: : (compile) , (error) (message) (compile-time)

    (function) main main (parameter) , main( ) , main (integer) , main int return 0; main ? main 0 , , 0

    {} (block) (body)

    main cout return , (semicolon) ; ;

    ,

    . -- (Detailing Program)

    (program) - -- (string) (number)

    .: -- (Detailing Program)#include #include

    using namespace std ;

    i n t main ( ){

    cout

  • .. (Writing Program Comments)

    (output)amar nam goni miaamar b a r i bograami t h a k i dhakaiamar boyos 20 bosoramar r e s u l t gpa 3 . 99

    -- - cout cout " " (string)

    endl end line cout ,

    cout

  • .. (Writing Program Comments)

    , , ,

    .: (Commenting in Programs)/ / l i s t of header f i l e s needed for t h i s program .

    #include #include

    using namespace std ; / / use the std namespace

    i n t main ( ){

    / / Subtract 20years from 2015 to get b i r t h y e a r

    cout

  • .. (Spacing and Indentation)

    (code) // list of header files needed forthis program , - #include #include // we will use thestd namespace using namespace std; (code) / - / , return EXIT SUCCESS;

    , (blockcomment)

    (comiler) (editor) (unicode) , - execution) ,

    ! , -

    ? ,

    . (Spacing and Indentation)

    (program) ? ?

    .: (Spacing in Programs)#include #include

    using namespace std ;

    i n t main ( ){

    cout

  • .. (Spacing and Indentation)

    (line comment) # - (compiler) (software) - (preprocessor) , - (preprocessor)

    #include / /

    (preprocessor) (compiler) ; (semicolon) (block) } - , - , - (code) , (space) -

    #include #include using namespace std ; i n t main ( ) { cout

  • .. (Exercise Problems)

    , cout return , ?

    (indentation)

    , , -

    (keyboard) (tab) , (space) ,

    , ,

    . (Exercise Problems)

    :

    . (program) ? ?

    . ?

    . (console) ? (input) (output) ?

    . (header file) ? iostream cstdlib ?

    . (namespace) ?

    . main return 0; returnEXIT SUCCESS; ?

    . (indentation) ? - ?

    . (comment) ? (comment) - ? (line) (block) ?

    . (program) ?

  • .. (Exercise Problems)

    ) start( ) ) system() ) main() ) program()

    . main ?

    ) 1 ) 0 ) 1 )

    . (block) ?

    ) { } ) < > ) ( ) ) begin end

    . (statement) ?

    ) . ) ; ) : ) ,

    . (comment)?

    ) / / ) ) / / ) { }

    :

    . (output)

    (comment)

    tomar boyosh noy bosor .porigonona shikhte chao ?porigonona k i sohoj na !

    . 8 ,

    (comment)

  • .. (Exercise Problems)

    : - ,

    . (output)

    (comment)

    tomar boyosh noy bosor .porigonona shikhte chao ?porigonona k i sohoj na !

    .: (Inspiring Programming)#include / / cout #include / / EXIT SUCCESS

    using namespace std ; / /

    i n t main ( ){

    / / cout

  • .. (Computing Terminologies)

    , ,

    .: (Program Drawing Designs)#include / / cout #include / / EXIT SUCCESS

    using namespace std ; / /

    i n t main ( ){

    / / cout

  • .. (Computing Terminologies)

    (output device)

    (message)

    (function)

    (statement)

    (software)

    (block)

    (block comment)

    (string)

    (console)

    (input)

    (body)

    (header file)

    (compiler)

    (compile)

    (compile-time)

    (code)

    (number)

    (editor)

    (line comment)

  • (Variables and Constants)

    (variable) (value) (constant) (data) (directly) (indirection)

    . (Using Variables)

    , - (program) (variable) , (output)

    (output)

    #include #include

    using namespace std ;

    i n t main ( ){

    cout

  • .. (Using Variables)

    (output)

    , , 5 6 , ,

    .: (Variables in Programs)#include #include

    using namespace std ;

    i n t main ( ){

    i n t doirgho ; / / i n t prostho ; / / i n t khetrofol ; / / i n t porishima ; / /

    doirgho = 5 ; / / prostho = 3 ; / /

    / / khetrofol = doirgho prostho ;

    / / porishima = 2 ( doirgho + prostho ) ;

    / / cout

  • .. (Using Variables)

    , , , doirgho, prostho, khetrofol, porishima length, width, area, perimeter - l , w, a, p , x, y, z, a, b, c -

    , (semantic) (syntax)

    int - integer integer int , int float float int float , int

    int doirgho; doirgho int doirgho; (variable declaration) - (statement) , , doirgho = 5; = doirgho (value assign) 5 doirgho 5 prostho 3

    , - , ,

    - doirgho 5 5 , doirgho

    5 6 , 6 , doirgho prostho

    (warningmessage) ,

    (output) "" (string) khetrofol "" khetrofol khetrofol , 15 ""

  • .. (Using Constants)

    , porishima porishima porishima

    . (Using Constants)

    , - (program) (integer)

    , (fraction) (floating-point number) float (constant) , ,

    float

    .: (Constants in Programs)#include #include

    using namespace std ;

    i n t main ( ){

    i n t bashardho = 5 ; / /

    f l o a t const pai = 3 . 1415 ; / /

    / / i n t khetrofol = pai bashardho bashardho ;

    / / cout

  • .. (Using Constants)

    (variable) (constant) , !

    main() {} return EXIT SUCCESS; cout

  • .. (Variable Declarations)

    (variable) , (assign) (constant) , (assign) (compiler) (error message) ,

    , khetrofol , -

    int . int 78 78.5375 78.5375 , khetrofol (assign) - , (truncation)

    78 khetrofol int float 78.5375

    : ) (variable) (constant) ; ) (initial assignment), ) , int float ,

    , , , 78.5375 78

    . (Variable Declarations)

    (variable) (declaration) , - , (datatype) , int float doirgho, prostho, porishima , int

    i n t doirgho ; / / i n t i n t prostho ; / / i n t i n t porishima ; / / i n t

    int , (statement) int , , (comma)

    i n t doirgho , prostho , porishima ; / / i n t

  • .. (Initial Assignment)

    , int float (statement)

    i n t bashardho ; / / i n t f l o a t khetrofol ; / / f l o a t

    porishima bashardho float

    f l o a t bashardho , khetrofol ; / /

    (program) , ,

    int (statement) float -

    i n t doirgho , prostho , porishima ; / / , , f l o a t bashardho , khetrofol ; / /

    . (Initial Assignment)

    (variable) (declaration) - (initial value) (assign)

    doirgho = 6 ;prostho = 3 ;bashardho = 5 ;

    , , (comma)

    doirgho = 6 , prostho = 3 , bashardho = 5 ;

    i n t doirgho = 6 , prostho = 3 , porishima ;f l o a t bashardho = 5 , khetrofol ;

    (program) , , , , ,

    , (compiler)

  • .. (Initial Assignment)

    doirgho

    cout

  • .. (Exercise Problems)

    doirgho, prostho, bashardho , , - , , :

    i n t doirgho = 6 , prostho = 3 , porishima ;f l o a t const pai = 3 . 1415 ;f l o a t bashardho = 5 , khetrofol ;

    porishima = doirgho prostho ;khetrofol = pai bashardho bashardho ;

    . (Exercise Problems)

    :

    . (program) ?

    . (program) ,

    . (variable) (value assign) ?

    . (variable) (constant) ?

    .

    .

    . ?

    . (variable) (initial value assignment) ?

    . (variable) ?

    . (constant) , ?

    . (float) int ?

    :

    . int , float 10, 15, 12.6

  • .. (Exercise Problems)

    . 89 56 , ,

    . c f , f = 9c/5+32 30 , ? float

    . f c , c = 5(f 32)/9 76 ,

    ? float

    . 7 15 39 60 60

    : - ,

    . int , float 10, 15, 12.6

    .: (Program Declaring Variables)#include #include

    using namespace std ;

    i n t main ( ){

    i n t purnok1 , purnok2 ; / / f l o a t vognok ; / /

    purnok1 = 10 , purnok2 = 15 ; / / vognok = 12 . 6 ; / /

    cout

  • .. (Exercise Problems)

    (output)purnok dut i 10 15vognok holo 12 . 6

    . 89 56 , ,

    (header) , std , main -

    , include, namespace,main, return , main return

    .: (Arithmetic Program)i n t prothom = 89 , d i t i y o = 56 ;

    i n t j o g f o l = prothom + d i t i y o ;i n t biyogfol = prothom d i t i y o ;

    cout

  • .. (Computing Terminologies)

    .: (Fahrenheit to Celcius)f l o a t f = 76 , c = 5 ( f 32) / 9 ;

    . 7 15 39 60 60

    .: (Convert Time to Seconds)i n t ghonta = 7 , minit = 15 , sekend = 39 ;i n t const ghontaiMinit = 60 , miniteSekend = 60 ;

    i n t motMin = ghonta ghontaiMinit + minit ;i n t motSek = motMin miniteSekend + sekend ;

    . (Computing Terminologies)

    (initial value)

    (assign)

    (declaration)

    (variable)

    (constant)

    (fraction)

    (value)

    (value assign)

    (floating-point)

    (var declaration)

  • (Naming Identifiers)

    (program) (variable), (constant), (function)

    . (Well-formed Names)

    - , (syntax) - main

    (function) , (identifier)

    (identifier) ) A-Z, ) a-z, ) 0-9 ) (underscore) 0-9 , A-Z a-z (underscore) -

    (program) (compile) cpp.sh , c++

  • .. (Meaningful Names)

    12 12cholok amar cholok (space) ama;cho+k , ,

    (program) ? ! (compiler) (error message) , -

    p P abc ABC Abc bAc a1bc , a1Bc a bc abc A b c

    amar cholok , amar Cholok , amarCholok123 , ,

    amar125cholok ,

    . (Meaningful Names)

    (identifier) , (semantic) ,

    (variable) (constant)

    (function) (program)

    gonimia1, gonimia2, , radius bashardho r b , ,

    ,

  • .. (Case Sensitivity)

    bashardho1 bashardho2 , bashardhoA bashardhoB (array) , a, b, c, p, q, r , i , j , k, x, y, z

    : ? ? , amar cholok

    , AmarCholok amarCholok

    sum sum jogfol jogfol bijor songkhar jogfol odd number sum Bijor Shongkhar Jogfol , BijorShongkharJogfol bijorShongkharJogfol

    . (Case Sensitivity)

    (case sensitive) ? , ?

    barek i s going homeBAREK I S GOING HOMEBarek I s Going Home

    (variable) (constant) (function), (identifier) - A-Z, a-z, 0-9, -

  • .. (Reserved & Key Words)

    - ,

    ?

    -

    amarcholok , amarCholok , AmarCholok , amar cholok ,Amar Cholok , amarChoLok , AmarChOlOk

    , (program) , amarcholok, amarCholok

    (compile) "amarCholok is not declared" (error message) amarCholok amarcholok

    bashardho Bashardho , , ,

    (program) : AmarCholok,

    , AmArChOlOk, , , !

    . (Reserved & Key Words)

    (reserved word) (key word) ? (variable), (constant) (function) (identifier)

    ? ?

    -

    " ?" , , ,

    " "

  • .. (Reserved & Key Words)

    , , , ! , "

    " ", , " ,

    , , ,

    return, int , float , return (function) , int float (reserved word) (key word) (identifier) - return returnValue ,

    (structured programming) :break, case, char, const, continue, default, do, double, else,enum, extern, float, for, goto, if , int , long, register, short,signed, sizeof, static , struct, switch, typedef, union, unsigned,return, void, volatile , while

    (object-oriented) :class , explicit , delete, friend, inline , mutable, namespace,new, opeator, private, protected, public, this , using, virtual

    (error handling) :catch, noexcept, throw, try

    (logical and bit-wise operators) :bool, and, and eq, bitand, bitor , compl, false, not, not eq,or, or eq, true, xor, xor eq

    (data type) :auto, const cast, decltype, nullptr , dynamic cast,reinterpret cast, static cast , typeid

    (template) :export, template, typename

  • .. (Exercise Problems)

    (compile-time) :static assert , constexpr

    (preprocessor) :if , elif , else, endif, defined, ifdef , ifndef, define, undef,include, line , error, pragma

    : char16 t, char32 t, wchar t

    : alignas, alignof, asm, concept, requires, thread local

    . (Exercise Problems)

    :

    . (identifier) ? ?

    . (identifier)

    . (program) ?

    . ? ?

    . (case sensitive) , ?

    . ? ?

    : (syntactically) (identifier) ? (meaningful) ? (reserved or key word)? ,

    . void

    . MAXENTRIES

    . double

    . time

    . G

    . Sue's

    . return

    . cout

    . xyz123

    . part#2

    . "char"

    . #include

    . a longone

    . xyz

    . 9xyz

    . main

    . mutable

    . max?out

    . Name

    . name

    . name 1

    . Int

    . INT

    . SUM

  • .. (Exercise Problems)

    . sum of numbers

    . firstName

    . Identifier

    . printf

    . int

    . pow

    . $sum

    . num2

    . num 1

    : ,

    . void : ,

    . MAXENTRIES : ,

    . double : ,

    . time : , (library) ,

    . G : , ,

    . Sue's : '

    . return : ,

    . cout : , (library) ,

    . xyz123 : ,

    . part#2 : #

    . "char" : "

    . #include : - (preprocessor)

    . a longone : ,

    . xyz : ,

    . 9xyz : , ,

    . main : ,

    . mutable : ,

    . max?out : , ?

    . Name : , ,

    . name : , ,

    . name 1 : , ,

    . Int : , int

  • .. (Computing Terminologies)

    . INT : , int

    . SUM : , ,

    . sum of numbers : ,

    . firstName : , ,

    . Identifier : , ,

    . printf : , , (library) ,

    . int : ,

    . pow : , , (library) ,

    . $sum : , $

    . num2 : ,

    . num 1 : ,

    . (Computing Terminologies)

    (identifier)

    (underscore)

    (array)

    (structured)

    (programming)

    (structuredprogramming)

    (object-oriented)

    (object orientedprogramming)

    (error handling)

    (logical operators)

    (bit-wiseoperators)

    (data type)

    (template)

    (compile-time)

  • (Input and Assignment)

    (program) (data) ? , , - (input)

    (variable) (assign)

    . (Data Input)

    (program) - (compile) , , - (input)

    (computing problem) , , (program) , (run) ,

    (write) (run)

    , (formula) , (data)

  • .. (Data Input)

    (programmer) ,

    (data) (variable) -

    -

    (input)

    .: (Programs with Data Input)#include #include

    using namespace std ;

    i n t main ( ){

    i n t doirgho ; / / c i n >> doirgho ; / /

    i n t prostho ; / / c i n >> prostho ; / /

    / / i n t khetrofol = doirgho prostho ;i n t porishima = 2 ( doirgho + prostho ) ;

    / / cout

  • .. (Data Input)

    doirgho -, (initial value assign) , doirgho - cin >> doirgho; cin console in

    (input device) (keyboard) (mouse) (output device) (monitor) console console in - (keyboard) (input) cin doirgho (value assign)

    prostho int cin prostho -

    (output) (compile) -

    (screen) , (cursor) , 13 (enter) cin doirgho

    (cursor) 12 (enter) -, cin prostho khetrofol holo 156 porishima holo 50

    (declaration) (input)

    (program segment)

    i n t doirgho , prostho ; / / c i n >> doirgho >> prostho ; / /

    (cursor) , 13 12 (enter) , 13 12

    13 12

    cout

  • .. (Input Prompt)

    cout

  • .. (Input Prompt)

    - (input-output)doirgho koto ? 13prostho koto ? 12khetrofol holo 156porishima holo 50

    cin (screen)

    (cursor) 13 (enter) 12 khetrofol holo 156 porishima holo 50 (cursor) write) (compile) (run) (run)

    (cursor) ,

    cin >> doirgho; cin >> doirgho; cout > doirgho; doirgho doirgho (enter) " ?" ! (input) , (input prompt) (input) "prostho koto? " (input prompt) , ?

    (declaration), (input prompt) , (input) (program segment)

    i n t doirgho , prostho ; / / cout > doirgho >> prostho ; / /

    doirgho o prostho koto? (cursor) 13 12 (enter)

  • .. (Value Assignment)

    , 13 12 ,

    doirgho o prostho koto ? 13 12

    . (Value Assignment)

    (program) (value assign) ? , ? ?

    i n t amar ;i n t tomar = 5 ;

    (variable declare) : amar tomar, int , (initial value) (computer) (memory) " " amar tomar amar tomar (memory) ? , ,

    amar = tomar ;

    tomar amar ? (statement) amar tomar amar 5 - tomar amar

    tomar tomar 5- (assignment) (target) (source) , amar = tomar ,

    (program segment) (output segment) x (initial value) 3, y x+5 3 + 5 = 8 x y x 3 y 8 - x = y 3; x 8 3 = 24, y

    , y , y

  • .. - (Value Swapping)

    (statement) x y , x 24 y 8 x x = y + 3 4; y , x 8 + 3 4 = 20, cout - x 20 y 8 y = x 2; y y = 20 2 = 40, x , x , x

    (program segment)i n t x = 3 ; / / i n t y = x + 5 ; / / cout

  • .. - (Value Swapping)

    : x 13 y 12 x y -! ? , !

    x = 13 ; / / x y = 12 ; / / y

    - : -

    -

    - ,

    .

    . ,

    . ,

    - - - -

    z x y -

    z = x ; / / z 12 x 12 , y 13x = y ; / / x 13 y 13 , z 12y = z ; / / y 12 z 12 , x 13

    x y -

    - , - - - z = x; x z

  • .. (Assignment Left and Right)

    , x ,

    . (Assignment Left and Right)

    (variable) - (lvalue) - (rvalue) ? (assign) = y = x; (target) (source) = , ? = ?

    " , , " ? " , " , " , " ,

    , (memory)

    x = 3; x x (memory) - 3 x x = - x

    - (l-value)

    y = x; y y y = y - x x y , x y x = x - (r-value) ,

    , = ,

  • .. - (Self-Referential Assignment)

    - (l-value) - (r-value) - -, x = 3; 3 3 = x; , (compile)

    "error: lvalue required as left operand of assignment" y+3 = x; , (error), y y + 3 y

    y 3, , x = y + 3;

    y + 3 - x -

    . - (Self-Referential Assignment)

    (program) x = x + 1; (variable) (assignment)= x x + 1 x = x + 1; ?

    x = x + 1 ; / / = ,

    = (equal) = (assignment) x = x + 1; ,

    (assignment) - x = x + 1

    - (self-referential assignment) - (r-value) , - (l-value) ?

    i n t x = 3 ; / / x x = x + 1 ; / / cout

  • .. (Exercise Problems)

    (memory) x - x 3 x= x+1; (execute) x + 1 x 3 x + 1 4 4 - - 4 x , 4 x x 3 4 x = x + 1; -

    x = x 3; x = xx + x + 1; ,

    . (Exercise Problems)

    :

    . (program) ?

    . (data) (input) ? - ?

    . (input prompt) ? ?

    . (variable) (assignment)

    . - - ?

    . = ?

    . - (self-referential)

    . (variable)

    :

    . (program) (int) (float) (input) (output)

    . (program) (float) (input) (output)

    . (program) (int) (input) 2 3 1 2 3 1 1 3 2

  • .. (Exercise Problems)

    . (program) (input) (output) ,

    f o l a f o l nirnoyer kromolekho prothom por ikkhai koto ? 90d i t i y o por ikkhai koto ? 75t r i t i y o por ikkhai koto ? 91 shorbo mot number holo 256

    : - ,

    (header) , (namespace) std , main return EXIT SUCCESS;

    (compile) (run) , include, namespace, main,return , main return

    . (program) (int) (float) (input) (output)

    .: (Input Output Program)i n t purnok ;f l o a t vognok ;

    cout > purnok ;

    cout > vognok ;

    cout

  • .. (Exercise Problems)

    .: (Input Process Output)f l o a t prothom , d i t i y o ;

    cout > prothom >> d i t i y o ;

    f l o a t j o g f o l = prothom + d i t i y o ;

    cout

  • .. (Computing Terminologies)

    .: (Result Processing Program)i n t prothom , d i t i y o , t r i t i y o ;

    cout

  • (Mathematical Processing)

    (expression) (operator) (function)

    . (Unary Operators)

    (unary) (positive) + (negative) ? (unary) (operator) (operand)

    .: (Arithmetic Positive Negative)i n t a = 5 ; i n t const b = 9 ; / / a b cout

  • .. (Binary Operators)

    , (variable), (constant), (function), (expression) , -

    (function) (input) (output) cstdlib - (header file) abs(x) abs(3) 3 abs(3) 3 abs(3.5) 3.5 abs(3.5) 3.5 (expression) , , , , 3 + x abs(y) x y

    . (Binary Operators)

    (binary) +, , , ? (operator) (operand)

    .: (Arithmetic Plus Minus Times)cout

  • .. (Division and Remainder)

    8.3, 1.9, 16.32 , 5.1 + 3, 5.1 3, 5.1 3 8.1, 2.1, 15.3,

    (output segment)5 + 3 = 85 . 1 + 3 = 8 . 15 . 1 + 3 . 2 = 8 . 3

    5 3 = 25 . 1 3 = 2 . 15 . 1 3 . 2 = 1 . 9

    5 3 = 155 . 1 3 = 15 . 35 . 1 3 . 2 = 16 . 32

    (operator) (operand) int int; float float

    int float float 3 3.0, 5.1 (operator) (operand) , , (type casting) ,

    . (Division and Remainder)

    (binary) (division) (remainder) ? (operator) (operand)

    .: (Arithmetic Division Operation)cout

  • .. (Division and Remainder)

    int float float int float (type casting) ,

    (output segment)13 / 5 = 213 . 0 / 5 = 2 . 613 / 5 . 0 = 2 . 613 . 0 / 5 . 0 = 2 . 6

    , , , ,

    2.6 , 13 / 5 2 3 -

    13 / 0

    (run) divide by zero (errormessage) (compile) , (run) (execute) ,

    - (run-time) - (execution-time)

    .: (Arithmetic Remainder Operation)cout

  • .. (Division and Remainder)

    (program) (compile) (error) -

    // , ,

    , (comment) //

    , - ? , , , (program) , , , , -

    (commenting) , , (uncomment) ! , !

    (output segment)13 / 5 = 2 13 % 5 = 313 / 5 = 2 13 % 5 = 313 / 5 = 2 13 % 5 = 313 / 5 = 2 13 % 5 = 3

    - (program segment) (output segment) -

    (positive) , (negative) , - cpp.sh , (compiler) (compile) , (program segment)

    , , (divisor) (dividend) 5 13 13 5 2 3 , , +

    , (dividend) , 13, +

  • .. (Assignment Operator)

    13 5 5 , divide by zero

    (compile) , (run) , - (run-time error)

    , (variable) (constant) (expression) (function) -(rvalue) , (function) (input) (output) cstdlib (header file) abs(x) abs(3) 3 abs(3) 3 abs(3.5) 3.5 abs(3.5) 3.5 (expression) , , , , , 3 + x abs(y) x y

    i n t a = 4 , b = 3 ;i n t const c = 5 ;

    a + 3 , c / b , b c ; / / , , a = c % abs ( b ) ; / / abs ( b ) a = a ( b c ) ; / / b c

    . (Assignment Operator)

    (assignment) (memory) (operator) ? ?

    (assignment) (operator) (operand) , , (binary)

    (operand) - (memory) , - ,

    (variable), (constant), (function) (expression) ?

    i n t v = 3 , w = 5 , x , y , z ; / / x = v + 5 ; / / x 8 , 8y = abs (w) ; / / y 5 , 5z = x + y ; / / z 13 , 13

  • .. (Compound Assignment)

    v + 5 3 + 5 8 x , abs(w) w 5 5 y x + y 8 + 5 13 z

    - !

    i n t v = 3 , w = 5 , x , y , z ; / / x = ( v + w) ; / / z = ( y = x ) ; / / z = v w; / / , z = y = x ; / / ,

    x + y + z + 3, z = y = x = w , (assignment)

    i n t x = 1 , y = 2 ; z = 3 ; / /

    x + ( y = 3) ; / / y 3 , 1 + 3 4y = x + ( z = 4) ; / / z 4 , y 1 + 4 5z = 5 + ( y = z 3) ; / / y 4 3 1 , z 5 + 1

    (statement) x + (y = 3); y 3 (assign) (assignment) 3, x 1 4 4 y = x + (z = 4); z 4 4, 4 x 1 5 y z = 5 + (y

    = z 3); z 3 , z 4 3 1 y (result) 1 1 5 6 z

    . (Compound Assignment)

    (compound assignment) ? (operator) (composition) ? - (self referential) ?

    (composition) = + - += = - =, =, /= %=

  • .. (Increment and Decrement)

    x += 13 ; / / x = x + 13 ;x = 7 ; / / x = x 7 ;y = x ; / / y = y x ;z / = x + y ; / / z = z / ( x + y ) ;z %= abs ( 3) ; / / z = z % abs ( 3) ;

    - - (self-referential assignment) , , ,

    , , , - (l-value) - (memory) (array) , (class) , , = :

    t h i s>amarSajonCholok [ suchok ] =t h i s>amarSajonCholok [ suchok ] + amarbriddhi ;

    t h i s>amarSajonCholok [ suchok ] += amarbriddhi ;

    = = , , (program)

    . (Increment and Decrement)

    (program) ++ ? !

    - ? ?

    i n t x = 6 , y ; / / , ++x ; / / x 7 , y x++ ; / / x 8 , y y = ++x ; / / x 9 , y 9 y = x++ ; / / y x 9 , x 10

    (program segment) (variable) x y x (initial value) 6, y -

  • .. (Increment and Decrement)

    ++x; x++;, x , ++ (incrementoperator) ++ -

    ++ - (pre-increment) - (post-increment)

    (increment operator) - - (l-value) (memory) (variable) - x - ++3 3++ 4 (x+3)++ ++(x+3), , (compile) 3 (number) x+3 (expression) - (r-value) (value) -

    - (l-value) (memory) , ++ x (constant) ,

    ++ ++x x++ x+=1; x = x+1; ++ 1 ++ (operand) ++ (unary) (operator) ? , , (increment operator) - (pre-increment) - (post-increment)

    - (pre-increment) (post-increment) (program segment) y = ++x; x 9 x 9 y (assign) y = x++; x y y 9 x 1 10 y = ++x; y = x++; ++ ? y = ++x; , y = x++; - (pre-) - (post-increment)

    x = x + 1 ; / / y= ++x ; x y = x ; / / y= ++x ; y x

    y = x ; / / y= x++ ; y x x = x + 1 ; / / y= x++ ; x

    - (pre-increment) - (post-increment) - - - (l-value) -, - - (r-value) (operand) - - , - ++++x; (++x)++; -

  • .. (Comma Operator)

    , (compile) , x++++ ++(x++) , , (error) "l-value required" ++x++;, , , (precedence) , ++x++ ++(x++)

    (precedence order)

    (increment) ++x x++ x+=1 x=x+1 , x++ ++x x+=1 x=x+1 - (pre-increment) -

    (post-increment) - , - x , (temporarily) , x , y = x++; y - , (overhead) - -

    ++x , - ++x; - x++; ++x , x++

    - - , x = (++x)++ + ++x; + (compile) , , (code) ,

    (increment) - (decrement) - (decrement) 1 x x

    x = 1 x = x 1 x (pre-decrement) x - (post-decrement) - - (precedence) - , -

    . (Comma Operator)

    (comma operator) (expression) (comma) (operand) (void) (operand) (comma operator)

    x = (y=3, y+1); y (assign) 3 y 3 3, (comma)

  • .. (Precedence Order)

    (void) (comma) y+1 3+1 4 + 4 x

    (comma) , (assignment) = y = 3 (comma) x , x = y = 3, y + 1; (assignment) (comma) (execute) y 3, x 3 , y+1 4 4

    (comma) (operator) (variable) (declare) (comma) int x, y, z = 3; (comma) , (separator)

    - (for-loop) (parameter) (list separator) (comma)

    . (Precedence Order)

    (precedence order) ? - (operator) (precedence order)

    3 + 45 + 6 (calculator) , 3 4 7 , 5 35 6 41

    , 5 6 11, - 4 44, 3 47 : 4 5 20 , 3 23, 6 29, , (precedence order)

    : , , , , , -

    (Operator) + ++ + / % =+= = = / %= , , - (precedence order)

    . ++ (unary operator) - - (post-increment and post-decrement) x++, x - (l- value) - - (r-value) x++++ x

  • .. (Precedence Order)

    . ++ + (unary operator) - (pre-increment)++x - (pre-decrement) x - (l-value) - ++++x x , ++ () (unary operator) +x (positive) x (negative) - (r-value) - + + x x , +

    . / % (binary operator) - (r-value) (operand) - 10 / 2 4% 6 , ,

    . + (binary operator) - (r-value) - (operator) - 10 2 + 5 ,

    . = += = = /= %= (binary operator) (assignment) - (l-value) , - (r-value) x += y= z = 3 = z 3 , =

    z y , y x

    . , (comma) (binary operator) (operand) , (void) , x + 2, y 3, z / 4 , ,

    - (associativity) xyz

    , , (left associative) x y z (x y) z (right associative) x y z x (y z) x + y + z, (x + y) + z x + (y + z) - , - (left associative), (right associative)?

    ( ) -

    (operator) (precedence order) (statement and expression) ,

  • .. (Mathematical Problems)

    , , x += y z x += (y z) ,

    . (Mathematical Problems)

    (two dimensional coordinate system) (input) (output)

    (x1, y1) (x2, y2) (x1 x2)2 + (y1 y2)2 -

    cmath (header file) sqrt

    .: (Distance Between Two Points)/ / main

    #include / / sqrt

    / / main return

    f l o a t x1 , y1 , x2 , y2 ; / / ( x1 , y1 ) , ( x2 , y2 )

    cout > x1 >> y1 ; / / cout > x2 >> y2 ; / /

    f l o a t xd = abs ( x1 x2 ) ; / / f l o a t yd = abs ( y1 y2 ) ; / /

    f l o a t dd = sqrt ( xd xd + yd yd ) ; / / cout

  • .. cmath (Header File cmath)

    dd dd (output) sqrt(xd xd + yd yd) cmath (header file) - hypot (function)

    hypot(xd, yd)

    . cmath (Header File cmath)

    cmath (function) - (hyperbolic)

    (Mathematical Functions)

    abs(x): x abs(3) 3 abs(3) 3

    (Trigonometric Functions)

    cos(x): (cosine) x

    sin(x): (sine) x

    tan(x): (tangent) x

    acos(x): (arc-cosine)

    asin(x): (arc-sine)

    atan(x): (arc-tangent)

    atan2(x,y): (arc-tangent) xy x (numerator) y (denominator)

    (Hyperbolic Functions)

    cosh(x): (hyperbolic cosine) x

    sinh(x): (hyperbolic sine) x

    tanh(x): (hyperbolic tangent) x

    acosh(x): (hyperbolic arc-cosine),

    asinh(x): (hyperbolic arc-sine),

    atanh(x): (hyperbolic arc-tangent),

  • .. cmath (Header File cmath)

    (Exponents and Logarithms)

    exp(x): ex (exponential function)

    log(x): loge x (logarithmic function)

    log10(x): log10x - (logarithm)

    exp2(x): 2x - (exponential)

    log2(x): log2x - (logarithm)

    (Power and Index)

    pow(x,y): xy x y pow(2,3) 23 8

    sqrt(x):x x sqrt(16.0) 4.0

    cbrt(x): 3x x cbrt(8.0) 2.0

    hypot(x,y):

    x2 + y2 x y (perpendicular) (base) (hypotenuse)

    (Rounding Functions)

    round(x): x

    floor(x): x

    ceil (x): x

    trunc(x): x

    x round(x) floor(x) ceil (x) trunc(x)

    2.3 2.0 2.0 3.0 2.02.8 3.0 2.0 3.0 2.02.5 3.0 2.0 3.0 2.02.0 2.0 2.0 2.0 2.0-2.3 -2.0 -3.0 -2.0 -2.0-2.8 -3.0 -3.0 -2.0 -2.0-2.5 -3.0 -3.0 -2.0 -2.0

  • .. (Exercise Problems)

    . (Exercise Problems)

    :

    . (function) (expression) ?

    . (unary) (binary) (operation) ? (unary) (binary) (operation)

    . (type casting) ? (binary operation) (type casting) ?

    . - (execution-time error) ? ?

    . (code segment) (comment) ,

    . (integer)

    . (assignment operator) ? (compound assignment) ?

    . (compound assignment) x += 1 (increment) x++ ++x ?

    . - (post-increment) - (pre-increment) ?

    . (comma) ? ?

    . (precedence order) (associativity) ?

    . (operator) (precedenceorder) (associativity)

    :

    . (arithmetic series) a d n- ? n ? (program) a, d, n (input) , n- n

    (output) n- = a+(n 1) d n = n (2a+ (n 1) d)/2 a d

  • .. (Exercise Problems)

    1 + 2 + 3 + . . . a = 1, d = 1 n- = a + n 1, n = n(n+ 1)/2 n = 10 10- 10, 55

    2 + 4 + 6 + . . . a = 2, d = 2 n- = 2n, n = n(n+ 1) n = 10 10- 20, 110

    1+ 3+ 5+ . . . a = 1, d = 2 n- = 2n 1, n = n2 n = 10 10- 19, 100

    . (output) (program) (binary operator)

    x=10 y=5

    r a s h i f o lx=y+3 x= 8x=y2 x= 3x=y5 x= 25x=x / y x= 2x=x%y x= 0

    . (program) 326 623 , , , 326 623

    . a, b, c (input) =

    s(s a)(s b)(s c) s

    s = (a+ b+ c)/2

    . (program) --

    . a, b, c (input) A, B, C A, B, C a, b, c C = cos1((a2 + b2 c2)/(2ab)), B = cos1((c2+a2b2)/(2ca)) A = cos1((b2+c2a2)/(2bc))

    . (program) , , ,

    . ax+ by = c dx + ey = f a, b, c, d, e, f x y

    . u a t v t s v = u+ at s = ut+ 12at

    2

  • .. (Exercise Problems)

    . - (pseudocode) (program)

    ) (read) x y

    ) (compute) p = x y) (compute) s = x+ y

    ) (compute) t = s2 + p (s x) (p+ y)) (write) t

    : - ,

    . (arithmetic series) a d n- ? n ? (program) a, d, n (input) , n- n

    (output) n- = a+(n 1) d n = n (2a+ (n 1) d)/2 a d

    1 + 2 + 3 + . . . a = 1, d = 1 n- = a + n 1, n = n(n+ 1)/2 n = 10 10- 10, 55

    2 + 4 + 6 + . . . a = 2, d = 2 n- = 2n, n = n(n+ 1) n = 10 10- 20, 110

    1+ 3+ 5+ . . . a = 1, d = 2 n- = 2n 1, n = n2 n = 10 10- 19, 100

    (program) (program)

    .: (Arithmetic Series Problem)i n t a , d , n ;cout > a ;cout > d ;cout > n ;

    i n t t = a + ( n 1) d ; / / n cout

  • .. (Exercise Problems)

    - (input-output segment)prothom pod? 1sadharon ontor ? 1kototom pod? 1010tom pod = 1010 poder somosti = 55

    . (output) (program)

    x=10 y=5

    r a s h i f o lx=y+3 x= 8x=y2 x= 3x=y5 x= 25x=x / y x= 2x=x%y x= 0

    .: (Binary Operation Results)i n t x = 10 , y = 5 ;

    cout

  • .. (Exercise Problems)

    . a, b, c (input) =

    s(s a)(s b)(s c) s

    s = (a+ b+ c)/2

    .: (Triangle's Area From Sides)/ / main #include

    / / main f l o a t a , b , c ; / / cout > a >> b >> c ; / /

    f l o a t s = ( a + b + c ) / 2 ; / / f l o a t k = sqrt ( s ( sa ) ( sb ) ( sc ) ) ; / /

    cout

  • .. (Exercise Problems)

    pai 3.1416 acos(1)

    .: (Triangle's Angles From Sides)/ / main #include

    / / main f l o a t a , b , c ; / / cout > a >> b >> c ; / /

    / / f l o a t C = acos ( ( aa + bb cc ) / ( 2ab ) ) ;f l o a t B = acos ( ( cc + aa bb ) / ( 2ca ) ) ;f l o a t A = acos ( ( bb + cc aa ) / ( 2bc ) ) ;

    / / f l o a t const pai = arccos (1) ; / / 3 . 1416C = 180 / pai ; B = 180 / pai ; A = 180 / pai ;

    cout

  • .. (Exercise Problems)

    . ax+by = c dx+ey = f a, b, c, d, e, f x y x = (ce bf)/(ae bd) y = (af cd)/(ae bd)

    .: (Simultaneous Equations)f l o a t a , b , c , d , e , f ;

    cout > a >> b >> c ;

    cout > d >> e >> e ;

    f l o a t x = ( ce b f ) / ( ae bd ) ;f l o a t y = ( a f cd ) / ( ae bd ) ;

    cout

  • .. (Computing Terminologies)

    . - (pseudocode) (program)

    ) (read) x y) (compute) p = x y) (compute) s = x+ y) (compute) t = s2 + p (s x) (p+ y)) (write) t

    .: (Program from Pseudocode)i n t x , y ; / / main

    c i n >> x >> y ; / / i n t p = x y ; / / i n t s = x + y ; / / i n t t = ss + p ( s x ) ( p + y ) ; / /

    cout

  • (Conditional Programming)

    , , - , (conditional programming) , ,

    . (If Then Else)

    (star) (program) (input) (output)

    ,

    .: - - (Pass Fail Star Marks)i n t nombor ; / /

    cout > nombor ; / /

    i f ( nombor >= 50) / / cout

  • .. (If Then Else)

    (program) (compile) - (run) 50 (input) 45

    (output) fell 50 79 (input) - 65 (output) pash 80 (input) 85 (output) : pash - taroka - (input-output segment) (program)

    , ,

    - (input-output segment)nombor? 45 nombor? 65 nombor? 85f e l l pash pash

    taroka

    (program segment) (variabledeclaration), (input prompt), (taking input) if (nombor >= 50) 50 cout

  • .. (Relational Operators)

    < 50) , , 50 50 , else if (nobmor < 50) (program) (slow) if (nobmor < 50) else nombor >= 50 nombor < 50 if

    i f ( nombor >= 50) / / cout

  • .. (Relational Operators)

    (program segment)cout

  • .. - (If-Else Ladder)

    (integer) , - (relational operators) (fractioner) , (int) (float) (type cast) , - (float) (bool) 0 1 (relational operators) (bool) false true 0 1 3 4

    (bool) (int) (float) (operand)

    . - (If-Else Ladder)

    - (If-Else Ladder) ? - (leap year) (program)

    (leap year) ,

    , , " , , , "

    .: (Leap Year Determination)i n t bosor ;cout > bosor ;

    i f ( bosor % 400 == 0) / / cout

  • .. - (Nested If-Else)

    % , , , !

    bosor %400 == 0 bosor %400 !=0 (program) ( ) , ( )

    400 , 4 100 ? ,

    , , (program) , - , , (program) ,

    (indentation) (program) if , else if

    , else (pattern) if

    , (statement) (execute) - cout

  • .. - (Nested If-Else)

    -

    i f ( bosor % 400 == 0) / / cout

  • .. (Dangling Else)

    - (indentation) else if else if else if (comment) - (program) (indentation)

    : - (if-else ladder) - (nested if-else) !

    (program-segment) - (nested if-else) - (if-else ladder) (indentation) ? (leap year) - , , , , , , , !

    i f ( bosor % 100 == 0) / / i f ( bosor % 400 == 0) / /

    cout

  • .. (Dangling Else)

    , (program segment)

    i n t onchol ;

    cout > onchol ;

    i f ( onchol > 100) / / khoroch = 4 ;

    else i f ( onchol % 13 == 0) / / khoroch = 3 ;

    else / / khoroch = 2 ;

    , (dangling else) khoroch (initial assignment)

    i n t khoroch = 2 ; / /

    i f ( onchol

  • .. (Compound Statement)

    if else , if - else if , (computer) (indentation) , !

    i n t khoroch = 2 ; / /

    i f ( onchol

  • .. (Compound Statement)

    f l o a t nombor1 , nombor2 ; / /

    cout > nombor1 >> nombor2 ; / /

    i f ( nombor1 == 0) / / {

    cout

  • .. (Error Detection)

    (block) (dangling else) . - else if (emptystatement) ; (semicolon) (program segment) if (block) else if ,

    i n t khoroch = 2 ; / / i f ( onchol

  • .. (Error Detection)

    (program) (execution-time) (error detect)

    #include / / sqrt

    / / main ,

    f l o a t a , b , c ; / /

    cout > b >> c ; / /

    f l o a t d = bb 4ac ; / /

    f l o a t x1 = (b + sqrt ( d ) ) / ( 2a ) ; / / f l o a t x2 = (b sqrt ( d ) ) / ( 2a ) ; / /

    cout

  • .. (Error Detection)

    (program) (program) return EXIT SUCCESS; return EXIT FAILURE;

    .: (Solving Quadratic Equations)#include / / cout #include / / EXIT SUCCESS/ FAILURE #include / / sqrt

    using namespace std ; / /

    i n t main ( ){

    f l o a t a , b , c ; / /

    cout > b >> c ; / /

    / / a b ? c !i f ( a == 0) / / a , !{

    i f ( b == 0) / / b !{

    cout

  • .. (Error Detection)

    cout

  • .. (Boolean Connectives)

    a (discriminant) floatd = bb 4ac; (negative) , (error message) return EXIT FAILURE; - (input-output) ,

    somikoron ax2 + bx + c = 0a b c er man koto ? 2 5 2nischayok r inatok !bastob somadhan nai !

    (discriminant) (negative) , , (coincidental) - (input-output)

    somikoron ax2 + bx + c = 0a b c er man koto ? 1 2 1duto somadhan ashole ekoi !somapotito x = 1

    , , (positive)

    (program segment) return EXIT SUCCESS;

    - (input-output)

    somikoron ax2 + bx + c = 0a b c er man koto ? 2 5 2prothom somadhan x1 = 2d i t i y o somadhan x2 = 0 . 5

    (program) if (block) return (program) if else (block) if (block) else ,

    . (Boolean Connectives)

    (program) (integer) (input) (output) "

  • .. (Boolean Connectives)

    ", " ", " ", " " " "

    .: (Lucky & Unlucky Numbers)i n t nombor ;cout > sonkhya ;

    i f ( sonkhya % 7 == 0 && sonkhya % 13 == 0)cout

  • .. , , (Boolean, Integer, Float)

    bool bivajyo7 = sonkhya % 7 == 0; - bivajyo7 true 1 false 0 bool bivajyo13 = sonkhya % 13 == 0; - bivajyo13 true 1 13 false

    0 13

    i n t nombor ;cout > sonkhya ;

    bool bivajyo7 = sonkhya % 7 == 0 ;bool bivajyo13 = sonkhya % 13 == 0 ;

    i f ( b iva jyo7 && bivajyo13 )cout

  • .. , , (Boolean, Integer, Float)

    i n t sonkhya = 41 ; / /

    i f ( sonkhya % 2 ! = 0)cout

  • .. (Boolean Algebra)

    . (Boolean Algebra)

    (if else) - (boolean algebra) &&, | | , ! (operators) (expression) (evaluate) (operator) (operator) , (program execution)

    (boolean algebra) (representation) true 1 false 0 (operator) (representation) , (operand) 0 true , false 0 true , (error)

    (boolean algebra) (operator) , ! not (operand) (result)

    !true false !false true (equivalence)

    !true false ! false true

    ! ! !true ! ! false ! !x, ! , ! ! (right associative) ! true false ! ! !true true, ! ! false false, ! !x x (double negation) ! ? , !

    ! !x ! ( !x)

    ! !x x

    ! !true true

    ! ! false false

    (boolean algebra) (operator) , && and (result) (operand) ,

    true && true true

    true && false false

    false && true false

    false && false false

    && - (true simplification) (false simplification)

  • .. (Boolean Algebra)

    x && true x

    true && x x

    x && false false

    false && x false

    (boolean algebra) (operator) , | | or (result) (operand) ,

    true | | true true

    true | | false true

    false | | true true

    false | | false false

    | | - (true simplification) (false simplification)

    x | | true true

    true | | x true

    x | | false x

    false | | x x

    (operator) (precedence order) !, &&, | | ,

    ! &&, | | , ! && | |

    x && !y | | z (x && (!y)) | | z !, &&, | |

    x && !y | | z x && ((!y) | | z) !, | | , &&

    (mathematical operators) (assignment) :

    . ++ (unary postfix (left associative)

    . ++ + ! (unary prefix) (right associative)

    . / % (binary) (left associative)

    . + (binary) (left associative)

    . && (binary) (left associative)

    . | | (binary) (left associative)

    . = += = = /= %= (binary) (right associative)

    . , (binary) (left associative)

  • .. (Boolean Equivalence)

    . (Boolean Equivalence)

    (equivalence rule) - (logical expression)

    , (commutative rule) (operator)

    x && y y && x x | | y y | | x

    (associative rule) - (operator) (evaluate) ,

    x && y && z (x && y) && z x && (y && z)

    x | | y | | z (x | | y) | | z x | | (y | | z)

    (distributive rule) (operator) - x (y + z) = x y + x z

    x && y | | z x && (y | | z) (x && y) | | (x && z)

    x | | y && z (x | | y) && z (x && z) | | (y && z)

    x | | y && z x | | (y && z) (x | | y) && (x | | z)

    x && y | | z (x && y) | | z) (x | | z) && (y | | z)

    (absorption rule) x true x | | y y | | x true && true x false && false x x false x && y y && x false x true | | true x !

    x && (x | | y) x

    x && (y | | x) x

    (x | | y) && x x

    (y | | x) && x x

    x | | (x && y) x

    x | | (y && x) x

    (x && y) | | x) x

    (y && x) | | x) x

    (operator) && | |

  • .. (Truth Table)

    (operator) (idempotence) , x + x = x , + && | | (idempotent)

    x && x x x | | x x

    v (operator)

    && false , , (contradiction) | | true ,

    , (excluded middle)

    x && !x false x | | !x true

    (De Morgan's Law) &&

    ! ! | | | |

    ! ! &&

    ! (x && y) !x | | !y ! (x | | y) !x && !y

    . (Truth Table)

    (equivalence rule) , , (combination) , (truth table)

    (variable) x y, true false (combination) - (evaluate) , , n 2n (truth table) (row) - (column) (subexpression) (expression)

  • .. (Boolean Simplification)

    ! (x && y) x && y , !x | | !y !x !y

    (Truth Table)x y x && y ! (x && y) !x !y !x || ! y

    true true true false false false falsetrue false false true false true truefalse true false true true false truefalse false false true true true true

    (truth table) (row) :

    . (row) x y true x && y true, ! (x && y) false !x !y false, !x | | !y false ! (x && y) !x | | !y

    . (row) x,y true, false, x && y false ! (x && y) true !x !y false true, !x | | !y true ! (x && y) !x | | !y

    . (row) x,y false , true, x && y false ! (x && y) true !x !y true false, !x | | !y true ! (x && y) !x | | !y

    . (row) x y false x && y false, !(x && y) true !x !y true, !x | | !y true ! (x && y) !x | | !y

    (operand) ! (x && y) !x | |!y ,

    . (Boolean Simplification)

    (conditional programming) (boolean algebra) ? (program)

    (program) (input)

    - shreni boyosh

    , (declare) (input prompt) (input)

  • .. (Boolean Simplification)

    if shreni == 5) , (output) "khelte parbe" if (shreni != 5 && boyosh == 10) if else if

    (output) "khelte parbena" , " " "" &&

    i f ( shreni == 5)cout

  • .. , , (Ladder, Nesting, Connectives)

    (program) ! (p && (!p | | q)) | | q

    ! (p && (!p | | q)) | | q

    ! ( (p && !p) | | (p && q)) | | q (distribution)

    ! (false | | (p && q)) | | q (contradiction)

    ! (p && q) | | q (false simplification)

    ( !p | | !q) | | q (De Morgan)

    !p | | ( !q | | q) (associative)

    !p | | true (excluded middle)

    true (true simplification)

    if ( ! (p && (!p | | q)) | | q) if(true) , true p q

    if

    / / i f ( true ) / / , cout

  • .. , , (Ladder, Nesting, Connectives)

    i f ( shorto1 ) i f ( shorto1 | | shorto2 )cout

  • .. , , (Ladder, Nesting, Connectives)

    i f ( shorto1 ) i f ( shorto1 | | ! shorto2 )cout

  • .. - (If-Else Optimisation)

    shorto true, shorto1 !shorto1 shorto shorto2 !shorto2 shorto shorto && if else

    shorto - shorto1 (partial evaluation) shorto2 , if ( !shorto2) else if ( !shorto2)

    bool shorto = f a l s e ; i f ( shorto1 | | shorto2 )i f ( shorto1 ) cout

  • .. - (If-Else Optimisation)

    , , (nombor >=50) nombor>= 80

    * =

    i f ( nombor >= 50) / / {

    cout

  • .. (Ternary Operator)

    + (+)* =

    , ,

    ? (output) , ,

    - - (case) , !

    . (Ternary Operator)

    (conditional programming) (ternaryoperator) ?

    ? : - (ternary operator) -- (if-then-else) , (expression) , if-else (conditional statement)

    i n t prothom , d i t i y o ; / /

    i n t boro = prothom > d i t i y o ? prothom : d i t i y o ;

    ?

    ? : : prothom > ditiyo prothom ditiyo

    prothom ditiyo !

    i n t prothom , d i t i y o ; / / i n t boro ; / /

    prothom > d i t i y o ? boro = prothom : boro = d i t i y o ;

  • .. (Ternary Operator)

    (variable) boro (assign) - (assign) (result) , , boro - int fol = prothom > ditiyo ? boro =prothom : boro = ditiyo; boro fol

    i n t prothom , d i t i y o ; / / i n t boro ; / /

    i f ( prothom > d i t i y o ) / / boro = prothom ;

    elseboro = d i t i y o ; / /

    - - ? (ternary) - , (block) (execute)

    i n t prothom , d i t i y o , t r i t i y o ; / /

    i n t boro = prothom > d i t i y o ? prothom : d i t i y o ;boro = boro > t r i t i y o ? boro : t r i t i y o ;

    (ternary operator) - , ?

    boro tritiyo boro boro tritiyo - tritiyo - , (nested) , - (indentation) prothom ditiyo prothom tritiyo - ditiyo , tritiyo ,

    i n t prothom , d i t i y o , t r i t i y o ; / /

    i n t boro = prothom > d i t i y o ?( prothom > t r i t i y o ? prothom : t r i t i y o ) :( d i t i y o > t r i t i y o ? d i t i y o : t r i t i y o ) ;

  • .. (Switch Cases)

    . (Switch Cases)

    (program) (integer) (fractioner) (input) (sine) (cosine), (tangent) " " (switch case) - (if-else)

    .: (Trigonometry with Menu)i n t onupat ; / / sine , cosine , tangentf l o a t kone ; / /

    / / (menu) cout

  • .. (Switch Cases)

    (program segment) : onupat

    kone (menu) , : 1 (sine), 2

    (cosine), 3 (tangent) (input) (input prompt) - (switch case)

    - (switch case) onupat

    (variable) (output) , - switch(onupat) (block) { } (curly brackets) - onupat 1, 2, 3

    (case) case 1: case 2: case 3:; - case onupat : (colon) (case) cout sine, cosine, tangent break; - - (break) (break) case 3: (break) default: case onupat

    onupat 1, 2, 3 default: (errormessage) break;

    (program execution) (control) main (executed) ,

    - (if-else) (branch) , if-else

    - (switch-case) switch(onupat) ? onupat 1 case 1: , 2 case 2: , 3 case 3: , default: switch(onupat) (case) break; break break; - (switch-case) (case)

    (break) ,

  • .. (Nested Switch Cases)

    . (Nested Switch Cases)

    (nested switch case) (program) , (menu) , (input)

    , (output) ,

    (program) (menu) - akriti (variable declare) (input prompt)

    (input) akriti (switch) (case) akriti 1 case 1: , 2 case 2: , default:

    .: (Menu with Nested Switch)/ / (menu)cout

  • .. (Nested Switch Cases)

    / / switch ( keechai ) / / {

    case 1 : / / cout

  • .. (Nested Switch Cases)

    case 1 : / / cout

  • .. (Switch Cases Breaks)

    - (block) (variable) , , chaokee - (output) (switch case) - , (nested switch case)

    , break; (control) - (switch case) , break; ? -

    cout

  • .. (Switch Cases Breaks)

    (program segment) , - , sokaler nasta, dupurer khabar, bikaler nasta , sokalernasta , dupurer khabar bikaler nasta

    , (switch) default

    : (case) , (output) (switch) (default) ,

    switch ( nombor ){

    case 4 :case 0 :case 2 :

    cout

  • .. - (Swtich Cases If Else)

    , case 1: - case 1:

    (nested) case 1:

    . - (Swtich Cases If Else)

    (switch cases) (if else) , ?

    switch ( nombor ){

    case 2 :case 1 :

    cout

  • .. (Global & Local Variables)

    , >, < (switch) , (if else) (connectives) &&, | | , !

    i f ( nombor < 0)cout

  • .. (Global & Local Variables)

    i f ( bashardho < nimnoshima ){

    cout

  • .. (Global & Local Variables)

    (local) (global)

    (unique) , ? (program segment) , cholok , (block) (global) cholok (output) , , ?

    2 , int kisuekta = cholok; (block) - 2 3, cholok , , - (program)

    (comment) -, , ?

    , , ?

    i n t nombor ;c i n >> nombor ;

    / / vagshesh i f ( i n t vagshesh = nombor % 3)

    cout

  • .. (Exercise Problems)

    (local variable)

    i n t nombor ;c i n >> nombor ;

    / / vagshesh switch ( i n t vagshesh = nombor % 3){

    case 0 :cout

  • .. (Exercise Problems)

    . (empty statement) ? ?

    . (boolean connectives) , ?

    . (integer) (fractioner) ?

    . (boolean condition) ?

    . (global variable (local variable) ?

    :

    . (program segment) (output) - ,

    i n t n ; / / cout

  • .. (Exercise Problems)

    i n t n , k = 5 ;n = ( 100 % k ? k + 1 : k 1) ;cout

  • .. (Exercise Problems)

    i n t n ;cout > n ;

    i f ( n < 10)cout

  • .. (Exercise Problems)

    . (program) - (if else ladder)

    . (input) (output) (switch cases)

    . (input) (-), (-), (-), (-), (-), (-), (-) - (switch cases)

    . (program) - (, , , , ) , - (input) (output)

    - , (errormessage) (switch cases) - (if else)

    . , , (input)

    . (program) - (input) (output) , ,

    . , . (input) (output)

    . , , , , ,, , , , , , , , , , , ,, , , , , , , , , , , , ,

    (program) , , ,, (input) , (output) , , + + =

    : - ,

  • .. (Exercise Problems)

    . (program segment) (output) - ,

    i n t n ; / / cout

  • .. (Exercise Problems)

    if else else cout

  • .. (Exercise Problems)

    . , (conditional statement) - (execute) (output) ? ?

    i n t n = 5 ;i f ( n = 0) / /

    cout

  • .. (Exercise Problems)

    (program segment) - uparjon < 0 , uparjon >=0 (if else ladder) uparjon >=0 (control)

    (and) && (operator) (operand) - && uparjon >= 1200 uparjon >= 2500

    f l o a t uparjon ;cout > uparjon ;

    i f ( uparjon < 0)cout

  • .. (Exercise Problems)

    . (nested if else) (indentation)

    i f ( n < 10)i f ( n > 0)

    cout

  • .. (Exercise Problems)

    (indentation) , (program) -

    n , "10 ba boro" n , dhonatok,

    . (input) , (output)

    .: - (Small and Big of Three Numbers)i n t a , b , c ; / / cout > a >> b >> c ; / /

    i n t boro , soto ; / / i f ( a > b ) / / a b

    boro = a , soto = b ;else / / b a

    boro = b , soto = a ;i f ( boro < c ) / / c boro

    boro = c ;else i f ( soto > c ) / / c soto

    soto = c ;

    cout

  • .. (Exercise Problems)

    . (input) (output)

    .: (Median of Three Numbers)/ / a , b , c

    i f ( a > b ) / / a > bi f ( c > a ) / / c > a > b

    cout b > c

    cout = b

    cout

  • .. (Exercise Problems)

    a b c , , (ascending order) (output) (if else) (nesting) (ladder)

    . (input) (letter grade) A, B, C, D, E, F

    .: (Letter Grades from Numbers)cout > nombor ;

    i f ( nombor >= 90)cout

  • .. (Exercise Problems)

    i f ( x > 0)i f ( y > 0)

    cout

  • .. (Exercise Problems)

    , (error message) | |

    cout > n1 >> n2 ; / /

    / / i f ( n1 < 100 | | n1 > 100 | |

    n2 < 100 | | n2 > 100){

    cout

  • .. (Exercise Problems)

    , ,

    i f ( bosor % 4 ! = 0) / / cout

  • .. (Exercise Problems)

    (operand) bosor % 4 == 0 (bosor % 100 == 0 && bosor % 400 != 0) bosor % 4 == 0 (bosor % 100 == 0 && bosor % 400 != 0) && (bosor %100 == 0 bosor % 400 != 0

    . (input) (output) (switch cases)

    .: (Bengali Month Names)i n t mash ; c i n >> mash ; / /

    switch ( mash ){

    case 1 : cout

  • .. (Exercise Problems)

    case 12 : case 13 : case 14 :cout

  • .. (Exercise Problems)

    i f ( posondo == 1)cout

  • .. (Exercise Problems)

    sorboccho kekheyese

    , sorboccho = p1,kekheyese = 1 sorboccho - sorboccho (program segment)

    .: (Largest of Five Numbers)i n t p1 ; cout > p1 ;i n t p2 ; cout > p2 ;i n t p3 ; cout > p3 ;i n t p4 ; cout > p4 ;i n t p5 ; cout > p5 ;

    i n t sorboccho = p1 , kekheyese = 1 ;i f ( sorboccho < p2 )

    { sorboccho = p2 ; kekheyese = 2 ; } i f ( sorboccho < p3 )

    { sorboccho = p3 ; kekheyese = 3 ; } i f ( sorboccho < p4 )

    { sorboccho = p4 ; kekheyese = 4 ; } i f ( sorboccho < p5 )

    { sorboccho = p5 ; kekheyese = 5 ; }

    cout

  • .. (Exercise Problems)

    . , . (input) (output)

    .: (Weekly Wage Calculation)f l o a t const shaShima = 40 . 0 ; / / f l o a t const otiHar = 1 . 5 ; / /

    f l o a t ghontaProti ; / / f l o a t kotoGhonta ; / / f l o a t motMojuri ; / /

    cout > ghontaProti ;cout > kotoGhonta ;

    i f ( kotoGhonta

  • .. (Exercise Problems)

    (program) , , ,, (input) , (output) , , + + =

    (Number Finding Game)cout

  • .. (Computing Terminologies)

    if , - , , sonkhya (output) -

    . (Computing Terminologies)

    (conditional)

    (if)

    (else)

    (relational)

    (boolean)

    (ladder)

    (nested)

    (dangling)

    (empty)

    (compound)

    (detection)

    (connective)

    , (and)

    , (or)

    , (not)

    (associative)

    (simplification)

    (precedence)

    (order)

    (equivalence)

    (distribution)

    (commutative)

    (absorption)

    (contradiction)

    (excluded middle)

    (truth table)

    (optimisation)

    (ternary)

    (switch)

    (case)

    (control)

    (break)

    (default)

    (global)

    (local)

    (block)

    (subblock)

    (superblock)

    (Developing c++ Programs) (Online Editing Compilation) (Offline Editing Compilation)

    (Program Structure) (Wishing Program)-- (Detailing Program) (Writing Program Comments) (Spacing and Indentation) (Exercise Problems) (Computing Terminologies)

    (Variables and Constants) (Using Variables) (Using Constants) (Variable Declarations) (Initial Assignment) (Exercise Problems) (Computing Terminologies)

    (Naming Identifiers) (Well-formed Names) (Meaningful Names) (Case Sensitivity) (Reserved & Key Words) (Exercise Problems) (Computing Terminologies)

    (Input and Assignment) (Data Input) (Input Prompt) (Value Assignment) - (Value Swapping) (Assignment Left and Right)- (Self-Referential Assignment) (Exercise Problems) (Computing Terminologies)

    (Mathematical Processing) (Unary Operators) (Binary Operators) (Division and Remainder) (Assignment Operator) (Compound Assignment) (Increment and Decrement) (Comma Operator) (Precedence Order) (Mathematical Problems) cmath (Header File cmath) (Exercise Problems) (Computing Terminologies)

    (Conditional Programming) (If Then Else) (Relational Operators)- (If-Else Ladder) - (Nested If-Else) (Dangling Else) (Compound Statement) (Error Detection) (Boolean Connectives), , (Boolean, Integer, Float) (Boolean Algebra) (Boolean Equivalence) (Truth Table) (Boolean Simplification), , (Ladder, Nesting, Connectives)- (If-Else Optimisation) (Ternary Operator) (Switch Cases) (Nested Switch Cases) (Switch Cases Breaks) - (Swtich Cases If Else) (Global & Local Variables) (Exercise Problems) (Computing Terminologies)