Clear, practical technology insights About · Contact

Modifier in C // C ++: Modifier in C // C ++

Understand Modifier in C // C ++: Modifier in C // C ++ with clear explanations, practical examples, and useful tips. This updated guide covers the...

Published: 2 minutes read
Table of Contents

Modifier in C // C ++: Modifier in C // C ++ is easier to understand when the core ideas are paired with practical examples. The sections below explain the topic clearly, highlight useful steps, and point out details that can prevent common errors.

C ++ allows data types char, int and double to have Modifiers placed before them. A Modifier helps inform the meaning of the base type, making it more accurate with the necessity of diverse situations.

Here are the Modifiers in C / C ++:

  1. signed (signed)
  2. unsigned (no sign)
  3. long
  4. short

Modifiers are: signed, unsigned, long, and short can be applied to integer types. Also, signed and unsigned can be applied to char, and long can be applied to type double.

The signed and unsigned Modifiers can also be used as prefixes for Modifiers that are long or short modifiers. For instance,: unsigned long int.

C ++ allows the type of declaration to be shortened to declare unsigned, short, or long integer. You can simply use unsigned words , short , or long , without int. the example below illustrates two declarations that are valid in C / C ++ to declare unsigned integer variables:

 unsigned x ; unsigned int y ; 

To distinguish the difference between two Modifiers is signed integer and unsigned integer interpreted by C / C ++, you should run the following program:

 #include using namespace std ; /* Chuong trinh nay chi ra diem khac nhau giua * cac so nguyen signed va unsigned. */ int main () { short int i ; // mot so nguyen signed short int short unsigned int j ; // mot so nguyen unsigned short int j = 32769 ; i = j ; cout << i << " " << j ; return 0 ; } 

It will result:

 - 32767 32769 

If you go back to the Data type chapter in C / C ++ , and read the range of values ​​of short int and unsigned short int, you will notice the difference when running the above program with j <= 32767 and with j> = 32767.

Qualifier in C / C ++

The Qualifier provides additional information about the variables that follow it.

Qualifier Thoughtaconst The object of const type cannot be changed by the program while executing volatile Modifier tells the compiler that the value of the variable can be changed indistinct (unannounced) by the program. restrict A pointer is set to restrict , which means that the object it points to can be accessed. Restrict is added in the C99 standard.

Next lesson: Storage Class (Storage Class) in C / C ++

Frequently Asked Questions

What should you know about qualifier in C / C ++?

The Qualifier provides additional information about the variables that follow it.

What is Modifier in C // C ++: Modifier in C // C ++?

C ++ allows data types char, int and double to have Modifiers placed before them.

Why is Modifier in C // C ++: Modifier in C // C ++ important?

A clear understanding of Modifier in C // C ++: Modifier in C // C ++ helps you make informed decisions, avoid common mistakes, and use the relevant tools or techniques more effectively.

Was this article helpful?

Your feedback helps us improve.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.