SlideServe
Menu
Préférences
© SlideServe · v2026

Programming Fundamentals

chibale avatar
27 diapositives · 423 Views · Jul 25, 2014

This lecture delves into fundamental concepts of C programming, covering the basic structure of a C program, variables, and data types. Learn to utilize input/output using 'cout' and 'cin', along with decision-making through if statements and relational operators. Understand logical operators and the significance of flow charts in program design. Practical examples clearly illustrate these concepts, enabling efficient problem-solving in coding. Enhance your programming skills by mastering these essential components of C.

Programming Fundamentals - slide 1
01 / 27Programming Fundamentals
1 / 17

Télécharger la présentation

Programming Fundamentals
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Programming Fundamentals Lecture 5

  2. In the Previous Lecture • Basic structure of C program • Variables and Data types • Operators • ‘cout’ and ‘cin’ for output and input • Braces

  3. Decision

  4. If Statement If condition is true statements If Ali’s height is greater then 6 feet Then Ali can become a member of the Basket Ball team

  5. If Statement in C If (condition) statement ;

  6. If Statement in C If ( condition ) { statement1 ; statement2 ; : }

  7. If statement in C

  8. Relational Operators

  9. Relational Operators a != b; X = 0; X == 0;

  10. Example #include <iostream.h> main ( ) { intAmirAge, AmaraAge; AmirAge = 0; AmaraAge = 0; cout<<“Please enter Amir’s age”; cin >> AmirAge; cout<<“Please enter Amara’s age”; cin >> AmaraAge; if AmirAge > AmaraAge) { cout << “\n”<< “Amir’s age is greater then Amara’s age” ; } }

  11. Flow Charting • There are different techniques that are used to analyse and design a program. We will use the flow chart technique. • A flow chart is a pictorial representation of a program. • There are labelled geometrical symbols, together with the arrows connecting one symbol with other.

  12. Flow Chart Symbols Start or stop Process Flow line Continuation mark Decision

  13. Example If the student age is greater than 18 or his height is greater than five feet then put him on the foot balll team Else Put him on the chess team

  14. Logical Operators AND && OR ||

  15. Logical Operators If a is greater than b AND c is greater than d In C if(a > b && c> d) if(age > 18 || height > 5)

  16. if-else if (condition) { statement ; - - } else { statement ; - - }

  17. Example • Code • if (AmirAge > AmaraAge) • { • cout<< “Amir is older than Amara” ; • } • if (AmirAge < AmaraAge) • { • cout<< “Amir is younger than Amara” ; • }

  18. Example Code if AmirAge > AmaraAge) { cout<< “Amir is older than Amara” ; } else { cout<<“Amir is younger than or of the same age as Amara” ; }

  19. Example If (AmirAge != AmaraAge) cout << “Amir and Amara’s Ages are not equal”;

  20. Unary Not operator ! • !true = false • !false = true

  21. Example if ((interMarks > 45) && (testMarks >= passMarks)) { cout << “ Welcome to LahoreUniversity”; }

  22. Nested if If (age > 18) { If(height > 5) { : } } Make a flowchart of this nested if structure…