C Programming
C Programming
technical training
Example 2:
printf("control strings",&v1,&v2,&v3,................&vn);
a=25
(Or) printf(“A value is %d”,a)
o/p : 25
printf("Message line or text line");
Note: %d is format specifies for integers
scanf("control strings",&v1,&v2,......&vn);
Example:
• int myInt=4;
• float myReal=2.5;
• char myChar=“a”;
These data types are defined by the user. Structure is a data type that can store variables of similar or
The following are the derived data types in C: different data types. The size of the structure is the sum of
A data type that has no values or operators and is used to represent nothing.
It is used in three kinds of situations:
Function returns as void
Ex: void exit (int status);
Function arguments as void
Ex: int rand(void);
Pointers to void
Ex: void *malloc( size_t size);
In C, Boolean is a data type that contains two types of values, i.e., 0 and 1.
Basically, the bool type value represents two types of behavior, either true or false.
Here, '0' represents false value, while '1' represents true value.
Syntax:
bool variable_name;
Example:
bool x=true;
Example:
used on a single
operand in order to
calculations.
an operand.
& bit-wise AND x=x&28 0000 1111 & 0001 1010 =0000 1010
15 28 10
Double Pointer operator data_type **pt; Double Pointer is, that double pointer points to another pointer variable
("**") address.
sizeof operator sizeof (data_type) sizeof returns the size of a variable or datatype
singled-lined
/* The code below will print the words Hello World!
multi-lined to the screen, and it is amazing */
printf("Hello World!");
Using this concept the compiler can understand that what type of data is in a variable
during taking input using the scanf() function and printing using printf() function.
Example:
print(“Value of a is %d”,234)
Escape sequences are used to format the output text and are
not generally displayed on the screen.
Interchange”.
communication.
ASCII contains numbers, each character has its own number to represent.
List of Constants:
Constant Example
Decimal Constant 10, 20, 450 etc.
Real or Floating-point Constant 10.3, 20.2, 450.6 etc.
Octal Constant 021, 033, 046 etc.
Hexadecimal Constant 0x2a, 0x7b, 0xaa etc.
Character Constant 'a', 'b', 'x' etc.
String Constant "c", "c program", "c in javatpoint" etc.
Types of literals:
Integer literal
Float literal
Character literal
String literal
Backslash Character Literals (Escape Sequences)
www.ciits.org cognitiveiitsolutions@gmail.com | admin@ciits.org
LITERALS IN C Character literal:
A character literal is created by enclosing a
Integer literal: single character inside single quotation
An integer is a numeric literal(associated with marks.
numbers) without any fractional or exponential part. Ex: 'a', 'm', 'F', '2', '}' etc.
1. Decimal Numer (base 10) Ex: 0, -9, 22 etc String literal:
2. Octal Number (base 8) Ex: 021, 077, 033 etc A string literal is a sequence of characters
3. Hexadecimal Number (base 16) Ex: 0x7f, 0x2a, etc enclosed in double-quote marks.
Float literal: Ex: "study", "tonight", "c programming", etc.
A floating-point literal is a numeric literal that has Backslash Character Literals (Escape Sequences):
either a fractional form or an exponent form. Sometimes, it is necessary to use characters
Ex: 100.50 0.000127 -0.77E-5 that cannot be typed or has special meaning in
C programming.
Ex: \n, \t, etc.