Fundamental of Programming(101)
Why study Programming Language Concepts? Increased capacity to express programming concepts Improved background for choosing appropriate languages Increased ability to learn new languages Understanding the significance of implementation Increased ability to design new languages Overall advancement of computing
Evaluation Scheme Evaluation Scheme The academic performance of student is based on Continuous Internal Assessment (CIA) and Semester End Examinations (SEE). parameters of CIA Unit Test Quiz Assignments Seminar 2 Internal Test SEE INCLUDE 2 HOURS PRACTICAL AND 3 HOURS THOERY EXAM.
Reference Books: Text Books: 1. Farrell Joyce, Programming Logic and Design, Course Technology. 2. Behrouz Forouzan, Richard Giberg, Computer Science- A Structure Approach Using C, Cengage Learning Question Bank utu.ac.in
Unit-1 Introduction of Computers, Logic and Structure
1.1 Computer Components and Operations Programming Paradigm
Computer Components 1. Hardware Hardware is the equipment, or the devices, associated with Computer. for example Monitor, Keyboard, Mouse, Printer etc.
Computer Components 2. Software Computer Software are programs that tell the computer what to do given by the instructions. It is classify into two categories: 1.Systems Software : Includes the operating system and all the utilities that enable the computer to function. 2.Applications Software: Includes programs that do real work for users. For example, word processors, spreadsheets
Computer H/W & S/W accomplish four major operations: Input Processing Output Storage
Information Processing cycle--1 Processor Control Unit/Arithmetic Logic Unit Memory Storage Devices Input Devices Output Devices
Input Devices Any hardware component that allows you to enter data, programs, commands, and user responses into a computer Input Device Examples Keyboard Mouse
Output Devices Output devices make the information resulting from processing available for use Output Device Examples ◦ Printers Impact Nonimpact Photo ◦ Display Devices CRT LCD
Storage Devices 1. Internal storage(Main Memory or Primary Memory) Use to store inside the machine. It is Volatile (contents are lost every time the computer loses power) 2.External Storage Use to store outside the machine. It is Non-Volatile Examples of external storage are: floppy-disk, hard disk or magnetic tape
Information Processing cycle--2 Processing Input Devices Output Devices Programming Languages Machine Languages Complier / Interpreter
source code for a program has been written by one or more humans in a programming language(or High level Language) (e.g., C or C++), it is compiled (i.e., converted) into machine code by a specialized program called a compiler, or by Interpreter. (converted language is known as machine language or low level language(o and 1 )This machine code is then stored as an executable file (i.e., a ready-to-run program) and can be executed (i.e., run) by the operating system.
1.2 Programming Process: Problem Understanding, Planning, Coding, Translation, Testing and Production
Programming process broken down into six steps: Understand the problem Plan the logic Code the program Translate the program Test the program Put the program into production
Understand the problem Analyze use needs and requirements Plan the logic Give the instructions to the computer in specific sequence this is called developing the logic Most common tools are: 1) Flowcharts 2) Pseudo code
Code the program To follow certain rules for giving instruction to machine is called syntax of the language Translate The program High-Level and low-level Language Test the program Logical and syntax errors Put the program into production if program is tested,the organization can use it by putting into production.
1.3 Data Hierarchy, Flowchart Symbols, Pseudo code Statements and Connector
Data Hierarchy File Record Field Character
Flowchart Symbols, Pseudo code Statements and Connector Flow Chart A flow chart is a pictorial representation of the logical steps to solve a problem. Pseudo code Pseudo code is a kind of structured English for describing algorithms. It allows the designer to focus on the logic of the algorithm without being distracted by details of language syntax.
Flowchart Symbols
Connector A connector will be used when limited page size forces to continue the flowchart on another page. Start Step -1 Step -2 1 Stop Step -3 Step -4 1
1.4 Variables, Data Types and Evolution of Programming Techniques
Variable A variable is a value that can change any time. It is a memory location used to store a data value. A variable name should be carefully chosen by the programmer so that its use is reflected in a useful way in the entire program. Example of variable names are: Sun number Salary Emp_name average1
Rules of Variables They must begin with a letter some system permit underscores as the first character. Length of variable should not be normally more than eight characters. Uppercase and lowercase are significant. That is the variable Total is not the same as total or TOTAL. The variable name should not be a keyword White space is not allowed.
Keywords and Identifies Keywords and Identifies Every C word is classified as either a Keyword or identifier. Keywords are the words whose meaning has already been explained to the C compiler. for example Auto, Break,Case,Char,Const,Continue,Default,Do,Double, Enum Identifiers refer to the names of variable, functions and arrays. These are user defined names and consist of a sequence of letter and digits
Data Type C support three types of data type 1.Primary ( int, char etc) 2.Derived (array, structure) 3.User defined (enum, type def)
Data Type Range BytesFormat Signed char-128 to % c Unsigned Char0 to 255 1% c Short signed int Signed int to % d Short unsigned int0 to % u Long signed int-2,14,74,83,648 to +2 14,74,83,647 4% ld Long unsigned int0 to 4,29,49,67,295 4% lu Float-3.4e38 to +3.4e38 4% f Double-1.7e308 to +1.7e308 8% lf Long double-1.7e4932 to +1.7e % Lf
1.5 Unstructured Spaghetti Code and Recognizing Structure
Unstructured / Spaghetti Code The popular name for unstructured program organization is spaghetti code. logic is free to jump from one place to anywhere else in the a program
1.6 Storae classes, basic structure & its reasons
The Sequence Structure A structure is a basic unit of programming logic; each structure is a sequence, selection, or loop.here with we can perform actions in order.
Selection Structure
Dual Branch Selection
A Repetition Structure programmers refer to looping as repetition or iteration
Stacking Structures
Nesting Structure Placing a structure within another structure is called nesting the structures
Priming Read
Understanding the Reasons for Structure Three structures(sequence, selection, and loop) is better for the following reasons: Clarity Professionalism Efficiency Maintenance
1.7 Special Structures
Case(selection)Structure Use the Case structure when there are several distinct possible values for a single variable being tested and each value requires different actions
Case(selection)Structure
The Do Until Loop
The Do While Loop