Posts

Showing posts from June, 2017

Data Types in C

Image
1.4 Data types    As in our daily languages we have different alphabets, numbers and special characters, in C we have many “data types”. These could be defined as the fundamental blocks by which define how any form of data is to be stored and processed. These data types may be different based on compilers, but in general C data types are classified into fundamental, derived and programmer-defined data types. C programming basic data types Fundamental data types are namely void, int, float, char, long, double, * (pointer type). Derived data types include arrays, string and structures. Programmer defined data types include Structure, Union and Enumerations. Let’s keep it short and define only the essential ones as you’ll have separate tutorials on some data types. 1.     Int:  This data type indicates integer numbers and it is represented by “ int ” keyword in C. Integers consume storage space of 2 bytes and range from -32,768 to 32,768. 2.     Long: This data t

What are C tokens ?

Image
1.3 What is a token? In our world when someone says token we think of an object that represents something else for example It may the receipt was given by the shopkeeper to you. But in c programming, it is the smallest unit or text which cannot be divided into a smaller unit. C token are divided as Let see them one by one Keywords We can say them reserved words because they have some special meaning in c compiler. These words cannot be used as an identifier. C language uses the following keywords: Auto Double Int Struct Break Else long Switch Case Enum register Typedef Char Extern return Union Etc. we will see them afterward. Identifier These are the name you use for a variable, functions in your program. You can begin naming a character or an underscore followed by any character or number.  Uppercase and lowercase letters are not equivalent in C, so the two id

Our First Program in C

1.2   Basic Program Let’s start here with a basic program which is so famous that is used in every beginner tutorial. We are going to discuss Hello World program. This prints (writes) “Hello World” onto the screen. #include <stdio.h> int main() {   printf( “Hello World” );   return 0 ; } The program above can be written in any text editor but has to be saved with the extension ‘ .c ’. Then the program must be compiled and run for the outcome. You’ll learn more about these processes in the previous tutorial. For now, when this program is compiled and run it’ll print “Hello World” onto the screen. Codeblocks is an IDE (Integrated Development Environment) which does all the above processes of writing, compiling and running code in one go. Now let’s take a look at the code. The first line of this C code is called preprocessor directive. These lines start with “ # ” and are, as the name suggests; directions to the preprocessor . This line says to include a file