Data Types and Variables in C language
|
|
- Michael Mason
- 6 years ago
- Views:
Transcription
1 Data Types and Variables in C language
2 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 illustrated below. Documentation section Link section Definition section Global declaration section main () Function section { Declaration part Executable part } Subprogram section Function 1 Function Function n (User defined functions)
3 Programming Rules Each instruction should be written in separate statement. A complete C program consists of set of instructions. The statements in program must be written in sequencial order to get desired output. Unless any logic problem can arises. All statement should written in small case letters. C has no particular rules for position at which statement is to be typed. In C program every statement must end with ; (semicolon). It act as a terminator.
4 Rules for Comment Comment in the program should be enclosed within /*.. */.Look example below the first line is comment. For ex. /*This my first program*/ #include<stdio.h> main() { } Statement; Though comments are not necessary, but it good practice to begin program with comment indicatingpurposeof program so that other person can get idea of program. You can write any number comment at any place in program mentioning the purpose of the statement. Use few Comment instead of too many. A comment cannot be nested. For ex., /* The/* first/*program*/*/*/. A comment can split over more than one line. For ex. /*THE First Program*/
5 Main Method main() is a collection of the set of statements. Statements that belongs to main() are always written within pairs of {} (opening and closing braces). For ex. void main() { 1st statement; 2nd statement; } Technically main() is a function because every function has the pair of parentheses ( ) associated with it. The function in c have their return type. Similarly, if we want that main() function should not return any value of particular type precede it with void. In case of returning a integer use int.
6 Declaration Any variable used in the program must be declared before using it. For ex, int a,b,c; float a,b,c; a=a+b; /*declaration*/ /*declaration*/ /*usage*/
7 Variable types Datatype number Declaration format string Integer 1,+5,-5 int a; "%d", a Float ,+1.14, float a; "%f", a Double , double a; "%l", a Character 'A','B' char a; "%c",a String "Dev.com" char a[20]; "%c",a
8 Variable types a) While declaration you can also initialize it as int a=1, b=24;, float a=1.5, b= *2.7; b) The order of declaration sometimes matter in initialization. For ex. int i = 1, j=24; is same as int j=24, i=1; float a=1.8, b= 3.1+a; This statement is alright but float b=3.1+a, a=1.8; is not the way, we have to initialize a before. c) Lets see another statements: int x,y,z; x=y=z=10; int x=y=z=10; work perfectly does not work we are trying to use y (assign to y) before defining it.
9 Character Set Character set are the set of alphabets, letters and some special characters that are valid in C language. Alphabets: Uppercase: A B C... X Y Z Lowercase: a b c... x y z Digits: Special Characters in C language, <>. _ () ; $ : % [] #? & {} ^! * / - \ ~ White space Characters: blank space, new line, horizontal tab, carriage return and form feed
10 Tri-graph Characters Many non-english keyboards do not support all the characters. ANSI C introduces the concept of Trigraph sequences to provide a way to enter certain characters that are not available on some keyboards.
11 Tokens in C Keywords Identifiers Constants String Constants Operators Punctuators
12 Tokens in C
13 Keywords Keywords are C tokens that have a strict meaning. They are explicitly reserved and cannot be redefined. ANSII C has 32 key words auto do goto signed unsigned break double if sizeof void case else int static volatile char enum long struct while const extern register switch continue float return typedef default for short union
14 Identifiers In C programming, identifiers are names given to C entities, such as variables, functions, structures etc. Identifier are created to give unique name to C entities to identify it during the execution of program. For example: int money; int mango_tree; Here, money is a identifier which denotes a variable of type integer. Similarly, mango_tree is another identifier, which denotes another variable of type integer.
15 Rules for Identifiers First letter must be alphabet (or Underscore) An identifier can be composed of letters (both uppercase and lowercase letters), digits and underscore '_' only. The first 31 characters of an identifier are significant Cannot use Keyword as identifiers Must not contain white space
16 Constants Constants in C refers to fixed values that do not change during the execution of program. C supports several types of constants
17 Integer Constants An integer constant refers to a sequence of digits, There are three types integers, namely, decimal, octal, and hexa decimal. Decimal Constant Eg: 123,-321 etc., Note: Embedded spaces, commas and non-digit characters are not permitted between digits. Eg: , $1000 Octal Constant An octal integer constant consists of any combination of digits from the set 0 through 7, with a leading 0. Eg: 1) 037 2) 0435 Hexadecimal Constant A sequence of digits preceded by 0x or 0X is considered as hexadecimal integer. They may also include alphabets A through F or a through f. Eg: 1) 0X2 2) 0x9F 3) 0Xbcd
18 Integer Constants Program for representation of integer constants on a 16-bit computer. /*Integer numbers on a 16-bit machine*/ main() { printf( Integer values\n ); printf( %d%d%d\n,32767, , ); printf( \n ); printf( Long integer values\n ); printf( %ld%ld%ld\n,32767l,32767l+1l,32767l+10l); } OUTPUT Integer values Long integer values
19 Real Constants Certain quantities that vary continuously, such as distances, heights etc., are represented by numbers containing functional parts like Such numbers are called real (or floating point) constants. Eg: , etc. A real number may also be expressed in exponential or scientific notation. Eg: may be written as e2 The generic form is mantissa e exponent is called as mantissa and 2 is the exponent Embedded white spaces are not allowed.
20 Single Character Constants A single character constants contains a single character enclosed within a pair of single quote marks. Eg: 7, X, ;, ' ' Note that character '7' is not same as number 7. Character constants have integer values known as ASCII values For ex. printf( %d, 'A'); will print 65, the ASCII value of 'A' Similarly, printf( %c, 65); will print letter 'A'
21 String Constants A string constant is a sequence of characters enclosed in double quotes. The characters may be letters, numbers, special characters and blank space. Eg: Hello!, 1987?.!
22 Backslash Character Constants C supports special backslash character constants that are used in output functions. These character combinations are known as escape sequences.
23 Variables A variable is a data name that may be used to store a data value. It may take different values at different times of execution and may be chosen by the programmer in a meaningful way. Variable name may consist of letters, digits and underscore character. Eg: 1) Average, 2) Counter_1 3) Fan1
24 Rules for Variable Names They must begin with a letter. Some systems permit underscore as the first character. ANSI standard recognizes a length of 31 characters. However, the length should not be normally more than eight characters. Uppercase and lowercase are significant. The variable name should not be a keyword. White space is not allowed.
25 Rules for Variable Names Valid Variables Names: John Value T_raise Delhi x1 ph_value mark sum1 distance Invalid Variable Names: 123 (area) % 25th
26 Data Types Storage representation and machine instructions to handle such data differs from machine to machine. Variety of data type is available in C to select from. A data type is used to Identify the type of a variable when the variable is declared Identify the type of the return value of a function Identify the type of a parameter expected by a function
27 Data Types ANSI C supports four classes of data types. 1. Primary or Fundamental data types. 2. User-defined data types. 3. Derived data types. 4. Empty data set.
28 Primary Data Types
29 Data Types - Integer Size and Range Of Data types on 16 bit machine
30 Data Types - Floating Point
31 Declaration of Variables Declarations does two things: It tells the compiler what the variable name it It specifies what type of data the variable will hold Primary Type Declaration The syntax is Data-type v1,v2..vn; Eg: int count; double ratio, total;
32 User-defined type declaration C allows user to define an identifier that would represent an existing data type. The general form is typedef type identifier; Eg: typedef int units; typedef float marks; Another user defined data types is enumerated data type which can be used to declare variables that can have one of the values enclosed within the braces. enum identifier {value1,value2, valuen}; Ex. enum day {Monday, Tuesday, Wednesday, Thursday, Friday} enum day week_st, week_end; week_st = Monday;
33 Declaration of Storage Class Variables in C can have not only data type but also storage class that provides information about their locality and visibility. /*Example of storage class*/ int m; main() { int i; float bal; function1(); } function1() { int i; float sum; } Here the variable m is called the global variable. It can be used in all the functions in the program. The variables bal, sum and i are called local variables. Local variables are visible and meaningful only inside the function in which they are declared. There are four storage class specifies, namely, auto, static, register and extern
34 Declaration of Storage Class
35 Assigning Values to Variables The syntax is Variable_name=constant Eg: int a=20; bal=75.84; yes= x ; C permits multiple assignments in one line. Example: initial_value=0;final_value=100;
36 Reading Data from Keyboard Another way of giving values to variables is to input data through keyboard using the scanf function. The C library function int scanf(const char *format,...) reads formatted input from stdin. The general format of scanf is as follows. scanf( control string, &variable1, &variable2,.); The ampersand symbol & before each variable name is an operator that specifies the variable name s address. Eg: scanf( %d, &number); Note: printf() and scanf() functions are declared in stdio.h header file in C library.
37 Symbolic Constants Many times unique constants are required in the program which are used repeatedly. For Ex , representing value of pi It is advisable to use named constant or symbolic names rather than the value like Area = PI * r *r; rather than Area = * r *r; It also increases understandability of the program Ex. # define PI Ex. # define PASS_MARKS 40 Symbolic names are constants and not variables. They do not appear in declaration.
38 Symbolic Constants - Rules Symbolic names have same form as variable names No space between # and define keyword # must be first character in the line Blank space between #define and symbolic name and the constant No semicolon to end the statement After definition, no value can be assigned to symbolic constant in the program No data types #define statement may appear anywhere in the program but before its usage. However usual practice is to place them in the beginning of the program.
39 Symbolic Constants Valid symbolic constant definition #define Students 70 #define COURSE BTECH Invalid symbolic constant definition #define Students = 70 # define COURSE BTECH #define COUNT 70; #define A 10, B20 #Define Total 100 #define amount$ 1000
40 Variable as Constant Certain variables may be required to remain constant throughout the program execution. Can be declared as constant Ex. const int class_size=40; This tells the compiler that the value of the int variable class_size must not be modified by the program.
41 Variable as Volatile By declaring a variable as volatile, its value may be changed at any time by some external source. Eg: volatile int date; The value of a volatile variable may be changed by some external factors even if it does not appear on the LHS of an assignment statement. The value of a volatile variable can be modified by by its own program as well. If the value should not be modified by the program while it can be altered by external process, declare as both const and volatile Ex. volatile const int location = 100;
42 Overflow and Underflow of Data Problem of data overflow occurs when value of a variable is either too big or too small for data type to hold Floating point values are rounded to the number of significant digits allowed Integers are always exact within the limit of the range of the integral data type C does not provide any warning or indication of integer overflow Exercise greater care in defining the variable with correct data type
43
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 informationDEPARTMENT 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 informationComputer 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 informationUNIT - 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 informationProgramming 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 informationDECLARATIONS. 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 informationPresented 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 informationVariables Data types Variable I/O. C introduction. Variables. Variables 1 / 14
C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition
More informationANSI C Programming Simple Programs
ANSI C Programming Simple Programs /* This program computes the distance between two points */ #include #include #include main() { /* Declare and initialize variables */ double
More informationProgramming 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 informationC 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 informationFundamental 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 informationFeatures 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 informationVARIABLES 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 informationLESSON 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 informationC: 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 informationC 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 informationFundamental 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 informationINTRODUCTION 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 informationChapter 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 informationFundamentals of Programming
Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables
More informationVariables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park
Variables in C CMSC 104, Fall 2012 John Y. Park 1 Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement 2 What Are Variables in C? Variables in C have the
More information.. 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 information6.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 informationCharacter Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits
More informationFull 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 informationFundamental 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 informationTokens, 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 informationFundamentals of C Programming
Introduction, Constants, variables, keywords, Comments, I/O Functions, Data types, Compilation & Execution Tejalal Choudhary tejalal.choudhary@gmail.com, tejalal.choudhary@sdbct.ac.in Department of Computer
More informationME240 Computation for Mechanical Engineering. Lecture 4. C++ Data Types
ME240 Computation for Mechanical Engineering Lecture 4 C++ Data Types Introduction In this lecture we will learn some fundamental elements of C++: Introduction Data Types Identifiers Variables Constants
More informationC - 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!"#$% &'($) *+!$ 0!'" 0+'&"$.&0-2$ 10.+3&2),&/3+, %&&/3+, C,-"!.&/+"*0.&('1 :2 %*10% *%7)/ 30'&. 0% /4%./
0!'" 0+'&"$ &0-2$ 10 +3&2),&/3+, #include int main() int i, sum, value; sum = 0; printf("enter ten numbers:\n"); for( i = 0; i < 10; i++ ) scanf("%d", &value); sum = sum + value; printf("their
More informationBinghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program
Syntax What the Compiler needs to understand your program 1 Pre-Processing Any line that starts with # is a pre-processor directive Pre-processor consumes that entire line Possibly replacing it with other
More informationBLM2031 Structured Programming. Zeyneb KURT
BLM2031 Structured Programming Zeyneb KURT 1 Contact Contact info office : D-219 e-mail zeynebkurt@gmail.com, zeyneb@ce.yildiz.edu.tr When to contact e-mail first, take an appointment What to expect help
More informationJava 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 informationProgramming 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 informationA Fast Review of C Essentials Part I
A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types
More informationLaboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information
Laboratory 2: Programming Basics and Variables Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information 3. Comment: a. name your program with extension.c b. use o option to specify
More informationIntroduction 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 informationSyntax 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 informationFundamentals 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 informationChapter 2 THE STRUCTURE OF C LANGUAGE
Lecture # 5 Chapter 2 THE STRUCTURE OF C LANGUAGE 1 Compiled by SIA CHEE KIONG DEPARTMENT OF MATERIAL AND DESIGN ENGINEERING FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING Contents Introduction to
More informationC OVERVIEW. C Overview. Goals speed portability allow access to features of the architecture speed
C Overview C OVERVIEW Goals speed portability allow access to features of the architecture speed C fast executables allows high-level structure without losing access to machine features many popular languages
More informationChapter 2: Overview of C. Problem Solving & Program Design in C
Chapter 2: Overview of C Problem Solving & Program Design in C Addison Wesley is an imprint of Why Learn C? Compact, fast, and powerful High-level Language Standard for program development (wide acceptance)
More information>B<82. 2Soft ware. C Language manual. Copyright COSMIC Software 1999, 2001 All rights reserved.
>B
More informationc) 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 informationChapter 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 informationMuntaser Abulafi Yacoub Sabatin Omar Qaraeen. C Data Types
Programming Fundamentals for Engineers 0702113 5. Basic Data Types Muntaser Abulafi Yacoub Sabatin Omar Qaraeen 1 2 C Data Types Variable definition C has a concept of 'data types' which are used to define
More informationDifferentiate Between Keywords and Identifiers
History of C? Why we use C programming language Martin Richards developed a high-level computer language called BCPL in the year 1967. The intention was to develop a language for writing an operating system(os)
More informationBASIC 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 informationCSc 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 informationChapter 2. Lexical Elements & Operators
Chapter 2. Lexical Elements & Operators Byoung-Tak Zhang TA: Hanock Kwak Biointelligence Laboratory School of Computer Science and Engineering Seoul National Univertisy http://bi.snu.ac.kr The C System
More informationUNIT- 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 informationVariables in C. CMSC 104, Spring 2014 Christopher S. Marron. (thanks to John Park for slides) Tuesday, February 18, 14
Variables in C CMSC 104, Spring 2014 Christopher S. Marron (thanks to John Park for slides) 1 Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement 2 What
More informationUNIT IV 2 MARKS. ( Word to PDF Converter - Unregistered ) FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING
( Word to PDF Converter - Unregistered ) http://www.word-to-pdf-converter.net FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING INTRODUCTION TO C UNIT IV Overview of C Constants, Variables and Data Types
More informationADARSH 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 informationTHE FUNDAMENTAL DATA TYPES
THE FUNDAMENTAL DATA TYPES Declarations, Expressions, and Assignments Variables and constants are the objects that a prog. manipulates. All variables must be declared before they can be used. #include
More informationPreview from Notesale.co.uk Page 6 of 52
Binary System: The information, which it is stored or manipulated by the computer memory it will be done in binary mode. RAM: This is also called as real memory, physical memory or simply memory. In order
More informationProgramming. C++ Basics
Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++
More informationC OVERVIEW BASIC C PROGRAM STRUCTURE. C Overview. Basic C Program Structure
C Overview Basic C Program Structure C OVERVIEW BASIC C PROGRAM STRUCTURE Goals The function main( )is found in every C program and is where every C program begins speed execution portability C uses braces
More informationBasic Types and Formatted I/O
Basic Types and Formatted I/O C Variables Names (1) Variable Names Names may contain letters, digits and underscores The first character must be a letter or an underscore. the underscore can be used but
More informationUniversity of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.
University of Technology Laser & Optoelectronics Engineering Department C++ Lab. Second week Variables Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable.
More informationET156 Introduction to C Programming
ET156 Introduction to C Programming g Unit 22 C Language Elements, Input/output functions, ARITHMETIC EXPRESSIONS AND LIBRARY FUNCTIONS Instructor : Stan Kong Email : skong@itt tech.edutech.edu General
More informationProgramming 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 informationME 172. Lecture 2. Data Types and Modifier 3/7/2011. variables scanf() printf() Basic data types are. Modifiers. char int float double
ME 172 Lecture 2 variables scanf() printf() 07/03/2011 ME 172 1 Data Types and Modifier Basic data types are char int float double Modifiers signed unsigned short Long 07/03/2011 ME 172 2 1 Data Types
More information2/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 informationUnit-II Programming and Problem Solving (BE1/4 CSE-2)
Unit-II Programming and Problem Solving (BE1/4 CSE-2) Problem Solving: Algorithm: It is a part of the plan for the computer program. An algorithm is an effective procedure for solving a problem in a finite
More informationBasics 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 informationIntroduction 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 informationLecture 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 informationProgramming 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 informationIntroduction 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 informationFundamentals 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 informationData 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 informationCSE 1001 Fundamentals of Software Development 1. Identifiers, Variables, and Data Types Dr. H. Crawford Fall 2018
CSE 1001 Fundamentals of Software Development 1 Identifiers, Variables, and Data Types Dr. H. Crawford Fall 2018 Identifiers, Variables and Data Types Reserved Words Identifiers in C Variables and Values
More informationIntroduction to Computing Lecture 01: Introduction to C
Introduction to Computing Lecture 01: Introduction to C Assist.Prof.Dr. Nükhet ÖZBEK Ege University Department of Electrical&Electronics Engineering ozbek.nukhet@gmail.com Topics Introduction to C language
More informationStandard 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 informationUEE1302 (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 informationSEQUENTIAL STRUCTURE. Erkut ERDEM Hacettepe University October 2010
SEQUENTIAL STRUCTURE Erkut ERDEM Hacettepe University October 2010 History of C C Developed by by Denis M. Ritchie at AT&T Bell Labs from two previous programming languages, BCPL and B Used to develop
More informationEEE145 Computer Programming
EEE145 Computer Programming Content of Topic 2 Extracted from cpp.gantep.edu.tr Topic 2 Dr. Ahmet BİNGÜL Department of Engineering Physics University of Gaziantep Modifications by Dr. Andrew BEDDALL Department
More informationWork 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 informationSTUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING
OBJECT ORIENTED PROGRAMMING STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING 1. Object Oriented Programming Paradigms 2. Comparison of Programming Paradigms 3. Basic Object Oriented Programming
More informationLEXICAL 2 CONVENTIONS
LEXIAL 2 ONVENTIONS hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. ++ Programming Lexical onventions Objectives You will learn: Operators. Punctuators. omments. Identifiers. Literals. SYS-ED \OMPUTER EDUATION
More informationBITG 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 informationCS149: 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 informationRecap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam
Multimedia Programming 2004 Lecture 2 Erwin M. Bakker Joachim Rijsdam Recap Learning C++ by example No groups: everybody should experience developing and programming in C++! Assignments will determine
More informationPROGRAMMAZIONE 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 informationC++ 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 informationCreating 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 informationDETAILED SYLLABUS INTRODUCTION TO C LANGUAGE
COURSE TITLE C LANGUAGE DETAILED SYLLABUS SR.NO NAME OF CHAPTERS & DETAILS HOURS ALLOTTED 1 INTRODUCTION TO C LANGUAGE About C Language Advantages of C Language Disadvantages of C Language A Sample Program
More informationCMSC 104 -Lecture 5 John Y. Park, adapted by C Grasso
CMSC 104 -Lecture 5 John Y. Park, adapted by C Grasso 1 Topics Naming Variables Declaring Variables Using Variables The Assignment Statement 2 a + b Variables are notthe same thing as variables in algebra.
More informationHave the same meaning as variables in algebra Single alphabetic character Each variable needs an identifier that distinguishes it from the others a =
Morteza Noferesti Have the same meaning as variables in algebra Single alphabetic character Each variable needs an identifier that distinguishes it from the others a = 5 x = a + b valid identifier in C
More informationRule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.
Chapter 9: Rules Chapter 1:Style and Program Organization Rule 1-1: Organize programs for readability, just as you would expect an author to organize a book. Rule 1-2: Divide each module up into a public
More informationObjectives. 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 informationChapter 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 information1.1 Introduction to C Language. Department of CSE
1.1 Introduction to C Language 1 Department of CSE 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
More informationChapter 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 informationMain Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University
C Programming Notes Dr. Karne Towson University Reference for C http://www.cplusplus.com/reference/ Main Program #include main() printf( Hello ); Comments: /* comment */ //comment 1 Data Types
More informationIV Unit Second Part STRUCTURES
STRUCTURES IV Unit Second Part Structure is a very useful derived data type supported in c that allows grouping one or more variables of different data types with a single name. The general syntax of structure
More informationThese 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