Data Types in C Programming || Operator in C Programming
Data Types in C Programming || Operator in C Programming |
Data types in c :-
- Integer [int ()]
- Float /real [float ()]
- Character [char () ]
Data type means type of data which is used in developing program .There are three types of data in c language :-
- Integer [int ()]
- Float /real [float ()]
- Character [char () ]
- Integer [int ()]: In Integer is a type of data in which number as a whole number without a decimal point . For ex : 22,40
- Float /real [float ()]: In float data type there will be the decimal point for the number which is in fraction. For ex : 22 / 7
- Character [char () ] : In which character like abc …z are considered . The collection of characters is known as a string. For ex : “Chromecoder”.
Variable, Constant and Keywords:-
1] Variables:- Variables are the name given to the location in memory. This location can contain an integer, real, float, characteristic functions.
Rules for constructing variable names:-
A variable name is any combination of 1 to 26 alphabets, digits, under scroll.
Do not create an unnecessary long variable name as it adds you are typing records.
Int No = 1 - is correct
Float = 2.7 - is correct
The first character in the variable name must be an alphabet or under scroll. No commas(,) blank brackets ( ) are allowed within the variable name. No special symbol other than under scroll.
2] Constant:- The constant in the program whose value remains the same throughout the program . For ex : a = 5 ,etc
3] Keywords:- Keywords are a word whose meaning already known/ defined to the compiler. For ex : switch,void ,int ,float ,char,etc.
Operators in c :-
Arithmetic Operators :-
- Addition.
- Subtraction.
- Multiplication.
- Division.
- Modulus.
- Addition:- This operator is used to add two operands. For ex: a and b are the operands, the addition of operands can be a + b.
- Subtraction:- This operation is used to subtract two operands.For ex: a and b are the operands, the subtraction of operands can be a –b.
- Multiplication:- This operator is used to multiply two operands. For ex: a and b are the operands, multiplication is a * b.
- Division :- This operands is used to divide two operands .For ex : a and b are the operands, the division is a / b.
- Modulus :- This operator is used to calculate the reminder of division For ex: c = a % b.
Relational operators:-
These operators are used to compare two values or two operands, the results comes in true or false.1] > [greater than] :- It is used to compare values of two operands .For ex: a and b where a=5 and b=7 ,So a > b =False ,a < b = True.
2] < [Less than] :- It is used to compare values of two operants .For ex: a and b where a=5 and b=7 ,So a > b =False ,a < b = True
3] ==[Equal to] :- It is used to check if the values are similar or not.For ex : a==b , where a=5 and b=5 , So result == true.
Logical operators : -
The logical operator checks the conditions.- AND [ && ]
- OR [ || ]
- NOT [ ! ]
- AND [ && ]:- When all the conditions are true then the output also true and when one of the conditions is false then output also false.
- OR [ || ]:- Check whether one of the condition is true the output also true if all condition are false then output also false
- NOT [ ! ] :- The logical NOT operator is unary .Not operator i.e it takes only one operand. The effect of NOT operator is that the logical value of that operate is reversed.
Assignment operator:-
This operator is used to assign value to its operand or variable.For ex : a = 5
This “=” is called as Assignment operator.
Increment ,decrement operator :-
Increment Operator:- To increment the value of operands by 1, the”++” increment operator is used. There are 2 types of increment operator:-pre-increment operator. [ For ex ++i]
post-increment operator. [ For ex i++]
Decrement operator:- The decrement operator has 2 types:-
pre-decrement. [ For ex --i]
post-decrement. [ For ex i--]
It is used to decrement the value of operand by 1.
For ex : “--” is pre decrement and “i—“ is post decrement.
Post a Comment