Home  >  Article  >  Backend Development  >  C/C++ markup?

C/C++ markup?

WBOY
WBOYforward
2023-08-30 11:41:131249browse

C/C++ markup?

C token is the smallest independent unit of a program.

C is a superset of C, so most C constructs are legal in C and their meaning and usage remain unchanged. Therefore, tokens, expressions, and data types are similar to C tokens, expressions, and data types.

The following are C tags: (Most C tags are basically similar to C tags)

  • Keywords
  • Identifiers
  • Constant
  • Variables
  • Operators

Keywords

Keywords are reserved words with a fixed meaning and their meaning cannot be changed. The compiler already knows what these keywords mean and how they work. C has more keywords than C, and these extra keywords do special jobs.

There are 32 of them, here are them

auto const double float int short struct unsigned
break continue elseforlong signed switch void
case default enumgoto register sizeof typedef volatile
char do extern if return static unionwhile

There are another 30 reserved words that are not in C and therefore are new to C, Here they are -

asm dynamic_cast namespace reinterpret_cast try
bool explicit new static_cast typeid
catch false operator template typename
class friend privatethis using
const_cast inline public throw virtual
delete mutable protected true wchar_t

Identifiers

Identifiers are names given to different items such as variables, structures, and functions. Furthermore, identifier names must be unique as these entities are used in the execution of the program.

Identifier Naming Convention

  • Only alphabetic characters, numbers, and underscores are allowed.

  • The first letter must be a letter or an underscore (_).

  • Identifiers are case-sensitive.

  • Reserved keywords cannot be used as names for identifiers.

Constants

Constants are like variables, except that once defined, their value does not change during execution.

There are two other different ways to define constants in C. They are:

  • By using the const keyword

  • By using the #define preprocessor

    li>

Constant declaration:

const [data_type] [constant_name]=[value];

Variables

A variable is a meaningful name for a location in computer memory where data is stored. When you use a variable, you refer to the computer's memory address.

Syntax for declaring variables

[data_type] [variable_name];

Example

#include <iostream.h>
int main() {
   int a,b;// a and b are integer variable
   cout<<" Enter first number :";
   cin>>a;
   cout<<" Enter the second number:";
   cin>>b;
   int sum;
   sum=a+b;
   cout<<" Sum is : "<<sum <<"\n";
   return 0;
}

Operators

C operators are used to perform mathematical or logical operations symbol.

  • Arithmetic operators
  • Increment and decrement operators
  • Relational operators
  • Logical operators
  • bit Operator
  • Assignment operator
  • Other operators

Arithmetic operator

tr>##*Multiplication/Division%Modulo##Increment and decrement operators
Operator Description
Addition
- Subtraction

Operator −−Relational operator
Description
increment
Decreasing

##OperatorDescription== is equal to != is not equal to > is greater than is less than >=Greater than or equalLess than or equalLogical operator

OperatorDescription##&&And operator. Performs the logical AND of two expressions. (If both expressions evaluate to True, the result is True. If either expression evaluates to False, the result is False) Or operator. Performs a logical OR operation on two expressions. (The result is True if one or both expressions evaluate to True) Not operator. Performs logical negation on an expression. Bitwise Operator

#||

!

OperatorDescriptionBinary left shift operator is not equal to Binary right shift operatorBinary complement operatorBinary AND operatorBinary XOR operatorBinary OR operator
!=
>>
~
&
^
|

Assignment Operator

Operator Description
= Assign
= td> increments, then assigns
-= decrements , then assign
*= multiplication, then assign
/= division, then Assign
%= to take the modulus, then assign
and shift left Assignment
>>= Shift right and assign
&= Bitwise AND assignment
^= Bitwise XOR and assignment
|= Bitwise OR operation And assign a value

Miscellaneous operators

##OperatorDescription,Comma operatorsizeOf()Returns the size of the memory location. &Returns the address of the memory location. *Pointer to variable. ? :Conditional expression

The above is the detailed content of C/C++ markup?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete