C/C++ markup?

WBOY
Release: 2023-08-30 11:41:13
forward
1113 people have browsed it

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
Copy after login

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
Copy after login

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

< p>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

Constant declaration:

const [data_type] [constant_name]=[value];
Copy after login

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];
Copy after login

Example

#include  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 : "<
        
Copy after login

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

##Operator Description == is equal to != is not equal to > is greater than is less than >= Greater than or equal Less than or equal Logical operator

Operator Description ##&& 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

#||

!

Operator Description Binary left shift operator is not equal to Binary right shift operator Binary complement operator Binary AND operator Binary XOR operator Binary 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

##Operator Description , Comma operator sizeOf() 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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!