Lecture_Notes_04_05_06

Lecture_Notes_04_05_06 - Relational Operators Name Operator...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Relational Operators Name Operator Sample Evaluates Equals == 100==50 50 ==50 false true Not Equals != 100!=50 50!=50 true false Greater than > 100>50 50>50 true false Greater than or equal to >= 100>=50 50>=50 true true Less than < 100<50 50<50 false false Less than or equal to <= 100<=50 50<=50 false true Our Programs Statement 1 Statement 2 Statement 3 e.g., calculate area e.g., calculate perimeter e.g., print outputs The if Statement Enter Your Score Score>90 Congratulations!! True False Thanks for appearing Statement0; if (condition) Statement1; Statement 2; Example 1. #include <iostream> 2. #include <cstdlib> 3. using namespace std; 4. int main() 5. { 6. double score=0.0; 7. cout<< "Enter Your Score: " ; 8. cin>>score; 9. if (score>=90) 10. cout<< "Congratulations!" <<endl; 11. cout<< "Thanks for appearing" ; 12. system( "PAUSE" ); 13. return 0; 14.} The if Statement Statement0; condition Statement1; Statement2; Statement3; Statement4; True False Statement5 Statement0; if (condition) { Statement1; Statement2; Statement3; Statement4; } Statement 5; Block of Statements 1. #include <iostream> 2. #include <cstdlib> 3. using namespace std; 4. int main() 5. { 6. double score=0.0; 7. cout<< "Enter Your Score: " ; 8. cin>>score; 9. if (score>=90) 10. { 11. cout<< "Congratulations!" <<endl; 12. cout<< "You have won a free coffee" <<endl; 13. cout<< "Hope you enjoyed the game" <<endl; 14. } 15. cout<< "Thanks for playing" <<endl; 16. system( "PAUSE" ); 17. return 0; 18.} Example The if-else Statement Enter your score If score>=40 Print Pass Print Fail Yes No The if-else Statement Enter your score If score>=40 Print Pass Print Fail Yes No Statement0; if (condition) { Statement1; Statement2; } else Statement 3; The if-else if Statement Enter your score If score>=80 Print Grade A Yes No If score>=60 Print Grade B Print Grade C Yes No The if-else if Statement Enter your score If score>=80 Print Grade A Yes No If score>=60 Print Grade B Print Grade C Yes No Statement0; if (condition) Statement1; else if (condition) Statement 2; else Statement3; Example 1. #include <iostream> 2. #include <cstdlib> 3. using namespace std; 4. int main() 5. { 6. double score=0; 7. cout<< "Enter you score: "...
View Full Document

Page1 / 30

Lecture_Notes_04_05_06 - Relational Operators Name Operator...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online