1.1 Introduction to C Language. Department of CSE

Size: px
Start display at page:

Download "1.1 Introduction to C Language. Department of CSE"

Transcription

1 1.1 Introduction to C Language 1 Department of CSE

2 Objectives To understand the structure of a C-Language Program To write a minimal C program To introduce the include preprocessor command To be able to create good identifiers for quantities in a program To be able to list, describe and use the basic data types in C To be able to create and use variables and constants in a C program 2 Department of CSE

3 Agenda Background of C Language Structure of a C program C Comments Identifiers in C Data types in C Variables in C Constants in C 3 Department of CSE

4 Background of C C is a middle level language it combines the best elements of high-level languages with the control and flexibility of assembly language Like most modern languages, C is also derived from ALGOL 60 (1960) Developed by Dennis Ritchie in 1972 using many concepts from its predecessors ALGOL,BCPL and B and by adding the concept of data types American National Standards Institute (ANSI) began the standardization of C in 1983 which was approved in 1989 In 1990 International Standards Organization (ISO) adopted the ANSI standard version known as C89 Minor changes were made to C89 in 1995 which came to be known as C95 Much more significant updates were made in 1999 and named as C99 4 Department of CSE

5 Features of C C is a structured programming language which allows compartmentalization of code and data A structured language offers a variety of programming possibilities. For example, structured languages typically support several loop constructs, such as while, do-while, and for. A structured language allows one to place statements anywhere on a line and does not require a strict field concept In a structured language, the use of goto is either prohibited or discouraged and is not the common form of program control 5 Department of CSE

6 Structure of a C Program Preprocessor Directives Global Declarations int main (parameter list) { Local Declarations Statements } Other functions as required To include standard input/output library file in the program Describes the data which is visible to all parts of the program (optional) main function is the starting point of every C program One and only one function must be named main in a C program Describes the data used in the function Visible only inside the function (optional) Follows the local declaration section Contains the instructions for the computer to do something (e.g., add two numbers) Optional functions also called modules similar to main to accomplish specific tasks 6 Department of CSE

7 Dissecting a minimal C program #include <stdio.h> int main(void) { printf( Welcome to Computer Programming ); return 0; } Preprocessor Directive to include stdio.h file main function Instruction to print a message Instruction to stop the program The first C program has Preprocessor Commands which are placed at the beginning of the program starting with # sign can start at any column but traditionally start at column 1 tells the compiler to include standard input/output library file (stdio.h) in the program which is needed for printing the welcome message on the screen must be typed exactly as shown above without any space between # and include and the file name is written between < and >. 7 Department of CSE

8 Dissecting the minimal C program General Syntax (writing format) of a Preprocessor Directive is #include<filename.extension> Examples: #include<stdio.h> - Required for using input/ output instructions #include<string.h> - Required for using pre-defined string functions #include<math.h> - Required for using pre-defined math functions Main function Executable part of the program begins with main function General Syntax: int main(void) The word int before the main indicates that the function will return an integer value to the operating system Since in this program main does not require any parameters, the parameter list is specified as void

9 Creating and Compiling the minimal C program In the linux environment, locate gedit and open the editor Type in the minimal C program exactly with all puncuations as follows #include <stdio.h> int main(void) { printf( Welcome to Computer Programming ); return 0; } After typing the preceding source code, save the program as welcome.c. Instead of welcome, any name can be chosen, but the extension must be.c. This extension is the common convention in C programs and identifies the contents of the file as C source code. Most compilers will expect the source file to have the extension.c, and if it doesn t, the compiler may refuse to process it. After saving the program, locate terminal and type cc welcome.c near the $ symbol

10 Executing the minimal C program If the program is present in the correct path and is error free, the compilation results in a $ being displayed right below the previous command typed If there is a syntax error, open the file again using gedit, locate the line number indicated by the compiler and do the necessary corrections If the compiler says file not found, change into the folder which contains the program to be compiled and repeat the compilation step Upon successful compilation, type./a.out at the $ prompt and the program must print Welcome to Computer Programming

11 Summary of writing and executing a C program

12 C Comments Placed by the programmer in the code to help the reader to understand the meaning of sections of code which are not very clear Comments are merely internal program documentations Compiler ignores the comments when it translates the program into executable code To identify a comment, C uses two different comment formats: Line Comment Block Comment

13 Line Comment The Second format, the line comment uses two slashes - // to identify a comment This format does not require an end-of-comment token The end of line automatically ends the comment Programmers generally use this format for short comments The line comment can start anywhere on a line and ends with the end of that line Examples of Line Comment: //This is a whole line comment A=5; //This is a partial line comment

14 Block Comment Block comment is used when a comment spans several lines It uses opening and closing comment tokens Each comment token is made up of two characters without spaces in between them The opening comment token is represented as /* The closing comment token is represented as */ Everything that is placed in between /* and */ is ignored by the compiler The block comments can start in any column and they need not both be on the same line The only restriction is that the opening token /* must precede the closing token */

15 Block Comment - Examples /* This is a block comment that covers one line*/ /* This is a block comment that covers two lines*/ /* */ **Block comments can also be designed with the opening **comment on a separate line and closing comment on a **separate line. Some programmers also put at the beginning of **each line in between to clearly mark the documentation part.

16 Caution with Comments Comments cannot be nested i.e., comments cannot be given inside comments Example: /* This is an /*inner comment*/outer comment*/ ignored Matches the first /* Left without an opening /* Once the compiler sees an opening block comment token /*, it ignores everything it sees until it finds a closing token */ Therefore, the opening token of the nested comment is not recognized and the closing token of the nested comment matches the outer opening comment thereby leaving the closing token of the outer comment without a matching opening token

17 Minimal C program revisited with comments /* Welcome to the minimal C program. This program demonstrates a small C program */ Written by: name Date: program written date #include <stdio.h> int main(void) { //main begins here // this is a preprocessor directive // this is the main function //No local declarations needed for this simple program //Statements printf( Welcome to Computer Programming ); //This is a print statement return 0; //returns the control back to the operating system } //main ends here

18 The C Character Set Character set specifies the valid symbols that can be used in a C program The C character set consists of the following symbols and escape sequence characters

19 Escape Sequence characters Escape sequence characters are a combination of two characters but treated as a single character. Often used in printf statements,they are not printed explicitly on the screen but the effect of these characters can be observed. The table beside shows some ASCII characters and their corresponding escape character format ASCII Character Escape representation null character \0 alert (bell) \a backspace \b horizontal tab \t newline \n vertical tab \v form feed \f carriage return \r single quote \ double quote \ backslach \\

20 Exercises Write a program that will output your name and address using a separate printf() statement for each line of output Write a program to print the pattern of asterisks as shown below Write a program to print the following figure using suitable characters

21 Solutions to Exercises #include<stdio.h> int main() { printf("raghesh Krishnan K, "); printf("asst.professor, CSE Dept, "); printf("amrita School of Engineering, "); printf("amrita Vishwa Vidyapeetham, "); printf("amrita Nagar Post, "); printf("coimbatore "); return 0; }

22 Solutions to Exercises //Prints a triangular pattern - Author: Raghesh Krishnan K #include<stdio.h> int main() { printf("*\n"); //prints first line printf("*\t*\n"); printf("*\t*\t*\n"); printf("*\t*\t*\t*\n"); //prints last line return 0; }

23 Solutions to Exercises //Prints a pattern - Author: Raghesh Krishnan K #include<stdio.h> int main() { printf(" \n"); //prints the top horizontal bar printf(" >>---> \n"); /* prints vertical bars*/ printf(" \n"); printf(" \n"); //prints the top horizontal bar return 0; }

24 Identifiers in C (Recollect Name Bindings in CTPS) Identifiers allow us to name data and other user created components in a program Each identified component is stored at a unique location in the computer s memory With no identifiers to symbolically represent data locations, we should know and use the component s memory address Using Identifiers, we simply name the data and let the computer keep track of where they are physically located in the computer s memory

25 Rules for Identifiers in C The only valid alphabets to be used for naming are upper case letters from A to Z and lower case letters from a to z _ (underscore) is the only special symbol that can be used in an identifier Numeric symbols from 0 to 9 can be used but the first symbol of an identifier cannot be a numeric symbol The first symbol of an identifier must be an alphabet or an underscore Typically application programs do not use underscore as the first symbol because many of the identifiers in C system libraries start with an underscore Duplication of system names for identifiers could be confusing Last but not the least, C has 32 keywords also known as reserved words, which have a predefined meaning and cannot be used as identifier names.

26 Some Keywords/Reserved words in C

27 Examples of Valid and Invalid Identifier Names Valid Names Invalid Names a //valid but poor style $sum //$ not allowed student_name //ok 2names //first character should not be a digit _asystemname //valid but similar to system identifier pattern Sum-salary //Hyphen not allowed _Bool //Boolean System id Stdnt Nmbr //Spaces not allowed INT_MIN //System Defined Value int //keyword not allowed

28 Exercises: Identify whether the following identifiers are valid. If not give reason and correct them (a) record1 (b) #tax (c) name_and_address (d) 1record (e) name (f) name-and-address (g)file_3 (h) name and address (i) return (j) Assume a version of C that can recognize only the first 8 characters of an identifier name, though the identifier names can be arbitrarily long. Which of the following pairs of identifier names are considered to be identical and which are distinct? (a) name, names (b) address, Address (c) list1, Iist2 (d) char1,char_1 (e) identifier_1, identifier_2 (f) answer, ANSWER

29 Solution to Exercises (a) record1 - valid (b) #tax - invalid (#character not allowed) (c) name_and_address - valid (d) 1record invalid first character cannot be a number (e) name valid (f) name-and-address invalid (hyphen not allowed) (g)file_3 - valid (h) name and address - invalid (spaces not allowed) (i) return invalid (keyword) (j) invalid (contains all numbers) (a) name, names - distinct (b) address, Address - distinct (c) list1, Iist2 distinct (d) char1,char_1 - distinct (e) identifier_1, identifier_2 - identical (f) answer, ANSWER - distinct

