Choice of Programming Language

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

CSE 105 Structured Programming Language (C)
COSC 120 Computer Programming
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?
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
1 ICS103 Programming in C Lecture 2: Introduction to C (1)
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
C programming Language and Data Structure For DIT Students.
CHAPTER 1: INTORDUCTION TO C LANGUAGE
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Computer Science 210 Computer Organization Introduction to C.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use.
Programming With C.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
Introduction to Computer Systems and the Java Programming Language.
King Saud University College of applied studies and community services CSC 1101 Computer Programming I Lecture 2.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Lecture #5 Introduction to C++
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
An overview of C Language. Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's.
Introduction to C Programming
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 C Syntax and Semantics Dr. Sherif Mohamed Tawfik Lecture Two.
Chapter 1: Introduction to Computers and Programming.
Choice of Programming Language 1 All the information is stored in the memory must be in the form of binary. As such any program to be executed by the CPU.
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.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Software Engineering Algorithms, Compilers, & Lifecycle.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1.
by sir fakhri alam programing fundamental
Chapter 1 Introduction 2nd Semester H
Numbers in ‘C’ Two general categories: Integers Floats
CSCE 206 Structured Programming in C
Computer Science 210 Computer Organization
Lesson #2 Introduction to C.
Chapter 1: Introduction to computers and C++ Programming
CSC201: Computer Programming
Lesson #2 Introduction to C.
Introduction to the C Language
CSCI-235 Micro-Computer Applications
Completing the Problem-Solving Process
Introduction to C Language
CSE101-Lec#2 Programming Methodologies
C Programming Hardik H. Maheta.
C Language VIVA Questions with Answers
ICS103 Programming in C Lecture 3: Introduction to C (2)
Introduction to C++.
Getting Started with C.
Lecture2.
INTRODUCTION c is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs.
TRANSLATORS AND IDEs Key Revision Points.
Translators & Facilities of Languages
Computer Science 210 Computer Organization
Introduction to the C Language
Chapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C
Govt. Polytechnic,Dhangar
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Programming Fundamentals Lecture #3 Overview of Computer Programming
Chapter 11 Introduction to Programming in C
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Lesson #2 Introduction to C.
C programming Language
WEEK-2.
C++ Programming Basics
An Overview of C.
Presentation transcript:

Choice of Programming Language All the information is stored in the memory must be in the form of binary. As such any program to be executed by the CPU must be in the form of 0 and 1. Low-Level Programming Languages Machine Language All the instructions, commands, expressions and data are in the form of 0 and 1. Pros: CPU can understand the program and can execute (run) the program. Cons: Are extremely difficult to write or read programs.

ASSEMBLY LANGUAGE Assembly Language All the instructions are in the form of short and easily understood codes such as MOVE, ADD, SUB, JMP, etc. Data can be in Binary/Dec/Oct/ Hex. Pros: Much easier to work with than machine language. Cons: Still not easy to read or write. Example: TO ADD 5 TO 6 … MOVE #5, R1 MOVE #6, R2 ADD R1, R2, R3 Needs a translator program which converts the assembly code to 0 and 1. Since after all CPU can only work with 0 and 1s. This program is known as Compiler or, in the case of Assembly Language, Assembler. Note:

High Level Languages High-Level Programming Languages C Fortran Pascal Turing Example: TO ADD 5 TO 6 … sum = 5 + 6; These programming languages are easy to read/write since the instructions are English like sentences. we still need to compile & to link our program. Note:

Solving Problems Here are the steps required to solve a problem with a computer program: 1. Define the problem 2. Analyse the problem. 3. Design a solution. 4. Implement the solution. 5. Test the program. 6. Update and maintain the program.

Why teach C? C is small (only 32 keywords). C is common (lots of C code about). C is stable (the language doesn’t change much). C is quick running. C is the basis for many other languages (Java, C++, awk, Perl). It may not feel like it but C is one of the easiest languages to learn.

C : Introduction The language is called “C” because its direct ancestor was called “B”. C was created around 1972 by Kernighan and Ritchie.

Programming Facilities Generally there needs to be a number software applications that facilitate production of a program including: Editors, Complier, Library, Linker Programming Environment or Integrated Development Environment (IDE) An environment that has all the different programming tools needed for a particular programming language

Note: Collection of ‘C’ programming tools ‘C’ Environment Collection of ‘C’ programming tools Borland ‘C++’, Quincy All environments are operating under some OS. Above mentioned IDEs are available under the WINDOWS. Note:

Some programmer jargon Some words that will be used a lot: Source code: The stuff you type into the computer. The program you are writing. Compile (build): Taking source code and making a program that the computer can understand. Executable: The compiled program that the computer can run. Library: Added functions for C programming which are bolted on to do certain tasks. Header file: Files ending in .h which are included at the start of source code.

Data Types in ‘C’ Major data types Numbers: any numerical value. Characters: any item from set of characters used by C. Strings: a combination of characters. Void: any expression that does not have any value 10 10

Numbers in ‘C’ Two general categories: Integers Floats Unsigned – all positive integers Signed – positive and negative integers Floats 11 11

Constants in C There are 3 basic types of constants in C. An integer constant is an integer-valued number.We will concern here solely with decimal constants like 0, 1, 743, 5280, 32767 or -764. A floating point constant is a base-10 number than contains either a decimal point or an exponent or both like 0., 1., 0.2, 50.0, 12.3,-12.667, 2E-8 or 0.006e-3. A character constant is a single character enclosed in apostrophes like 'a', 'x', '9', or '?'.

Preprocessor directives Preprocessor: A system program that modifies the C program prior to compilation. Preprocessor directive: An instruction to the preprocessor. Begins with #. Library: A collection of functions, symbols and values. 2 kinds of preprocessor directives: includes and defines.

Preprocessor directives #include <stdio.h>: stdio.h, which stands for "standard input/output header", is the header in the C standard library that contains macro definitions, constants, and declarations of functions and types used for various standard input and output operations. The #include <stdio.h> directive must be included on top of every C program. #define PI 3.1416: this is a constant macro definition. It associates a name to a value for the duration of the program In this case it associates the symbol PI to the value 3.1416. It is an optional directive.

Comments Comments are lines of code that are ignored by the compiler. They are placed for the programmer's benefit. /* this is a comment */ /* this is another comment, it can be spread over multiple lines */

Instructions Instructions in C are terminated by a semi-colon (;) Line changes and tabs are not important to the C compiler. a=3; b=4; c=5; are the same as a=3; b=4; c=5;

Skeleton of a program #include <stdio.h> /* optional additional includes */ /* optional constant macros */ int main (void) { /* optional declarative statements */ /* one or more executable statements */ return (0); }

/* PROGRAM # 1 */ #include <stdio.h> /* This is my first C program. */ /* It’ll print a message to the display. */ int main (void ){ printf(“Welcome to the C programming language course!\n”); printf("This is our very first C program.\n"); printf(“We wish you a very pleasant experience with C.”); return (0); } 18 18

This is what we see after execution: 1st line: Welcome to the C programming language course! 2nd line: This is our very first C program. 3rd line: We wish you a very pleasant experience with C. 19 19

Conversion Decimal number to signed integer(32-bit)(2-compliment for negative numbers) -48 118 64 Binary to decimal 0000 0000 0000 0000 0000 0000 0111 1010

Choose the biased exponent (32-bits)(floating point numbers IEEE-754) -18 25 Binary to decimal(32-bit-floating point IEEE-754) 1100 0100 0011 0110 0001 0000 0000 0000