Содержание
- 2. Conditional Operators Syntax: exp1 ? exp2 : exp3 Where exp1,exp2 and exp3 are expressions Working of
- 3. Increment & Decrement Operators C++ supports 2 useful operators namely Increment ++ Decrement- -operators The ++
- 4. Rules for ++ & -- Operators These require variables as their operands. When postfix either ++
- 5. Examples for ++ and -- Operators Let the value of a =5 and b=++a then a
- 6. Shorthand Assignment Operators
- 7. Objectives To use the selection structure to choose among the alternative actions if selection statement Double
- 8. Control structures Control structure A control statement and the statements whose execution it controls. a control
- 9. Control structures Bohm and Jacopini’s control structures Bohm and Jacopino’s work demonstrate that all programs could
- 10. Control structures if Selection Structure Perform an action if condition is true. .Skip the action if
- 11. We are going to discuss if and if/else selection structures and switch first and will explain
- 12. Decision making structure/ selection structure Selection structure/decision structure allows the program to make a decision or
- 13. Equality and Relational operators Conditions in if structures can be formed by using the equality and
- 14. Equality and relational operators
- 15. Boolean Expressions Boolean expressions are expressions that are either true or false comparison operators such as
- 16. If Selection Structure The primary C++ selection structure statement used to perform a single-alternative selection. Choose
- 17. Flow chart Graphical representation of an algorithm or a portion of algorithm. Drawn using certain special-purpose
- 18. Flow chart Parallelogram are the input/output symbols Arrows, showing what's called "flow of control“. An arrow
- 19. If selection structure flow chart
- 20. If selection structure example: Pseudocode If student’s grade is greater than or equal to 60 Print
- 21. If selection structure Flow chart for the pseudocode statement.
- 22. Example Example is using the relational and equality operators. Following example used six if statements to
- 24. Input is 35 and 30 Input is 25 and 25 Input is 10 and 20
- 25. The if-else statement The if statement by itself will execute a single statement, or a group
- 26. Ques: In a company an employee is paid as under: If his basic salary is less
- 27. If/else selection structure Different actions if conditions true or false Syntax A single statement for each
- 28. If/else selection structure flow chart Action if true true false
- 29. If/else selection structure Example Pseudocode if student’s grade is greater than or equal to 60 print
- 30. If/else selection structure Flow chart for the pseudocode
- 31. Compound Statement Compound statement Set of statements within a pair of braces also known as BLOCK
- 32. Another simple Example //program to determine if user is ill #include using namespace std; int main()
- 33. output Input is 100 100 > NORM Input is 98 98
- 34. Example of if and if/else selection structure drawn in flow chart form If selection structure(program 1)
- 35. c++ code for the flow chart of if selection structure (program 1). //program 1 //program to
- 36. Output of program 1 Part_number is equal to 203 Part_number is not equal to 203
- 37. c++ code for the flow chart of if/else selection structure (program 2). //program to calculate the
- 38. Output of program 2 Sales is 1500 Sales is greater than 1500
- 39. Example of if/else Write a program to calculate the gross pay of an employee. The employee
- 40. C++ code #include using namespace std; int main() { int hour; //declaration double gross_pay, rate; cout
- 41. output Hour Hour>40
- 42. Nested if/else structure if structure that rests entirely within another if structure, within either the if
- 43. Simple example to understand the nested if/else Consider an example of a program segment that accepts
- 44. Simple example to understand the nested if/else Flow chart
- 45. Simple example to understand the nested if/else C++ code //F and M are correct codes //f
- 46. Nested if/else structure following pseudocode is example of nested if/else if student’s grade is greater than
- 47. Nested if/else structure C++ code if ( grade >= 90 ) // 90 and above cout
- 48. Avoiding Common Pitfalls with if Statements Forgetting that C++ is case sensitive Assuming that indentation has
- 50. Скачать презентацию