30 Types in C A type defines a set of values and a set of operations that can be applied on those values For example a light switch can be compared to a type It can have two values on and off Only two operations can be applied to the light switch: turn on and turn off The defined set of types in C can be divided into four general categories: void, integral, floating-point and derived

31 Types in C C Types void Integral Floating Point Derived Boolean Character Integer Real Imaginary Complex

32 Types in C Void type: Is designated by the key word void Has no values and no operations Very useful type Used in cases where a function has no parameters or return values and for many other purposes which will be covered in the forthcoming topics Integral type: Integral types cannot contain fractional parts i.e., they can contain only whole number quantities C Language has three kinds of integral types: Boolean, Character and Integer

33 Types in C Boolean: Can represent only two values: true or false Is referred to by the key word bool Boolean type is stored in the memory as 0 or 1 Character: A character data type holds any single symbol from the C character set Is referred to by the key word char The size of a character is 1 byte or 8 bits Integer: Is a number without a fraction part (whole numbers) C supports four different sizes of integer data types: short int, int, long int and long long int C defines these data types so that they can be organized from smallest to largest

34 Types in C Integer Type No of Bytes Minimum value that can be stored Maximum Value that can be stored short int 2-32,768 32,767 int 4-2,147,483,648 2,147,483,647 long int 4-2,147,483,648 2,147,483,647 long long int 8-9,223,372,036,854,775,807 9,223,372,036,854,775,806 A short int can also be referred to as short A long int can also be referred to as long A long long int can also be referred to as long long Although the size of a data type is machine dependent, c requires the following relation ship to be always true: size of short <= size of int <=size of long <= size of long long

35 Types in C Depending on the usage of sign, each integer size can be of two forms signed and unsigned If the integer is a signed number, one bit must be used for sign Positive sign is indicated by a sign bit with 0 value For example, assuming 16 bit representation, the integer number 5 is represented as Negative sign is indicated by a sign bit with 1 value For example, assuming 16 bit representation, the integer number -5 is represented as Unsigned integer can store a positive number that is twice as large as the signed integer of same size However the actual sizes are dependent on the physical hardware

36 Types in C Floating Point: C standard recognizes 3 floating point types: real, imaginary and complex Real: Real type holds values that consists of an integral and a fractional part e.g., Real type can further be classified into three different types based on size as float, double and long double Similar to integer data type, C defines the real types so that they can be organized from smallest to largest Regardless of machine type, C requires the following relationship to be true: size of float <= size of double<=size of long double

37 Types in C Integer No of Minimum value Maximum Value Type Bytes that can be stored that can be stored float e e 38 double e e 308 long double e e+493

38 Types in C Imaginary type: Imaginary types is one of the components of complex type Similar to real type can be of three different sizes: float imaginary, double imaginary and long imaginary Most C implementations do not support the imaginary type yet and the functions to handle them are not a part of the standard Complex Type: Implemented by most compilers Similar to real type can be of three different sizes: float complex, double complex and long long complex The size needs to be the same in both real and imaginary part

39 Summary of Types in C Category Type C Implementation Void Void void Integral Boolean bool Character char Integer short int, int, long int, long long int Floating-Point Real float, double, long double Imaginar y Complex float imaginary, double imaginary, long double imaginary float complex, double complex, long double complex

40 Variables in C (Recall Name bindings in CTPS) Variables are named memory locations which have a type such as integer or character The type specified for a variable determines the values that a variable may contain and the operations that may be used with its values Variable Declaration: Each variable in a program must be declared and defined A C declaration is giving name to a variable While creating variables, declaration gives them a symbolic name Generally speaking where a variable is located in memory is not a programmer s concern, it is a concern of a compiler A Programmer must be able to access the data through their symbolic names, i.e., identifiers or variables

41 Variables in C Variable Definition: Definitions are used to create the variable Definition of a C variable assumes that declaration has been done already or is being done at the same time as definition Once defined, variables are used to hold the data required by the program for its operation Definition reserves memory for the variables

42 Variables in C Some Examples of Variable declaration and definition are illustrated below: char option; Variable s identifier int i; long long natl_debt; Variable s type float payrate; double pi; A variable can be of type except void. To create a variable, first specify the type, which automatically specifies its size (precision) and then its identifier For example float price; denotes the definition of a real variable named price of type float

43 Variables in C Some examples of different styles of readable variable declarations and definitions: bool fact; short maxitems; //Usage of a capital letter (I) as a word separator long long pi_value; // usage of underscore as word separator float payrate; //Usage of a capital letter (I) as a word separator double tax; float complex voltage; int a,b; //Multiple variables of same type declared on same line char option, kind

44 Variables in C Variable initialization When variables are defined they usually contain meaningless values left over in the memory space from previous use Hence there is a need to store data in them by initialization before accessing the values to avoid unwanted bugs in the program With a few exceptions (seen later) variables are not initialized automatically A variable is initialized with the prescribed data required when the function starts A variable can be initialized at the time of declaration using an initializer An initializer, when present establishes the first value that the variable will contain To initialize a variable when it is defined, the identifier is followed by an = sign and then the initializer, which is the value the variable is to contain when the function starts An example initialization format is shown below: int count = 0; Every time the function containing count is entered, count is set to zero

