Posts

Showing posts from September, 2022

Operators in C

Image
  //operators in C programming language //Operators: a symbol used to perform operations in given programming language //Types of operators in C language     /*1. Arithmetic Operators       2. Relational Operators       3. Logical Operators       4. Bitwise Operators       5. Logical Operators     */ //--------------------------------------- //Arithmetic Operators     /*(+): addition       (-): subtraction       (*): multiplication       (/): division       (%): modulus - gives remainder       */ //--------------------------------------- //Relational Operators     /*(==): is equal to       (!=): is not equal to       (>): greater than       (<): less than       (>=): greater than or equal to       (<=): less  than or eq...

Variables and Data Types in C

//variables in C //variable: A name given to a memory location is called variable //declaring variable: type variable_name; //rules for defining a variable in C     /*1. can contain alphabets, digits and underscore(_)       2. a variable name can start with an alphabet and underscore only       3. can't start with a digit       4. whie space and reserved words are not allowed to give name of a variable       */ //Data types in C     /*1. basic data type: int, char, float, double       2. derived data type: this type of data types are created or derived by using basic data types                             array, pointers, structure, union       3. enumeration data type: emum       4. void data type: void     */ #include <stdio.h> int main () {     printf ( " %lu " , s...

Tokens in C

//basic syntax of a C program // a C program is made up of the collection of tokens // Token: smallest unit used in a C program is called token #include <stdio.h> int main () {     int     a // token (identifier)     ;     a     = // token (operator)     100 ;     printf     (           "softwareharaish" //token (string literal)     )     ; //token (symbol)     return //token (keyword)     0 //token (constant)     ; } // in the above c program I breaks the program into individual tokens // types of tokens i C program     /*  1. keywords: reserved words which has a special meaning in c program ()         2. identifiers: name of functions, variables ets to identifie                         (panctuators are not allowed to make id...

Steps taken by a compiler to execute a C program

//steps taken by a compiler to execute a C program /*  1. pre processing: i) comments removal                        ii) macros expansion                        iii) #files inclusion                        iv) conditional compilation     2. compilation: converts to assembly level instructions     3. assembling: converts to machine level instructions     4. linking: linker combine all machine level instructions                 to create an executable file that is .exe file*/ //to understand better how compiler works follow the below step /* A) execute "gcc -Wall -save-temps file_name.c" on vs code terminal     u will get 4 extra files in explorer this files will show u how compiler works         1. file_name...