Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

C++ Programming Club-Lecture 1


Published on

In this lecture you will learn linear programming that is simple input, processing and output
You will get the basic knowledge about syntax.

  • Be the first to comment

C++ Programming Club-Lecture 1

  1. 1. C++ Programming Club Lecture 1
  2. 2. Steps needed for solving a programming problemSoftware engineering steps:• Problem definition & analysis: Identifying inputs/outputs of a problem. Develop a list of variables & indicate their relationship.• Algorithm development: Pseudo code or flowchart.• Coding: Converting algorithm into a programming language.• Testing & Debugging (1)
  3. 3. Programming AlgorithmsGeneral form of a computer algorithm: INPUT → PROCESSING → OUTPUTAlgorithm types: pseudo code & flowchart.Pseudo code is the steps of an algorithm written inconcise natural language for problem solving.Example: Ohms law.1. Start.2. Input resistor R & voltage V values.3. Compute current I = V/R.4. Output I (Current).5. Stop. (2)
  4. 4. Commands for the C++ preprocessor.Preprocessor Lines beginning with # are preprocessor Directive directives. C++ contains one or more functions, Main the main function must be one of them. Function Declaration Within the main function all variables must be declared to the compiler. Block Statement Statement block contains the Block program statements. (3)
  5. 5. A SIMPLE C++ PROGRAM Remarks for program clearity. These are not compiled//A Welcome Messege It’s a type of pre- processor directive .It#include<iostream> enable the compiler toUsing name space std; recognize i/p and o/p.Void main () Function that accepts{ And returns no value. {} is used for opening and closing a function.cout<<“Welcome to C++!”<<endl; Output statement that displays text on screenSystem (“pause”); All statements end} with a ; Written so that the command prompt does not quickly disappear but (4) remains on the screen.
  6. 6. • C++ Data TypesBut we shall be only dealing with Interger , Character andFloating point! (5)
  7. 7. How To Find Out The Force Exerted On An Object By Using C++// Finding out the force#include <iostream>using namespace std;Void main (){ float f,m,a; // variables that will be usedcout<<“Please enter the mass:”; //Displayed on the screencin>>m; // First Inputcout<<“Please enter the area:” // Displayed on the screencin>>a; //Second Inputf=m*a; //Processingcout<<f<<endl; //Outputsystem (“pause”);} (6)
  8. 8. • Home Work1.Write an assignment statement to calculatethe circumference of a circle. The formula fordetermining the circumference, c, of acircle is c = 2*pi*r, where r is the radius and piequals 3.1416.2. Write an assignment statement to converttemperature in degrees Fahrenheitto degrees Celsius. The formula for thisconversion is Celsius = 5/9 (Fahrenheit - 32). (7)