Overview of programming language features
1 / 32

Overview of Programming Language Features - PowerPoint PPT Presentation

  • Uploaded on

3. Overview of Programming Language Features. AIM To develop further an understanding of the transition from the design phase to the program development phase OBJECTIVES Study languages in general, and programming languages in particular

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Overview of Programming Language Features' - nile

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Overview of programming language features


Overview of ProgrammingLanguage Features


To develop further an understanding of the transition from the design phase to the program development phase


  • Study languages in general, and programming languages in particular

  • Study the relationship between design notation and the facilities that mirror this in a modern programming language


Overview of programming language features 1326501

Languages: In General



  • All languages are subject to a set of rules governing

    • the set of valid characters that can be used

    • word construction

    • sentence construction

  • The rules of sentence construction are called syntax

  • To use a language correctly you need to know about these and

    • vocabulary - the set of valid words

    • semantics - ensuring that what is written makes sense

  • You need to be able to recognize language 'tokens'

Syntax rules
Syntax Rules

  • English language descriptions of language rules can be very cumbersome, and lead to ambiguity

  • Syntax diagrams are a neat way of expressing language rules

    • they should be completely unambiguous

    • they usually involve other syntactic elements (tokens)

  • What would a syntax diagram look like for

    • a word

    • a sentence

    • prose


The ability to read a syntax diagram is an important skill.

Syntax vs semantics
Syntax vs. Semantics

Syntax - the grammatical arrangement of words to show their connection and relation; the set of rules governing this arrangement.

Semantics - relate to meaning in language

  • A sentence in English may be syntactically correct

    • it obeys the language rules

  • But not necessarily semantically correct

    • it has no valid meaning

  • Both syntax and semantics are important


You’ve got to put the syntactic elements together so that they are both syntactically and semantically correct.

Overview of programming language features 1326501

Programming Language

Building Blocks


  • A computer program is like a set of instructions

  • Each instruction is termed a statement

  • Each program statement has a terminating character

  • Translate into syntax diagrams

Types of statement
Types Of Statement

  • It’s useful to categorize statements

    • type definitions - introduce new types

    • variable declarations - introduce new objects

    • assignment statements - involve a change in the value of an object

    • I/O statements

    • compound statements - a (bracketed) collection of statements

    • control-flow statements - change the normal linear flow of control (selection, repetition, function)

    • other forms of statement

Starting c programming


Starting C++Programming


To get started on programming in C++


  • Understand the Systems Development Life Cycle (SDLC)

  • Simple C++ statements

  • Program layout and style

  • Simple input and output in C++

  • Comments in C++


A first c program

Display a Greeting

#include <iostream.h>

int main()


cout << "Hello ";

cout << "Your name" << endl;

cout << "Welcome to MIS442" << endl;

return 0;





Display “Hello”

Display your name

Display “Welcome to MIS442”



Chapter 4



A First C++ Program


Try things out in small test programs to determine what C++ features do.

Overview of programming language features 1326501


Structure Of Simple C++


  • See syntax diagram simple C++ program

  • We’ll gradually introduce the different forms of statement that you can write in C++

    • The cout "..." ...; lines in the greeting program are statements that produce output

  • Special significance of main() and the braces { and }

  • Your programs must conform to the syntax rules of the language, as specified in the syntactic elements

  • The syntax rules allow the computer to distinguish between syntactically correct and syntactically incorrect programs

  • But what if a program doesn't conform?

C compile time errors



C++ Source

#include "..

int main()




} // end main()



Compiler Error Messages

Error: line 8


C++ Compile-Time Errors

  • What if you make a syntax mistake in your source program?


A single syntax error may give rise to multiple compiler error messages.


You’ll have to get used to the form of the compiler’s error messages.


It may be worth fixing the first source-code error and then recompiling.

Program layout and style


Program Layout And Style

  • Are either of these C++ fragments syntactically legal?

