Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the special symbols in C language?
In C programming language, generally, the special symbols have some special meaning. This language provides low-level access to the memory and it is identified for its performance and efficiency.
The C language includes a character set of English alphabets(a-z, A-Z), digits(0-9), and specific meaning with special characters. Some special characters are operators, while combinations like "
" are escape sequence. In C symbols are used to perform special operations. Some of the special symbols that are used in C programming are as follows ?
[] () {}, ; * = #
Common Characters in C Programming
Let's understand their definitions, which are as follows ?
-
Brackets[] ? Opening and closing of brackets are used for array element reference, which indicate single and multidimensional subscripts.
-
Parentheses() ? These special symbols are used for function calls and function parameters (Read: Functions in C).
-
Braces{} ? Opening and closing of curly braces indicates the start and end of a block of code which contains more than one executable statement.
-
Comma (,) ? It is used to separate more than one statements like separating parameters in function calls.
-
Colon(:) ? It is an operator which essentially invokes something called as an initialization list.
-
Semicolon(;) ? It is called as a statement terminator that indicates the end of one logical entity. That is the reason each individual statement must be ended with a semicolon.
-
Asterisk (*) ? It is used to create a pointer variable.
-
Assignment operator(=) ? It is used for assigning values.
-
Pre-processor (#) ? The pre-processor called as a macro processor is used by the compiler to transform your program before the actual compilation starts.
Example
This program defines a Point structure, a function to print the point, and determines special characters like braces {}, parentheses (), and the arrow operator ->.
#include <stdio.h>
struct Point {
int x, y;
};
void printPoint(struct Point *p) {
printf("Point: (%d, %d)
", p->x, p->y);
}
int main() {
struct Point p = {10, 20};
printPoint(&p);
return 0;
}
The result is generated as follows ?
Point: (10, 20)
Special Symbols in C
The table given below is the respective meaning of the special symbols used in the C programming language.
| Symbol | Meaning |
|---|---|
| ~ | Tilde |
| !#$ | Exclamation markNumber signDollar sign |
| %^& | Percent signCaretAmpersand |
| *() | AsteriskLest parenthesisRight parenthesis |
| _+, | UnderscorePlus signComma |
| ./| | PeriodSlashVertical bar |
| \`- | BackslashApostropheMinus sign |
| =<> | Equal to signOpening angle bracketClosing angle bracket |
| ?{} | Question markLeft braceRight brace |
| []: | Left bracketRight bracketColon |
| "; | Quotation markSemicolon |
Example
In the example below, we are using basic C programs that explain the use of different symbols. This program performs arithmetic operations(subtraction, addition, remainder, multiplication, division) on two integers, x ,and ,y and prints the result for each operation.
#include <stdio.h>
int main() {
int x = 10, y = 15;
int sum, diff, prod, quot, rem;
sum = x + y;
diff = x - y;
quot = y / x;
rem = y % x;
prod = x * y;
printf("Sum: %d
", sum);
printf("diff: %d
", diff);
printf("quot: %d
", quot);
printf("rem: %d
", rem);
printf("prod: %d
", prod);
return 0;
}
The result is obtained as follows ?
Sum: 25 diff: -5 quot: 1 rem: 5 prod: 150