![]() |
C is a procedural programming language. It was developed by Dennis Ritchie at the Bell Laboratories in the year 1972. Despite being old C is a very popular language among programmers. It is a very fast language compared to other languages like Python, Java, etc. Below is the basic syntax structure of the C program: The basic syntax of the C program consists of the header, main() function, variable declaration, body, and return type of the program.
C
Output
Hi! This is a basic C program. TokensA token in C programming is either a keyword, an identifier, a constant, a string literal, or a symbol. Let’s get a good understanding of tokens through a print statement in C language. printf("GeeksforGeeks\n"); Individual tokens from the above syntax are: printf ( "GeeksforGeeks\n" ) ; SemicolonsIn C programming Semicolon is used to show the termination of Instruction. It is also called a statement terminator since every single statement should be ended with a semicolon. Semicolons are used to end statements in C. The Semicolon tells the compiler that the current statement has been terminated. If any statement in the Program ends without a semicolon, then the program will not compile and will generate an error message. C
Error ./253df686-61b0-495f-98fe-46dfeb318172.c: In function 'main': ./253df686-61b0-495f-98fe-46dfeb318172.c:7:5: error: expected ';' before 'return' return 0; ^ Preprocessor DirectivesIn C language, a program should begin with preprocessor directives since they contain multiple files that contain specific functions. Preprocessors in C are used to process our source code before compilation. There are 4 main types of Preprocessor directives in C:
While executing a program in C multiple steps are involved as mentioned below: ![]()
Identifiers in CIn C programming, the identifier is used to identify a variable, function, or any other user-defined data type. C programming language does not allow special characters such as $, @, or % within the identifier. C is a case-sensitive programming language which means that “horje” and “Geeksforgeeks” are treated as two different identifiers in C. Identifiers should begin with a letter Uppercase letters (A to Z), lowercase letters (a-z), digits (0-9) or underscores ( _ ). Some examples of identifiers in C are:
C KeywordsIn the C programming language, keywords are reserved words that have special meanings. These reserved words can’t be used as variables or constants or any other identifier name. C contains a total of 32 keywords that are reserved and have special meanings. Keywords in C programming are mentioned below:
Comments in CIn C programming Comments are used to make any program more readable and understandable. Comments are generally used by programmers to add explanations or descriptive text in the code without any interference from the compiler or the programming structure. Comments are not programming statements and they are ignored by the compiler. We can’t have comments inside comments since they will interfere within themselves. In C language there are two types of programming comments:
Example C
Output
GeeksforGeeks In the above C program, comments are ignored by the compiler and they can be read only by the programmer. Whitespaces in CIn C programming lines containing white spaces, blank lines, and comments are ignored by the compiler. Whitespace in C is used to describe blanks, newline characters, comments, and tabs. Whitespace is used to separate parts of a statement from another and it helps the compiler to distinguish the keywords, identifiers, and elements in a statement. It allows us to format our code in a way that makes it easier to understand by programmers and others. In C we are free to use the whitespaces to increase user readability. Example of Whitespace in C: int a; // whitespace used to increase readablity and to distinguish elements. string s = "GeeksforGeeks"; FunctionsIn C programming Function is a set of statements that performs specific computations. Functions help us to reduce our code redundancy. Instead of writing multiple lines of code again and again we use functions to reduce code redundancy. Functions in C provide abstractions. In C “main” is also a function that has its own return type defined in the program. This function serves as the starting point for program execution. Syntax return_type function_name(parameter_list) { // Function body (code goes here) } Example int mul(int Full_marks,int Full_marks2); Below is the representation of the above C function: ![]()
|
Reffered: https://www.geeksforgeeks.org
C Language |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |