An identifier is use for any variable, constants, functions, structures, pointers, arrays, structures, unions, labels, or any other user-define data, to identify them. An identifier can be compose of letters just like uppercase, lowercase letters, underscore, digits. The starting letter should be either an alphabet or an underscore only. It can not start with a digit. There are 52 alphabetical characters (uppercase and lowercase), underscore character, and 10 numerical digits (0-9) that represent the identifiers. There is a total of 63 alphanumerical characters that represent the identifiers is knows as C Identifier.

Rules for C identifiers

  • The first character of an identifier should be either an alphabet or an underscore.
  • It should not Starting with any numerical digit.
  • In identifiers, both uppercase and lowercase letters are distinct.
  • Commas or whitespace cannot be specified within an identifier.
  • The Keywords cannot be represent as an identifier.
  • The length of the identifiers should not be more than 31 characters.

Types of identifiers

There are two Types identifiers

  • Internal identifier
  • External identifier

Internal Identifier

The identifier is not use in the external linkage, then it is known as an internal identifier. The internal identifiers can be use in local variables.

External Identifier

The identifier is use in the external linkage, then it is known as an external identifier. The external identifiers can be use in function names, global variables.

Example of Identifier

int main()  
{  
    int v=45;  
    int V=80;  
    printf("Value of v is : %d",v);  
    printf("\nValue of V is :%d",V);  
    return 0;  
}  

Output of Identifier

Output value

C Operators

An operator are use to perform operations on values and variables. It is  perform specific mathematical or logical functions is knows as C Operators.

Some types of Operators

  • Arithmetic operators
  • Assignment operators
  • Comparison operators
  • Logical operators
  • Bitwise operators

Arithmetic Operators

OperatorDescription
+Adds two operands.
Subtracts second operand from the first Operands.
*Multiplies both operands.
/Divides one operands by another operands.
%Returns the division remainder
++Increment operator increases the integer value by 1.
Decrement operator decreases the integer value by 1.

Example of Arithmetic Operators

Input value

#include <stdio.h>

main() {

   int x = 21;
   int y = 10;
   int z ;

   z = x + y;
   printf("Value of z is %d\n", z );
	
   z = x - y;
   printf("Value of z is %d\n", z );
	
   z = x * y;
   printf("Value of z is %d\n", z );
	
   z = x / y;
   printf("Value of z is %d\n", z );
	
   z = x % y;
   printf("Value of z is %d\n", z );
	
   z = x++; 
   printf("Value of z is %d\n", z );
	
   z = x--; 
   printf("Value of z is %d\n", z );
}

Output value

Output value

Assignment operators

OperatorDescription
=Simple assignment operator. Assigns values from right side operands to left side operand.
+=Add AND assignment operator. It adds the right operand to the left operand and assign the result to the left operand.
-=It subtracts the right operand from the left operand and assigns the result to the left operand
*=It multiplies the right operand with the left operand and assigns the result to the left operand
/=Divide AND assignment operator. It divides the left operand with the right operand and assigns the result to the left operand.
%=Modulus AND assignment operator. It takes modulus using two operands and assigns the result to the left operand.
<<=Left shift AND assignment operator.
>>=Right shift AND assignment operator.
&=AND assignment operator.
^=exclusive OR and assignment operator.
! =inclusive OR and assignment operator.

Example of Assignment operators

Input value

#include <stdio.h>

main() {

   int x = 45;
   int z ;

   z =  x;
   printf("Operator Example, Value of z = %d\n", z );

   z +=  x;
   printf("Operator Example, Value of z = %d\n", z );

   z -=  x;
   printf("Operator Example, Value of z = %d\n", z );

   z *=  x;
   printf("Operator Example, Value of z = %d\n", z );

   z /=  x;
   printf("Operator Example, Value of z = %d\n", z );

   z  = 400;
   z %=  x;
   printf("Operator Example, Value of z = %d\n", z );

   z <<=  40;
   printf("Operator Example, Value of z = %d\n", z );

   z >>=  40;
   printf("Operator Example, Value of z = %d\n", z );

   z &=  40;
   printf("Operator Example, Value of z = %d\n", z );

   z ^=  40;
   printf("Operator Example, Value of z = %d\n", z );

   z |=  40;
   printf("Operator Example, Value of z = %d\n", z );

}

Output of Assignment operators

Output value

Logical operators

OperatorOperator
&&Called Logical AND operator. If both the operands are non-zero, then the condition becomes true.
||Called Logical OR Operator. If any of the two operands is non-zero, then the condition becomes true.
!Called Logical NOT Operator. It is used to reverse the logical state of its operand. If a condition is true, then Logical NOT operator will make it false.

Example of Logical operators

#include <stdio.h>

main() {

   int x = 40;
   int y =250;
   int z ;

   if ( x && y ) {
      printf("Condition is true\n" );
   }
	
   if ( z || y ) {
      printf("Condition is true\n" );
   }
   
   x = 5;
   y = 25;
	
   if ( x && y ) {
      printf("Condition is true\n" );
   } else {
      printf("Condition is not true\n" );
   }
	
   if ( !(x && y) ) {
      printf("Condition is true\n" );
   }
	
}

Output of Logical operators

Output value

If you have any queries regarding this article or if I have missed something on this topic, please feel free to add in the comment down below for the audience. See you guys in another article.

To know more about C Programming language please Wikipedia click here .

Stay Connected Stay Safe, Thank you


Basic Engineer

Hey Readers! We have more than fifteen years of experience in Software Development, IoT, Telecom, Banking, Finance and Embedded domain. Currently we are actively working on Data Science, ML and AI with multiple market leaders worldwide. Happy Reading. Cheers!

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *