Data type of c programming and operator in C programming

 

C Programming Languages

Introduction and Features of C Language 

Ans: C is a programming language developed at AT & T's Bell Laboratories of the USA in the 1970s. It was designed and developed by Dennis M. Ritchie. C seems so popular because it is reliable, simple, and easy to use. C stands in between high-level language and low-level language. That is why it is often called a Middle-level language. It is designed to have both: relatively good programming efficiency (as compared to machine-oriented languages) and relatively good machine efficiency.

 Advantage of C programming:

  1. It is more efficient than unstructured code because of the minimized branching of the code.
  2. Correction of errors (debugging) in a program is easy. Adding a new feature is easier and faster.
  3. Maintenance of the C code is easy due to the readability of the code.
  4. It is easy to interact with hardware.
  5. It is easy to learn.
  6. The program code is secured. It is compact and efficient to use.

The disadvantage of C Language

  1. The program takes more time to design and implement the software.
  2. C coding techniques sometimes result in repeating code in a program.
  3. RC coding becomes less efficient if the sub-routines called frequently thereby killing the time. C does not have efficient garbage collection i.e. problem regarding memory clearance.
  4. It doesn't contain runtime checking.
  5. There is no strict type checking (for example, we can pass an integer for floating data value type).

  6. As the program extends, it is very difficult to fix the bugs. It does not support Object-oriented Programming (OOP) features, so to overcome C++ language was introduced.

Data Types in C

The data type is an instruction that is used to declare the category or type of the variable being used in the program. Any variable used in the program must be declared before using it. It determines the way a computer organizes data in memory. It determines how much space it occupies in storage and how the bit pattern stored is interpreted. Types of data types can be either basic (fundamental) and derived. The basic data types in C are the basic types (int, float, and char) and the type void. The derived data types are array, string, structure, and union.

int

Ans: int represents integer numbers (numbers without fractions e.g. 546). It requires 2 bytes of memory space. It can be either signed or unsigned. Derived data types from int are short int, long int.

Float

Ans: float represents real numbers (numbers with fractions e.g. 3.14). It requires 4 bytes of memory space. It can also be signed or unsigned. Derived data types from float are double, long double.

char

Ans: char represents a single alphabet or symbol (e.g. 'A', 'f, '@') or multiple alphabets or symbols for the string. It requires 1 byte of memory space. It can also be either signed or unsigned.

void

The void data type has no values. It is used as the return type for functions that do not return a value.

Here is the list of data types with their corresponding memory requirement and range of value it can take:
 

Operators and Expressions


Ans: C is very rich in built-in operators. An operator is a symbol that instructs C to perform some operation action on one or more operands. An operand is something that an operator acts on. Operators d require two operands are binary (dyadic) operators, operators that require one operand is a (monadic) and operator that requires three operands is a ternary operator.

For example, in a mathematical expression: A + B, where A and B are the operands,+ is the operator.

A+B is an expression.

The C offers different types of operators:

1. Arithmetic operator
2. Relational operator
3. Equality operator
4. Logical operator
5. Assignment operator
6. Increment/Decrement operator
7. conditional operator
8. bitwise operator

Arithmetic Operator
Ans:  Arithmetic operator is a symbol used for basic mathematical calculations. It usually takes two operands and returns the result of the mathematical calculation. C contains five arithmetic operators.

Relational Operator
Ans:  Relational operator is a symbol that determines the relationship between two different operands. C provides four relational operators in which all operators are binary for comparing numbers and characters. Relational operators always give the final result in terms of true and false after its operation.

Equality operator
Ans: Equality operator is a symbol used to compare two operands if they are equal or not. It executes either true or false result. It is a binary operator.

Logical operator
Ans: Logical operator is a symbol that logically connects the logical expressions i.e. it is used to connect two or more expressions.

Increment/Decrement operator
Ans: These operators are also called unary or monadic operators as they act upon the single operand. The increment operator (++) causes its operand to be increased by whereas the decrement operator (--) causes its operand to be decreased by one. In other words, a = a + 1 is the same as 2 or a++ and a = a - 1 is the same as - - a or a=-.
Both the increment and decrement operators come in two varieties: they may either precede follow the operand. The prefix version comes before the operand (as in ++a or --a) and the postfix version comes after the operand (as in a++ or a--). The prefix increment decrement operators follow, change then use rule i.e. they first change (increment or decrement the value of the operand, then use the new value in evaluating the expression. The post-increment or decrement operators follow, use then change ie they first use the value of the operand in evaluating the expression and then change (increment or decrement) the operand's rule.

Assignment operator
Ans: An assignment operator is a symbol used to assign a value or a result of an expression to an identifier. There are several different assignment operators in c. All of them at used to form assignment expressions.

1. Simple assignment:
Ans: The most commonly used assignment operator is = Assignment expressions that make use this operator are written in the form.

2. Multiple assignments
Ans: c also allows multiple assignment statements using =.

Conditional Operator (?:) [ Ternary operator ]
And: C offers a conditional operator (?: ) that stores a value depending upon a condition. This operator is called a ternary operator as it requires three operands.

Bitwise operator
Ans: Bitwise operators are used to perform calculations using binary digits which can be performed using the following operators.




Author Spotlight

Santosh Chapagain
Gmail: chapagainsantoshcs@gmail.com
Phone no: +977-9863512955

Post a Comment

0 Comments