45 Variables in C What will be the result of the following initialization? int count, sum=0; Are both count and sum initialized or only sum is initialized? Answer: The initializer applies only to the variable defined immediately before it Therefore only sum is initialized! If both variables need to be initialized, then provide two initializers as shown below: int count = 0, sum =0;

46 Variables in C To avoid confusion and error, only one declaration could be specified per line as follows: int count = 0; int sum =0; Let us revisit the example of variable declaration and definition along with initialization and the memory representation char option = y ; int i = 25; long long natl_debt = ; float payrate = 25.50; double pi = ; Program B 14 option i natl_debt payrate pi Memory Representation

47 Constants in C Constants are data values that cannot be changed during the execution of a program Like variables, constants also have a type Boolean, character, integer, real, complex and string constants are some types of constants Boolean Constants A boolean value can have only one of the two values 0 (false) or 1 (true) The usage of a boolean constant requires the use of the boolean library stdbool.h

48 Constants in C Character Constants Character constant is a character or symbol from the character set enclosed between two single quotes e.g., a Escape characters A character preceded by a backslash \ enclosed in a pair of single quotes e.g., \n The backslash is known as an escape character It is used when the represented character does not have any graphic associated with it i.e., when it cannot be printed or entered from a keyboard The escape character signifies that what follows is not a normal character but something else For example \n inserts a line feed also known as new-line character

49 Constants in C Examples of representing integer constants Representation Value Type int int L -32,371 long int 76542LU 76,542 unsigned long it LL 12,789,845 long long int

50 Constants in C Real Constants Default form of real constant is double To have the resulting data type to be float or long double, corresponding code must be used to specify the desired data type f and F are used for float and l and L are used for long double Upper case alphabets are recommended for representing the codes Representation Value Type double double double double -2.0f -2.0 float L long double

51 Constants in C Complex constants Are widely used in engineering Coded as two parts real part and imaginary part, separated by a plus sign Real part is coded using the real format rules Imaginary part is coded as a real number times (*) the imaginary constant (_Complex_I) If the complex.h library is included, the imaginary part can be abbreviated as I Representation Value Type * I * (-1) 1/2 double complex 14F + 16F * I * (-1) 1/2 float complex L L * I * (-1) 1/2 long double complex

52 Constants in C String Constants A string constant is a sequence of zero or more characters enclosed in double quotes Examples of strings // a null string h // a string containing only a single letter h (not a //character) Hello world\n HOW ARE YOU Good Morning! Difference between a null character \0 and a null string Null character represents no value As a character it is 8 zero bits An empty string on the other hand is a string containing nothing Single quotes are used for character constants and double quotes are used for string constants

53 Constants in C Coding constants There are three different ways to code constants in programs literal constants, defined constants and memory constants Literal Constants A literal is an unnamed constant used to specify data If it is known that the data value cannot be changed, the data value is itself coded in a statement Literals are coded as a part of a statement using the constant format described previously For example, the literal 5 is used in the following statement a = b + 5;

54 Constants in C Defined Constants Another way to designate a constant using the preprocessor #define Like all preprocessor commands, it is prefixed with # (pound sign) The defined constants are usually placed at the beginning of a program (although they are legal anywhere in the program) Placing them at the beginning of the program makes them easy to find and change An example for a typical define command may be #define SALES_TAX_RATE.0825 The sales tax rate may change more often and it and other similar constants at the beginning of the program enables one to find and change them easily

55 Constants in C When the preprocessor formats the program for the language translator, it replaces each defined name SALES_TAX_RATE with its defined value (.0825) wherever it is found in the source program The preprocessor does not evaluate the definition in any way it just blindly makes the substitution Memory Constants Memory constants use a C type qualifier const to indicate that the data cannot be changed The syntax or format of a memory constant is const type identifier = value;

56 Constants in C A variable declaration does nothing more than giving a type and size to a named object in memory A Memory constant const fixes the contents of the memory location such that it cannot be changed This is similar to the concept of literal but it is named The following code creats a memory constant cpi To indicate that it is a constant, it is prefixed with c Example: const float cpi = ; Points to be observed The type qualifier comes first There must be an initializer If there is no initializer then cpi would contain whatever was present in the memory location assigned to cpi Finally since cpi is a constant, it cannot be changed

57 What has been discussed? Background of C Language Writing, Compiling and Executing C Programs Comments in C language How to make valid and good identifiers in C Basic data types in C Declaring and defining variables in C Different types of constants in C

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

C Language, Token, Keywords, Constant, variable

C Language, Token, Keywords, Constant, variable C Language, Token, Keywords, Constant, variable A language written by Brian Kernighan and Dennis Ritchie. This was to be the language that UNIX was written in to become the first "portable" language. C

More information

BITG 1233: Introduction to C++

BITG 1233: Introduction to C++ BITG 1233: Introduction to C++ 1 Learning Outcomes At the end of this lecture, you should be able to: Identify basic structure of C++ program (pg 3) Describe the concepts of : Character set. (pg 11) Token

More information

VARIABLES AND CONSTANTS

VARIABLES AND CONSTANTS UNIT 3 Structure VARIABLES AND CONSTANTS Variables and Constants 3.0 Introduction 3.1 Objectives 3.2 Character Set 3.3 Identifiers and Keywords 3.3.1 Rules for Forming Identifiers 3.3.2 Keywords 3.4 Data

More information

PROGRAMMAZIONE I A.A. 2018/2019

PROGRAMMAZIONE I A.A. 2018/2019 PROGRAMMAZIONE I A.A. 2018/2019 COMMENTS COMMENTS There are two ways to insert a comment in C: üblock comments begin with /* and end with */, and üline comments begin with // and end with the next new

More information

DECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA.

DECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA. DECLARATIONS Character Set, Keywords, Identifiers, Constants, Variables Character Set C uses the uppercase letters A to Z. C uses the lowercase letters a to z. C uses digits 0 to 9. C uses certain Special

More information

Intro to Computer Programming (ICP) Rab Nawaz Jadoon

Intro to Computer Programming (ICP) Rab Nawaz Jadoon Intro to Computer Programming (ICP) Rab Nawaz Jadoon DCS COMSATS Institute of Information Technology Assistant Professor COMSATS IIT, Abbottabad Pakistan Introduction to Computer Programming (ICP) What

More information

BASIC ELEMENTS OF A COMPUTER PROGRAM

BASIC ELEMENTS OF A COMPUTER PROGRAM BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators

More information

CS102: Variables and Expressions

CS102: Variables and Expressions CS102: Variables and Expressions The topic of variables is one of the most important in C or any other high-level programming language. We will start with a simple example: int x; printf("the value of

More information

Programming in C++ 4. The lexical basis of C++

Programming in C++ 4. The lexical basis of C++ Programming in C++ 4. The lexical basis of C++! Characters and tokens! Permissible characters! Comments & white spaces! Identifiers! Keywords! Constants! Operators! Summary 1 Characters and tokens A C++

More information

Basic Elements of C. Staff Incharge: S.Sasirekha

Basic Elements of C. Staff Incharge: S.Sasirekha Basic Elements of C Staff Incharge: S.Sasirekha Basic Elements of C Character Set Identifiers & Keywords Constants Variables Data Types Declaration Expressions & Statements C Character Set Letters Uppercase

More information

Data Types and Variables in C language

Data Types and Variables in C language Data Types and Variables in C language Basic structure of C programming To write a C program, we first create functions and then put them together. A C program may contain one or more sections. They are

More information

Objectives. In this chapter, you will:

Objectives. In this chapter, you will: Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates arithmetic expressions Learn about

More information

Introduction to C programming. By Avani M. Sakhapara Asst Professor, IT Dept, KJSCE

Introduction to C programming. By Avani M. Sakhapara Asst Professor, IT Dept, KJSCE Introduction to C programming By Avani M. Sakhapara Asst Professor, IT Dept, KJSCE Classification of Software Computer Software System Software Application Software Growth of Programming Languages History

More information

Fundamentals of C. Structure of a C Program

Fundamentals of C. Structure of a C Program Fundamentals of C Structure of a C Program 1 Our First Simple Program Comments - Different Modes 2 Comments - Rules Preprocessor Directives Preprocessor directives start with # e.g. #include copies a file

More information

Presented By : Gaurav Juneja

Presented By : Gaurav Juneja Presented By : Gaurav Juneja 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 of UNIX are written

More information

C: How to Program. Week /Mar/05

C: How to Program. Week /Mar/05 1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers

More information

Programming in C and Data Structures [15PCD13/23] 1. PROGRAMMING IN C AND DATA STRUCTURES [As per Choice Based Credit System (CBCS) scheme]

Programming in C and Data Structures [15PCD13/23] 1. PROGRAMMING IN C AND DATA STRUCTURES [As per Choice Based Credit System (CBCS) scheme] Programming in C and Data Structures [15PCD13/23] 1 PROGRAMMING IN C AND DATA STRUCTURES [As per Choice Based Credit System (CBCS) scheme] Course objectives: The objectives of this course is to make students

More information

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been

More information

6.096 Introduction to C++ January (IAP) 2009

6.096 Introduction to C++ January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture

More information

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2 - Introduction to C Programming

Chapter 2 - Introduction to C Programming Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic

More information

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers

More information

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary GATE- 2016-17 Postal Correspondence 1 C-Programming Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts, Analysis

More information

Basic Types, Variables, Literals, Constants

Basic Types, Variables, Literals, Constants Basic Types, Variables, Literals, Constants What is in a Word? A byte is the basic addressable unit of memory in RAM Typically it is 8 bits (octet) But some machines had 7, or 9, or... A word is the basic

More information

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018 C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing

More information

Standard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points)

Standard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points) Standard 11 Lesson 9 Introduction to C++( Up to Operators) 2MARKS 1. Why C++ is called hybrid language? C++ supports both procedural and Object Oriented Programming paradigms. Thus, C++ is called as a

More information

Chapter 1 & 2 Introduction to C Language

Chapter 1 & 2 Introduction to C Language 1 Chapter 1 & 2 Introduction to C Language Copyright 2007 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 1 & 2 - Introduction to C Language 2 Outline 1.1 The History

More information

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program

More information

Work relative to other classes

Work relative to other classes Work relative to other classes 1 Hours/week on projects 2 C BOOTCAMP DAY 1 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Overview C: A language

More information

Full file at C How to Program, 6/e Multiple Choice Test Bank

Full file at   C How to Program, 6/e Multiple Choice Test Bank 2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d)

More information

Introduction to C# Applications

Introduction to C# Applications 1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making

More information

Programming for Engineers Introduction to C

Programming for Engineers Introduction to C Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines

More information

Variables and Literals

Variables and Literals C++ By 4 EXAMPLE Variables and Literals Garbage in, garbage out! To understand data processing with C++, you must understand how C++ creates, stores, and manipulates data. This chapter teaches you how

More information

IECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23.

IECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23. Subject code - CCP01 Chapt Chapter 1 INTRODUCTION TO C 1. A group of software developed for certain purpose are referred as ---- a. Program b. Variable c. Software d. Data 2. Software is classified into

More information

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are: LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words

More information

.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar..

.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar.. .. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar.. A Simple Program. simple.c: Basics of C /* CPE 101 Fall 2008 */ /* Alex Dekhtyar */ /* A simple program */ /* This is a comment!

More information

Fundamental of C programming. - Ompal Singh

Fundamental of C programming. - Ompal Singh Fundamental of C programming - Ompal Singh HISTORY OF C LANGUAGE IN 1960 ALGOL BY INTERNATIONAL COMMITTEE. IT WAS TOO GENERAL AND ABSTRUCT. IN 1963 CPL(COMBINED PROGRAMMING LANGUAGE) WAS DEVELOPED AT CAMBRIDGE

More information

Fundamentals of Programming Session 4

Fundamentals of Programming Session 4 Fundamentals of Programming Session 4 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2011 These slides are created using Deitel s slides, ( 1992-2010 by Pearson Education, Inc).

More information

CS149: Elements of Computer Science. Fundamental C++ objects

CS149: Elements of Computer Science. Fundamental C++ objects Fundamental C++ objects 1. Compiler needs to know in advance how to store different data types 2. Variable name + type, e.g. (price, integer) 3. Types: (a) Integers: short, long, signed (b) Floating Points:

More information

Lecture 2 Tao Wang 1

Lecture 2 Tao Wang 1 Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors

More information

2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants

2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants Data types, variables, constants Outline.1 Introduction. Text.3 Memory Concepts.4 Naming Convention of Variables.5 Arithmetic in C.6 Type Conversion Definition: Computer Program A Computer program is a

More information

ADARSH VIDYA KENDRA NAGERCOIL COMPUTER SCIENCE. Grade: IX C++ PROGRAMMING. Department of Computer Science 1

ADARSH VIDYA KENDRA NAGERCOIL COMPUTER SCIENCE. Grade: IX C++ PROGRAMMING. Department of Computer Science 1 NAGERCOIL COMPUTER SCIENCE Grade: IX C++ PROGRAMMING 1 C++ 1. Object Oriented Programming OOP is Object Oriented Programming. It was developed to overcome the flaws of the procedural approach to programming.

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

Creating a C++ Program

Creating a C++ Program Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer. 1 Creating a C++ Program created using an

More information

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan Introduction to C Programming Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan Outline Printing texts Adding 2 integers Comparing 2 integers C.E.,

More information

C Fundamentals & Formatted Input/Output. adopted from KNK C Programming : A Modern Approach

C Fundamentals & Formatted Input/Output. adopted from KNK C Programming : A Modern Approach C Fundamentals & Formatted Input/Output adopted from KNK C Programming : A Modern Approach C Fundamentals 2 Program: Printing a Pun The file name doesn t matter, but the.c extension is often required.

More information

A First Program - Greeting.cpp

A First Program - Greeting.cpp C++ Basics A First Program - Greeting.cpp Preprocessor directives Function named main() indicates start of program // Program: Display greetings #include using namespace std; int main() { cout

More information

IT 374 C# and Applications/ IT695 C# Data Structures

IT 374 C# and Applications/ IT695 C# Data Structures IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation

More information

Maciej Sobieraj. Lecture 1

Maciej Sobieraj. Lecture 1 Maciej Sobieraj Lecture 1 Outline 1. Introduction to computer programming 2. Advanced flow control and data aggregates Your first program First we need to define our expectations for the program. They

More information

Chapter 2, Part I Introduction to C Programming

Chapter 2, Part I Introduction to C Programming Chapter 2, Part I Introduction to C Programming C How to Program, 8/e, GE 2016 Pearson Education, Ltd. All rights reserved. 1 2016 Pearson Education, Ltd. All rights reserved. 2 2016 Pearson Education,

More information

Gabriel Hugh Elkaim Spring CMPE 013/L: C Programming. CMPE 013/L: C Programming

Gabriel Hugh Elkaim Spring CMPE 013/L: C Programming. CMPE 013/L: C Programming 1 Literal Constants Definition A literal or a literal constant is a value, such as a number, character or string, which may be assigned to a variable or a constant. It may also be used directly as a function

More information

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 1

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 1 BIL 104E Introduction to Scientific and Engineering Computing Lecture 1 Introduction As engineers and scientists why do we need computers? We use computers to solve a variety of problems ranging from evaluation

More information

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this

More information

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance. 2.1 Introduction (No questions.) 2.2 A Simple Program: Printing a Line of Text 2.1 Which of the following must every C program have? (a) main (b) #include (c) /* (d) 2.2 Every statement in C

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

Syntax and Variables

Syntax and Variables Syntax and Variables What the Compiler needs to understand your program, and managing data 1 Pre-Processing Any line that starts with # is a pre-processor directive Pre-processor consumes that entire line

More information

Number Systems, Scalar Types, and Input and Output

Number Systems, Scalar Types, and Input and Output Number Systems, Scalar Types, and Input and Output Outline: Binary, Octal, Hexadecimal, and Decimal Numbers Character Set Comments Declaration Data Types and Constants Integral Data Types Floating-Point

More information

Java Notes. 10th ICSE. Saravanan Ganesh

Java Notes. 10th ICSE. Saravanan Ganesh Java Notes 10th ICSE Saravanan Ganesh 13 Java Character Set Character set is a set of valid characters that a language can recognise A character represents any letter, digit or any other sign Java uses

More information

UEE1302 (1102) F10: Introduction to Computers and Programming

UEE1302 (1102) F10: Introduction to Computers and Programming Computational Intelligence on Automation Lab @ NCTU Learning Objectives UEE1302 (1102) F10: Introduction to Computers and Programming Programming Lecture 00 Programming by Example Introduction to C++ Origins,

More information

Programming and Data Structures

Programming and Data Structures Programming and Data Structures Teacher: Sudeshna Sarkar sudeshna@cse.iitkgp.ernet.in Department of Computer Science and Engineering Indian Institute of Technology Kharagpur #include int main()

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

More information

DEPARTMENT OF MATHS, MJ COLLEGE

DEPARTMENT OF MATHS, MJ COLLEGE T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,

More information

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University Fundamental Data Types CSE 130: Introduction to Programming in C Stony Brook University Program Organization in C The C System C consists of several parts: The C language The preprocessor The compiler

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah Lecturer Department of Computer Science & IT University of Balochistan 1 Outline p Introduction p Program development p C language and beginning with

More information

Chapter 1 Introduction to Computers and C++ Programming

Chapter 1 Introduction to Computers and C++ Programming Chapter 1 Introduction to Computers and C++ Programming 1 Outline 1.1 Introduction 1.2 What is a Computer? 1.3 Computer Organization 1.7 History of C and C++ 1.14 Basics of a Typical C++ Environment 1.20

More information

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic BIT 3383 Java Programming Sem 1 Session 2011/12 Chapter 2 JAVA basic Objective: After this lesson, you should be able to: declare, initialize and use variables according to Java programming language guidelines

More information

Basics of Java Programming

Basics of Java Programming Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement

More information

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Object oriented programming. Instructor: Masoud Asghari Web page:   Ch: 3 Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning

More information

P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS)

P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS) FACULTY: Ms. Saritha P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS) SUBJECT / CODE: Programming in C and Data Structures- 15PCD13 What is token?

More information

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols. EEE-117 COMPUTER PROGRAMMING Basic Elements of C++ Objectives General Questions Become familiar with the basic components of a C++ program functions, special symbols, and identifiers Data types Arithmetic

More information

The component base of C language. Nguyễn Dũng Faculty of IT Hue College of Science

The component base of C language. Nguyễn Dũng Faculty of IT Hue College of Science The component base of C language Nguyễn Dũng Faculty of IT Hue College of Science Content A brief history of C Standard of C Characteristics of C The C compilation model Character set and keyword Data

More information

Types, Variables, and Constants

Types, Variables, and Constants , Variables, and Constants What is a Type The space in which a value is defined Space All possible allowed values All defined operations Integer Space whole numbers +, -, x No divide 2 tj Why Types No

More information

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and

More information

Data types, variables, constants

Data types, variables, constants Data types, variables, constants Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic in C 2.6 Decision

More information

EC 413 Computer Organization

EC 413 Computer Organization EC 413 Computer Organization C/C++ Language Review Prof. Michel A. Kinsy Programming Languages There are many programming languages available: Pascal, C, C++, Java, Ada, Perl and Python All of these languages

More information

Room 3P16 Telephone: extension ~irjohnson/uqc146s1.html

Room 3P16 Telephone: extension ~irjohnson/uqc146s1.html UQC146S1 Introductory Image Processing in C Ian Johnson Room 3P16 Telephone: extension 3167 Email: Ian.Johnson@uwe.ac.uk http://www.csm.uwe.ac.uk/ ~irjohnson/uqc146s1.html Ian Johnson 1 UQC146S1 What is

More information

Fundamentals of Programming. Lecture 3: Introduction to C Programming

Fundamentals of Programming. Lecture 3: Introduction to C Programming Fundamentals of Programming Lecture 3: Introduction to C Programming Instructor: Fatemeh Zamani f_zamani@ce.sharif.edu Sharif University of Technology Computer Engineering Department Outline A Simple C

More information

Basics of Programming

Basics of Programming Unit 2 Basics of Programming Problem Analysis When we are going to develop any solution to the problem, we must fully understand the nature of the problem and what we want the program to do. Without the

More information

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All rights reserved. Java application A computer program that executes when you use the java command to launch the Java Virtual Machine

More information

Reserved Words and Identifiers

Reserved Words and Identifiers 1 Programming in C Reserved Words and Identifiers Reserved word Word that has a specific meaning in C Ex: int, return Identifier Word used to name and refer to a data element or object manipulated by the

More information

C++ Programming: From Problem Analysis to Program Design, Third Edition

C++ Programming: From Problem Analysis to Program Design, Third Edition C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 2: Basic Elements of C++ Objectives (continued) Become familiar with the use of increment and decrement operators Examine

More information

2 nd Week Lecture Notes

2 nd Week Lecture Notes 2 nd Week Lecture Notes Scope of variables All the variables that we intend to use in a program must have been declared with its type specifier in an earlier point in the code, like we did in the previous

More information

AN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University

AN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University AN OVERVIEW OF C CSE 130: Introduction to Programming in C Stony Brook University WHY C? C is a programming lingua franca Millions of lines of C code exist Many other languages use C-like syntax C is portable

More information

INTRODUCTION 1 AND REVIEW

INTRODUCTION 1 AND REVIEW INTRODUTION 1 AND REVIEW hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Programming: Advanced Objectives You will learn: Program structure. Program statements. Datatypes. Pointers. Arrays. Structures.

More information

CSc Introduction to Computing

CSc Introduction to Computing CSc 10200 Introduction to Computing Lecture 2 Edgardo Molina Fall 2011 - City College of New York Thursday, September 1, 2011 Introduction to C++ Modular program: A program consisting of interrelated segments

More information

Overview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O

Overview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O Overview of C Basic Data Types Constants Variables Identifiers Keywords Basic I/O NOTE: There are six classes of tokens: identifiers, keywords, constants, string literals, operators, and other separators.

More information

The sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm.

The sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm. CHAPTER 1&2 OBJECTIVES After completing this chapter, you will be able to: Understand the basics and Advantages of an algorithm. Analysis various algorithms. Understand a flowchart. Steps involved in designing

More information

These are reserved words of the C language. For example int, float, if, else, for, while etc.

These are reserved words of the C language. For example int, float, if, else, for, while etc. Tokens in C Keywords These are reserved words of the C language. For example int, float, if, else, for, while etc. Identifiers An Identifier is a sequence of letters and digits, but must start with a letter.

More information

C - Basic Introduction

C - Basic Introduction C - Basic Introduction C is a general-purpose high level language that was originally developed by Dennis Ritchie for the UNIX operating system. It was first implemented on the Digital Equipment Corporation

More information

Introduction to C CMSC 104 Spring 2014, Section 02, Lecture 6 Jason Tang

Introduction to C CMSC 104 Spring 2014, Section 02, Lecture 6 Jason Tang Introduction to C CMSC 104 Spring 2014, Section 02, Lecture 6 Jason Tang Topics History of Programming Languages Compilation Process Anatomy of C CMSC 104 Coding Standards Machine Code In the beginning,

More information

Chapter 1. C++ Basics. Copyright 2010 Pearson Addison-Wesley. All rights reserved

Chapter 1. C++ Basics. Copyright 2010 Pearson Addison-Wesley. All rights reserved Chapter 1 C++ Basics Copyright 2010 Pearson Addison-Wesley. All rights reserved Learning Objectives Introduction to C++ Origins, Object-Oriented Programming, Terms Variables, Expressions, and Assignment

More information

The C++ Language. Arizona State University 1

The C++ Language. Arizona State University 1 The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

More information

Chapter 2: Introduction to C++

Chapter 2: Introduction to C++ Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++

More information

Unit 1: Introduction to C Language. Saurabh Khatri Lecturer Department of Computer Technology VIT, Pune

Unit 1: Introduction to C Language. Saurabh Khatri Lecturer Department of Computer Technology VIT, Pune Unit 1: Introduction to C Language Saurabh Khatri Lecturer Department of Computer Technology VIT, Pune Introduction to C Language The C programming language was designed by Dennis Ritchie at Bell Laboratories

More information

Typescript on LLVM Language Reference Manual

Typescript on LLVM Language Reference Manual Typescript on LLVM Language Reference Manual Ratheet Pandya UNI: rp2707 COMS 4115 H01 (CVN) 1. Introduction 2. Lexical Conventions 2.1 Tokens 2.2 Comments 2.3 Identifiers 2.4 Reserved Keywords 2.5 String

More information

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley

More information