Fundamentals of Computer and programming in C Programming Languages, Programs and Programming Rohit Khokher.

Slides:



Advertisements
Similar presentations
CSE 105 Structured Programming Language (C)
Advertisements

Fundamental of C Programming Language and Basic Input / Output Function Lecture 2.
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
One Dimensional Arrays
Lecture 2 Introduction to C Programming
Introduction to C Programming
Principles of Programming Fundamental of C Programming Language and Basic Input/Output Function 1.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Three types of computer languages
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Principles of Programming - NI Chapter 3 Fundamental of C Programming Language and Basic Input/Output Function.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
C - Input & Output When we are saying Input that means to feed some data into program. This can be given in the form of file or from command line. C programming.
Computer Science 210 Computer Organization Introduction to C.
Welcome In The World Of ‘C’.  TEXT BOOK: Programming in ANCI ‘C By: E Balagurusamy. TMH  Reference Books: 1) The ‘C Programming Language By: Kernighan.
CIS Computer Programming Logic
INTRODUCTION TO PROGRAMMING, ALGORITHMS & FLOWCHARTS Programming in C2 CHAPTER 1.
C Programming language
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
Syntax and Semantics, and the Program Development Process ROBERT REAVES.
The Software Construction Process. Computer System Components Central Processing Unit (Microprocessor)
Khalid Rasheed Shaikh Computer Programming Theory 1.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
1 Overview of Programming Principles of Computers.
FUNCTIONS. Midterm questions (1-10) review 1. Every line in a C program should end with a semicolon. 2. In C language lowercase letters are significant.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
C is a high level language (HLL)
Introduction to Computer Programming using Fortran 77.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Chapter 1 slides1 What is C? A high-level language that is extremely useful for engineering computations. A computer language that has endured for almost.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Lecture 3 Translation.
Lecture2.
Chapter Topics The Basics of a C++ Program Data Types
Computer Science 210 Computer Organization
Engineering Problem Solving With C An Object Based Approach
Chapter 1: Introduction to computers and C++ Programming
Introduction to the C Language
BASIC ELEMENTS OF A COMPUTER PROGRAM
Chapter 2 - Introduction to C Programming
Basic Elements of C++.
Revision Lecture
Chapter 2 - Introduction to C Programming
Lecture2.
Welcome In The World Of ‘C’.  TEXT BOOK: Programming in ANSI ‘C By: E Balagurusamy. TMH  Reference Books: 1) The ‘C Programming Language By: Kernighan.
Basic Elements of C++ Chapter 2.
Computer Science 210 Computer Organization
Introduction to the C Language
Computer Programming Machine and Assembly.
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
CSCE Fall 2013 Prof. Jennifer L. Welch.
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Lecture3.
CSCE Fall 2012 Prof. Jennifer L. Welch.
Chapter 2 - Introduction to C Programming
The Von Neumann Machine
Chapter 6 Programming the basic computer
DATA TYPES There are four basic data types associated with variables:
Introduction to C Programming
Presentation transcript:

Fundamentals of Computer and programming in C Programming Languages, Programs and Programming Rohit Khokher

Concepts: Programming Languages, Programs and Programming Programs A set of statements written in a Programming Language and arranged in a specified structure. Executable Non-executable Machine Assembly High level Main programs Sub-programs ADDAB A+B Operation code Operand

Executable statements Non-executable statement Declarations (definitions) Data type declarations o integer data type. o Floating point data type. o Character data type. Variable declarations Constant declarations Program type declarations o Main program o Subprogram Perform Arithmetic operations Logical operations Transfer execution control operations Cause iteration Data movement operations o Input devices to memory o Memory to output devices o Memory to memory o Memory to register o Register to memory

Structures The structure of a main program in C language Preprocessor declarations Type declarations Variable declarations (global) void main () { local declarations Executable statements } Function (subprogram) declarations #include void main () { printf (“ \n I am in the main program”); } Stdio.h is a collection of subprograms for input and output operations like printf (). No declaration (empty) Main is an address in the memory. It may contain a data. Void indicates the type of the data will be determined when it will contain a data value. No declaration (empty)

#include void main () void main () { printf (“ \n I am in the main program”); } Code Segment Data Segment Iaminthemmainprogram Compiler  Checks the syntax  Generates codes Compiler  Checks the syntax  Generates codes Loader/ Linker/ Binder Loads Loader/ Linker/ Binder Loads Data in Data segment Code in code segment main Stdio.h Printf Data address PC Compilation & execution of a program

Algorithm Example Suppose you are given a set of mark sheets where each mark sheet bears A, B, C or F letter grade. Write an algorithm to read mark sheet and print the grade that it contains. 1.Start 2.Take a mark sheet and read the grade. 3.Print the grade 4.Stop #include void main() { char c; printf ("\n enter the letter grade "); c=getchar(); printf ("\n Grade= "); putchar(c); gets(""); } #include void main() { char c; printf ("\n enter the letter grade "); c=getchar(); printf ("\n Grade= "); putchar(c); gets(""); }

Algorithm Example 2 Suppose you are given a set of mark sheets where each mark sheet bears A, B, C or F grade. Write an algorithm to read a mark sheet and print if the grade is A only. 1.Start 2.Take a mark sheet and read the grade. 3.If grade is A then Print the grade 4.Stop #include void main() { // reading and writing characters char c; printf ("\n enter the letter grade"); c=getchar(); if( c =='A') { printf("\n The grade is = "); putchar(c); } #include void main() { // reading and writing characters char c; printf ("\n enter the letter grade"); c=getchar(); if( c =='A') { printf("\n The grade is = "); putchar(c); } }

Algorithm Example 3 Suppose you are given a set of mark sheets where each mark sheet bears A, B, C or F grade. Write an algorithm to read a mark sheet and print the grade if it is A or B only. 1.Start 2.Take a mark sheet and read the grade. 3.If grade is A or B then Print the grade 4.Stop #include void main() { // reading and writing characters char c; printf ("\n enter the letter grade"); c=getchar(); If (( c =='A') | ( c =='B')) { printf("\n The grade is = "); putchar(c); } #include void main() { // reading and writing characters char c; printf ("\n enter the letter grade"); c=getchar(); If (( c =='A') | ( c =='B')) { printf("\n The grade is = "); putchar(c); } }

Summary Program – Main program – Subprogram Statements – Executable – Non executable Programming Language – Machine Language – Assembly Language – High level Language Structure Main program Subprograms (functions) Blocks Compilers Loaders Linkers Interpreter s