Tejalal Choudhary “Computer Programming” Fundamentals of “C”

Slides:



Advertisements
Similar presentations
1 C++ Syntax and Semantics The Development Process.
Advertisements

Java Syntax Part I Comments Identifiers Primitive Data Types Assignment.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
C programming Language and Data Structure For DIT Students.
Introduction to C language
Copyrights© 2008 BVU Amplify DITM Software Engineering & Case Tools Page:1 INTRODUCTION TO ‘C’ LANGUAGE Chapter 2.
Elements of a C++ program 1. Review Algorithms describe how to solve a problem Structured English (pseudo-code) Programs form that can be translated into.
C Tokens Identifiers Keywords Constants Operators Special symbols.
Five Tips to Success. Work hard Try more exercises and more practice.
1 CSC103: Introduction to Computer and Programming Lecture No 6.
Structured Programming Approach Module III - Expressing Algorithm Sequence Module IV - Concept of scalar Data Types Prof: Muhammed Salman Shamsi.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
CPS120: Introduction to Computer Science
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
Primitive Variables.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
Dennis Ritchie 1972 AT & T Bell laboratories (American Telephone and Telegraph) USA 1www.gowreeswar.com.
What is C? C is a programming language. It was developed in 1972 USA. It was designed and written by a man named dennis ritchie. C is the base for all.
The character data type char. Character type char is used to represent alpha-numerical information (characters) inside the computer uses 2 bytes of memory.
Primitive Variables.
Constants, Variables and Data types in C The C character Set A character denotes any alphabet, digit or special symbol used to represent information.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
C BASICS QUIZ (DATA TYPES & OPERATORS). C language has been developed by (1) Ken Thompson (2) Dennis Ritchie (3) Peter Norton (4) Martin Richards.
MAHENDRAN. Session Objectives Session Objectives  Discuss the Origin of C  Features of C  Characteristics of C  Current Uses of C  “C” Programming.
Lecture 4 Monday Sept 9, Variables and Data Types ►A►A►A►A variable is simply a name given by the programmer that is used to refer to computer storage.
Constants, Data Types and Variables
Chapter 3 Using Variables, Constants, Formatting Mrs. UlshaferSept
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
INTRODUCTION TO C LANGUAGE
Course Contents KIIT UNIVERSITY Sr # Major and Detailed Coverage Area
The Machine Model Memory
Data types Data types Basic types
BASIC ELEMENTS OF A COMPUTER PROGRAM
Chapter 1 Introduction to C Programming
Documentation Need to have documentation in all programs
Computing Fundamentals
ITEC113 Algorithms and Programming Techniques
C Language VIVA Questions with Answers
Objectives Identify the built-in data types in C++
EPSII 59:006 Spring 2004.
Intro to Programming Week # 1 Hardware / Software Lecture # 2
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
' C ' PROGRAMMING SRM-MCA.
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.
Tejalal Choudhary “C Programming from Scratch” Pointers
Visit for more Learning Resources
Computer Programming LAB 1 Tejalal Choudhary Asst. Prof, CSE Dept.
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
2.1 Parts of a C++ Program.
Variables in C Topics Naming Variables Declaring Variables
CS111 Computer Programming
C++ Data Types Data Type
Storing Information Each memory cell stores a set number of bits (usually 8 bits, or one byte) (byte addressable)
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
Chapter 2: Introduction to C++.
C programming Language
C – Programming Language
C Language B. DHIVYA 17PCA140 II MCA.
Variables in C Topics Naming Variables Declaring Variables
Course Outcomes of Programming In C (PIC) (17212, C203):
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables in C Topics Naming Variables Declaring Variables
Basic Programming Lab C.
Variables in C Topics Naming Variables Declaring Variables
Getting Started With Coding
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Tejalal Choudhary “Computer Programming” Fundamentals of “C” Store Data Operate on Data Perform I/O Control the sequence “Computer Programming” Fundamentals of “C” VARIABLES, CONSTANTS & DATA TYPES Tejalal Choudhary Department of Computer Science & Engg SDBCT, Indore tejalal.choudhary@sdbct.ac.in

Contents Need of variable, constant and data types Character set Constants Variables Data types

What is C ? Programming Language Simple and easy to use Many other languages are based on C Developed at AT & T’s Bell Laboratories of USA in 1972. Major parts of OS like Windows, UNIX, Linux is still written in C. Device driver are written in C Many mobile devices, consumer devices are based on C Popular gaming frameworks have been built using C Closely interact with the hardware devices. and so on…..

Analogy b/w English & C Steps in learning English language: Steps in learning Programming language: Alphabets Words Sentences Paragraphs Alphabets, Digits, Special Symbols Constants, Variables, Keywords Instructions Program

Identifier Any user defined name Can be a name of Variable, array, structure, Union ,Function etc. Should follow the naming rules of a language Naming Rules The first character in the variable name must be an alphabet or underscore. No commas or blanks are allowed within identifier No special symbol other than an underscore

Constants An entity that doesn’t change Types Integer (10, 20) Real (10.56) Character (‘a’, ‘A’)

Variables Variable is an entity that may change. It’s a Named memory location Each variable has some address Store constant value If not initialized constrains garbage value Can store one value at a time i.e. x=10 x=20 X –> Variable 10, 20 –> constant

Variable A B

Data-type variable-name; Data Types Define Type for variable Range(max and min value it can store) Size(space required to store value) Data Type char short int long float double General Syntax for Variable Declaration Data-type variable-name; Char ch;

Byte Binary digit -> bit(0 or 1) One byte 0/1 One Byte can represent 28 =256 distinct values 0/1

Char(1 Byte) Char ch=‘A’; //65 64 +1 26+20 1 26 20 27 +26 +25 +24 +23 +22 +21 +20

Short(2 Byte) Short s=519; 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 29 + 22 + 21 + 20 512 + 4 + 2 +1=519

Short(2 Byte) 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 20 +…….+ 214 1+2+4+8+16+ 32+64+128+256+ 512+ 1024+ 2048+ 4096+ 8192+ 16384= 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32767 + 1

Negative Numbers (Stored in 2’s complement) Binary of -32768 is same as 32768 When we try to store 32768 it becomes -32768 Binary of -32768 = 1’s Complement of 32768 +1 Binary of 32768 is : 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1’s complement 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +1 2’s complement 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Binary of -32768

Assigning one type to another Char ch=‘A’; //65 Short s=ch; 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 65

Assigning one type to another Short s=300; 28+25+23+22=256+32+8+4 Char ch=s; 25+23+22 = 0 0 0 0 0 0 0 1 0 0 0 1 0 1 1 0 0 0 0 0 1 0 1 1 0 0 44

Lab Assignment 2 WAP which accepts a lower case character from the user and display the corresponding upper case character.(Hint: use <string.h> header file and its functions) Take length & breadth of rectangle from user. WAP to calculate area of rectangle.