Wel come.

Slides:



Advertisements
Similar presentations
Object Oriented Programming in JAVA
Advertisements

Types and Variables. Computer Programming 2 C++ in one page!
C programming an Introduction. Types There are only a few basic data types in C. char a character int an integer, in the range -32,767 to 32,767 long.
Chapter 2 Data Types, Declarations, and Displays
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
1 Lecture 3  Lexical elements  Some operators:  /, %, =, +=, ++, --  precedence and associativity  #define  Readings: Chapter 2 Section 1 to 10.
Basic Elements of C++ Chapter 2.
Variable & Constants. A variable is a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines.
A First Book of ANSI C Fourth Edition
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Chapter 2: C Fundamentals Dr. Ameer Ali. Overview C Character set Identifiers and Keywords Data Types Constants Variables and Arrays Declarations Expressions.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Streams Streams –Sequences of characters organized.
Chapter 9 Formatted Input/Output. Objectives In this chapter, you will learn: –To understand input and output streams. –To be able to use all print formatting.
A Variable is symbolic name that can be given different values. Variables are stored in particular places in the computer ‘s memory. When a variable is.
Input & Output: Console
2440: 211 Interactive Web Programming Expressions & Operators.
C Tokens Identifiers Keywords Constants Operators Special symbols.
Programming I Introduction Introduction The only way to learn a new programming language is by writing programs in it. The first program to.
C-Language Keywords(C99)
Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram.
CPS120: Introduction to Computer Science
Lecture #5 Introduction to C++
C++ Programming: Basic Elements of C++.
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.
3. FORMATTED INPUT/OUTPUT. The printf Function The first argument in a call of printf is a string, which may contain both ordinary characters and conversion.
CONSTANTS Constants are also known as literals in C. Constants are quantities whose values do not change during program execution. There are two types.
DATA TYPE AND DISPLAY Computer Programming Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
C++ Basics Tutorial 5 Constants. Topics Covered Literal Constants Defined Constants Declared Constants.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 9, 2005 Lecture Number: 6.
Constants, Variables and Data types in C The C character Set A character denotes any alphabet, digit or special symbol used to represent information.
Topics to be covered  Introduction to C Introduction to C  Characterstics of C Characterstics of C  Characterset Characterset  Keywords Keywords 
Ajmer Singh PGT(IP) Programming Fundamentals. Ajmer Singh PGT(IP) Java Character Set Character set is a set of valid characters that a language can recognize.
Chapter2 Constants, Variables, and Data Types. 2.1 Introduction In this chapter, we will discuss –constants (integer, real, character, string, enum),symbolic.
CPS120: Introduction to Computer Science Variables and Constants.
Operating System Discussion Section. The Basics of C Reference: Lecture note 2 and 3 notes.html.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
Objects Variables and Constants. Our Scuba Problem #include // cin, cout, > using namespace std; int main() { const double FEET_PER_ATM = 33.0, LBS_PER_SQ_IN_PER_ATM.
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2012 CMPE-013/L Constants and Literals Gabriel Hugh Elkaim Spring 2012.
1 C Syntax and Semantics Dr. Sherif Mohamed Tawfik Lecture Two.
Introduction C# program is collection of classes Classes are collection of methods and some statements That statements contains tokens C# includes five.
Prepared By: K. U. Khimani Assistant Professor IT Department.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 2.
Constants, Data Types and Variables
Introduction to ‘c’ language
The Second C++ Program Variables, Types, I/O Animation!
Chapter 2 Variables.
Chapter Topics The Basics of a C++ Program Data Types
Chapter 2: Introduction to C++
BASIC ELEMENTS OF A COMPUTER PROGRAM
ECE Application Programming
Basic Elements of C++.
Chapter 2: Introduction to C++
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.
Basic Elements of C++ Chapter 2.
Introduction to the C Language
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.
C++ Basics.
C++ fundamentals Lecture 1, Chapter 2 – pp /22/2018 Y K Choi.
2.1 Parts of a C++ Program.
Introduction to C++ Programming
Basics of ‘C’.
C AS A LANGUAGE Interface between computer & human being. ALPHABETS
Introduction to Programming - 3
Chapter 2: Introduction to C++.
Chapter 2 Variables.
Lexical Elements & Operators
The Fundamentals of C++
Presentation transcript:

wel come

BILASPUR UNIVRSITY,BILASPUR Department Of Computer Science & Application Assignment- Constants In C Guided By:- Presented By:- Mr. Jeetendra sir Ajay Thakur

CONSTANTS : 1. What is constant. 2. Declaring constants 3. Basic types of constant. 4. Integer constant. 5. Real constant. 6. Single character constant. 7. String constant. 8. Backslash character constant.

What is constant : Constants are data values that cannot be changed during the execution of a program. Like variables have a type. In this section, we discuss Boolean ,character , integer , real , complex , and string constants.

Declaring constants : Declaring a constants allows you to quickly and easily change a value that is used throughout your code simply by changing the declaration . Unlike variables , constants are declared using the c language preprocessor and not the compiler . Here’s the format : #define PI 3.14

Declaring constants : #include<stdio.h> #define PI 3.14 void main () { float R,area,square; R=2.5; area = 4*PI*R*R; square =4/3*PI*R*R*R; printf(“%f %f”,area,square); }

Single character constants Types of constant : constants Numeric constants Integer constants Real constants Character constants Single character constants String constants

Integer constants : An integer constant refers to a sequence of digits. there three types of integers , namely ,decimal integer , octal integer and hexadecimal integer. decimal integer consist of a set of digit . valid example: 123 -312 0 67364 +56 an octal integer constant consists of any combination of digits from the set 0 through 7 with a leading 0. valid example: 037 0 043 0546 a sequence of digits preceded by 0x or 0X is considered as hexadecimal integer . Valid example: 0X2 0x9F 0Xbcd 0x

Integer constants : valid remarks 25,000 $255 0X7B No Yes No Represents long integer Comma is not allowed $ symbol is not permitted Hexadecimal integer

Real constants : Integer numbers are inadequate to represent quantities that vary continuously , such as distances , heights ,temperatures , prices , and so on . Examples of real constants are: 0.0083 -0.75 435.36 +247.0 It is possible to omit digits before the decimal point , or digits after the decimal point . That is , 215. .95 -.71 +.5 A real number may also be expressed in exponential notation . For example , the value 215.65 may be written as 2.156e2 in exponential notation . E2 means multiply by 10 2 . The general for is : Mantissa e exponent The mantissa is either a real number expressed in decimal notation or an integer . Example of legal floating-point constants are: 0.65e4 12e-2 1.5e+5 3.18E3 -1.2E-1

Real constants : Valid? Remarks Constant +5.0E3 3.5e-5 7.1e 4 1.5E+2.5 Yes No ANSI c support unary plus ----=----- No white space is permitted Exponent must be an integer

Single char. constants : A single character constant contains a single character enclosed within a pair of single quote marks . Example of charater constants are: ‘5’ ‘X’ ‘;’ ‘ ’ Note that the character constant ‘5’ is not the same as the number 5. Character constant have integer values known as ASCII value . For example , the statement Printf(“%d”,’a’); Would print the number 97,the ASCII value of the letter a .

String Constants : A string constant is a sequence of characters enclosed in double quotes . The characters may be letters , number , special characters and blank space examples are : “Hello!” “1987” “well done” “?....!” “5+3” “X” Remember that a character constant is not equivalent to single character string constant . Further , a single character string constant does not have an equivalent integer value while a character constant has an integer value . Character string are often used in programs to build meaningful programs .

Backslash char Constants : C supports some special backslash character constants that are used in output functions . For example , the symbol ‘\n’ stands for newline character. A list of such backslash character constant is given in table . Note that each one of them represents one character , although they consist of two characters .

Backslash char Constants : Meaning ‘\n’ ‘\b’ ‘\f’ ‘\r’ ‘\t’ ‘\v’ ‘\’ ‘\”’ ‘\?’ ‘\\’ ‘\0’ Audible alert (bell) Back space Form feed New line Carriage return Horizontal tab Vertical tab Single quote Double quote Question mark Backslash null

Thank you