int main(){cout<<"Hello"


;cout<<"Welcome to MIS442"



int main(){cout<<"Hello"


;cout<<"Welcome to MIS442"

<<endl; return 0;}



The aesthetics of your program’s appearance to the human eye are very important.


Adopt sensible style rules and stick with them.

Overall layout of c programs
Overall Layout Of C++ Programs

  • C++ is a free-format language

  • The compiler ignores white space (spaces, tabs, end of line, blank lines) in most situations

#include <iostream.h>

int main()


cout << "Hello ";

cout << "Your name"

<< endl;

cout << "Welcome to MIS442"

<< endl;

return 0;


  • Use indentation and white space to make your programs more readable. The compiler doesn’t care about white space.

Simple i o in c


Simple I/O In C++

Design and write a program that asks a user to input their first name followed by their age in years, and then calculates and prints their age in hours.



I o in c conti
I/O In C++ (Conti.)

#include <iostream.h>

#include <cstring.h>

cin >>

cout <<

getline(cin, variable, ‘\n’);

#include <iomanip.h>





cout << ... << setw(9) << ... ;




  • Program statements alone are often not very readable

  • Often you wish to add some commentary to a program

  • Such comments give the reader additional information

  • There has to be a syntactic element in the language to permit this – see comment



// Source file name: hello.c

// A C++ program to print out a greeting message

// Edit the lines indicated below

// Include the information which defines the IO types

#include <iostream.h>

int main()


cout << "Hello ";

cout << "Your name" // Edit to your name

<< endl;

cout << "Welcome to MIS442" // Edit to your course

<< endl;

return 0;

} // end main()






Comments style rules

Chapter 4



Comments: Style Rules

  • A program without any comments is a bad program.

  • A comment should add something to the program.

  • And not just expand on the obvious.

  • Add comments while you are implementing your program.

  • Capture design abstractions as comments in the source code.

  • Use white space to improve their readability.

  • A source file should identify the name and purpose of the program, and its author and date.

  • Use a template for new programs.

Overview of programming language features 1326501


Systems /Software Development Life Cycle (SLC/ SDLC)

  • A method that provides information systems professionals with step-by-step procedures to develop their projects/systems.


1 problem conceptualization
1. (Problem) Conceptualization

  • Prepare a complete and unambiguous problem statement.

  • Users and analysts sign the requirements document.

2 analysis
2. Analysis

  • Understand the problem: develop a system behavior model and determine problem input, output, and other relevant data elements.

  • Name each identified data element and develop a model of the essential characteristics (attributes and operations) for each element.

3 design
3. Design

  • Using the system and data models developed during requirements analysis, perform a top-down design of the system.

  • For each system component, identify key data elements and subordinate functions using structure charts.

4 implementation
4. Implementation

  • Write algorithms and pseudocode descriptions of individual functions.

  • Code the solution.

  • Debug the code.

5 testing and verification
5. Testing and Verification

  • Test the code, verifying that it is correct. Each data modeling component should be tested separately, before all components are tested as an integrated whole.

  • Involve users and special testing teams in all system tests.

6 operation follow up and maintenance
6. Operation, Follow-up, and Maintenance

  • Run the completed system.

  • Evaluate its performance.

  • Remove new bugs as they are detected.

  • Make required changes to keep the system up to date.

  • Verify that changes are correct and that they do not adversely affect the system’s operation.

Overview of programming language features 1326501


Your first steps as a C++ programmer:

  • Use of syntax diagrams

  • Compile-time errors

  • Basic structure of simple C++ programs

  • Simple I/O in C++

  • C++ comments

    Your first steps as a software engineer:

  • Program layout and white space

  • Style rules

  • Use of comments to capture the design

  • Constructing test programs to see what C++ features do

More c examples
More C++ Examples

  • miles.cpp (p. 40)

  • Hello.cpp (p.55)

  • A Case Study: Finding The Value of A Coin Collection: Coins.cpp (p.82)

Sieve program
Sieve Program


Chapter 3




  • You now know about the importance of syntax and semantics

  • You know how to read syntax diagrams

  • You know about the basic features of programming languages

  • You should be able to recognize these features in many popular languages (especially C++)

  • But you don't know enough yet to be able to write programs ...

Age in hours program

variable names

#include <iostream.h>

#include "Text.h"

int main()


const double HOURS_YEAR = 365.0 * 24.0;

int age;

Text name;

cout << "What is your first name? ";

cin >> name;

cout << "and what is your age in years? ";

cin >> age;

cout << "Welcome to " << name

<< " who claims to be " << (age * HOURS_YEAR)

<< " hours young" << endl;

return 0;









Age-In-Hours Program


Drawing a square
Drawing A Square

Design and implement a program to draw a square.

int main()


// Create window and sideLength

// Input a value for sideLength

// Move to starting position

// Put the pen down

// Draw line forward

// Draw line up

// Draw line back

// Draw line down

return 0; //exit the program

} //end main()





A useful starting point is a set of comments expressing the design.