Posts

Showing posts from August, 2018

C/C++ Tokens

A token is the smallest element of a program that is meaningful to the compiler. Tokens can be classified as follows: Keywords Identifiers Constants Strings Special Symbols Operators Keyword:  Keywords are pre-defined or reserved words in a programming language. Each keyword is meant to perform a specific function in a program. Since keywords are referred names for a compiler, they can’t be used as variable names because by doing so, we are trying to assign a new meaning to the keyword which is not allowed. You cannot redefine keywords. However, you can specify text to be substituted for keywords before compilation by using C/C++ preprocessor directives. C  language supports  32  keywords which are given below: auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed...

Line Splicing in C/C++

While writing a program, sometimes we give comment about the working of the code in the comment section with the help of single/double comment line. But we had never thought that if at the end of this comment line if we use \(backslash) character then what will happen? The answer of the above question is line Splicing. Lines terminated by a \ are spliced together with the next line very early in the process of translation.  §2.2 Phases of translation . Actually whenever at the end of the comment line if we use \(backslash) character then it deletes the backslash character and the preceding next line of code only from the entire program or we can say that the ending \(backslash)  makes the new line also as a comment for the compiler. // C program to illustrate the concept of Line splicing. #include <stdio.h> int main() {      // Line Splicing\      printf ( "Hello GFG\n" );      printf ( "we...

Escape Sequences in C

In C programming language, there are 256 numbers of characters in character set. The entire character set is divided into 2 parts i.e. the ASCII characters set and the extended ASCII characters set. But apart from that, some other characters are also there which are not the part of any characters set, known as ESCAPE characters. List of Escape Sequences \a Alarm or Beep \b Backspace \f Form Feed \n New Line \r Carriage Return \t Tab (Horizontal) \v Vertical Tab \\ Backslash \' Single Quote \" Double Quote \? Question Mark \ooo octal number \xhh hexadecimal number \0 Null Some coding examples of escape characters // C program to illustrate // \a escape sequence #include <stdio.h> int main( void ) {      printf ( "My mobile number "            "is 7\a8\a7\a3\a9\a2\a3\a4\a0\a8\a" );      return (0); } Run on IDE Output...