ITGyan has created this video to demonstrate constants in c, theoretically and practically both. I, Anunay Ghosh (Anunay Kumar Ghosh), assured you that after watching this video you must not have any problem understanding constants in C.
Constants in C, Types of Constants in C, How to Use Constants in C, Using Constants in C
#ITGyan
#AnunayGhosh
#programminginc
Download the Notes here: -- https://cutt.ly/xXh5Kzi
Key Moments:
0:08 Introduction of Constants
2:49 Integer Constants
5:09 Floating Points Constants
7:24 Character Constants
9:00 String Constants
10:42 Ways of defining constants
11:50 Using const keyword
15:04 Using #define preprocessor directive
17:04 Practical Sessions
Query Covered:
Constants in C
Types of Constants in C
How to Use Constants in C
Using Constants in C
Integer Constants in C
Floating Point Constants in C
Character Constants in C
String Constants in C
const keyword in C
#define directive in C
Programming in C
Basics of C
C for beginners
Programming in C for beginners
C Language
Programming Language C
ITGyan
IT Gyan
Watch also:
Bitwise operators in C : • Operators in C | Bitwise Operators in C | ...
Ternary or Conditional operator : • Operators in C | Ternary Operator in C | C...
Increment/Decrement Operator: • Increment Decrement Operators in C | incre...
Assignment and Compound operators : • Assignment Operators in C | Using Assignme...
Logical Operators in C : • Logical Operators in C | Using Logical Ope...
Relational Operators in C : • Relational Operators in C | Using Relation...
Arithmetic operators in C : • Arithmetic Operators in C | Using Arithmet...
Printf and Scanf in C : • printf and scanf in C | printf in c | scan...
First C Program, save and run : • First C Program | My First C Program | pri...
Token in C : • Tokens in C | What is tokens | Token in C ...
Keywords in C : • Keywords and Datatype in C | Keywords in C...
Identifiers in C : • Identifiers in C Types of Identifiers Vari...
Convert Image to Text : • Image to Text | Photo to Text | Image To T...
Parity Bit- Error Detection : • Even Parity Bit | Odd Parity Bit | Parity ...
Constants in C
Constants are any value that we assign to a variable that the program cannot alter during its execution. These fixed values are also called literals.
Constants can be of any basic data type in C like an integer constant, a floating constant, a character constant, or a string literal. There is an enumeration constant also.
Constants are treated just like regular variables except that their values cannot be changed after their definition.
Types of Constants: 1. Numeric Constants Integer Constants Real Constants 2. Character Constants Single Character Constants String Constants Escape Sequence Character
Integer Constants
An integer literal can be a decimal, octal, or hexadecimal constant. A prefix specifies the base or radix: 0x or 0X for hexadecimal, 0 (zero) for octal, and nothing for decimal.
Here are some examples of valid and invalid integer literals −
212 /* Legal */
215u /* Legal */
0xFee /* Legal */
077 /* Legal */
078 /* Illegal: 8 is not an octal digit */
032UU /* Illegal: cannot repeat a suffix */
Following are other examples of various types of integer literals −
85 /* decimal */
0213 /* octal */
0x4b /* hexadecimal */
Floating-point Literals
A floating-point literal has an integer part, a decimal point, a fractional part, and an optional exponent part. You can represent floating point literals either in decimal form or exponential form.
While representing decimal form, you must include the decimal point, the exponent, or both; and while representing exponential form, you must include the integer part, the fractional part, or both. The signed exponent is introduced by e or E. E is equivalent to 10.
Here are some examples of floating-point literals −
53.8901 /* Legal */
6.159E-5L /* Legal */
4590E /* Illegal: incomplete exponent */
5610f /* Illegal: no decimal or exponent */
.e25 /* Illegal: missing integer or fraction */
Character Constants
Character literals are enclosed in single quotes, e.g., 'x' can be stored in a simple variable of char type.
A character literal can be a plain character (e.g., 'x'), an escape sequence (e.g., '\t'), or a universal character (e.g., '\u02C0').
There are certain characters in C that represent special meaning when preceded by a backslash, for example, newline (\n) or tab (\t) called escape sequence character.
String Literals
String literals or constants are enclosed in double quotes " ". A string contains characters that are similar to character literals: plain characters, escape sequences, and universal characters.
You can break a long line into multiple lines using a \ (backward Slash).
Here are some examples of string literals. All the three forms are identical and valid strings in C.
"ITGyan"
"IT\
Gyan"
Visit us:
Facebook : / itgyanpage
Информация по комментариям в разработке