Monday, 31 December 2018

C Data type

The word data type tells that it describes the type of data.  We haven't yet studied variables, functions etc. Data type is used there to describe the type of data. C supports several different types of data, each of which may be represented differently within the computer’s memory. Below are 4 basic data types.


Data typeDescriptionMemory requirement  Value range
charsingle character1 byte -128 to 127
int integer quantity2 bytes-32,768 to 32,767
float floating-point number4 bytes-2,147,483,648 to +2,147,483,647
double double precision floating-point number 8 bytes 2.3E-308 to 1.7E+308

The above data types can be used in an extensive way by using qualifiers like signed,unsigned, short, long.
For example, int data type can be used as signed int or long int and char data type can be used as signed char or long char.
Signed int means it will consider the sign bit and it is same as normal int but in case of unsigned int the value range will be from 0 to 65,535.

The char data type represents individual characters. Hence, the char type will generally require only one byte of memory. Actually char type is of integer type.
With most compilers, a char data type will permit a range of values extending from 0 to 255. Some compilers represent the char data type as having a range of values extending from -128 to +127. There may also be unsigned char data (with typical values ranging from 0 to 255), or signed char data (with values ranging from -128 to +127).

Keywords and Identifiers of C Language

Identifiers
Identifiers are names that are given to various program elements, such as variables, functions and arrays. These are user-defined. Identifiers consist of letters, digits and some characters but the first letter must be a letter. Generally lowercase letter is used but uppercase letter can also be used. Uppercase and lowercase letters are not interchangeable.
Identifiers can be of any length but typically it accepts 31 characters.
The following names are valid identifiers.

    a   x   xy   firstname  lastName  area_of_circle   _length  test18
The followings are not valid identifiers.
         18test                   The first character must be a letter
         "xx"                      Illegal character "
         first name             Blank space
         last-name              Illegal character -

Keywords:
In C programming language, there are some certain reserve words. These reserve words are called Keyword. Keywords can be used only in particular purpose that is defined in language. So, keywords cannot be used as identifiers. Keywords have standard predefined meanings.
C keyword list is below:
      
Keywords in C Language
auto double int struct
break else long switch
case enum register typedef
char extern return union
continue for signed void
do if static while
default goto sizeof volatile
const float short unsigned

Note that the keywords are all lowercase. Since uppercase and lowercase characters are not equivalent, it is possible to utilize an uppercase keyword as an identifier. Normally, however, this is not done, as it is considered a poor programming practice.

Sunday, 30 December 2018

C Character Set


Character set is important for any computer languages because this character is understood by the compiler. To write a program, we code, but the code has to be meaningful to the compiler. To write statement, expression, variable or custom function name, this are formed from this computer set.

C character sets are belows:
  • Uppercase letter A to Z
  • Lowercase letter a to z
  • The digit 0 to 9
  • And some special character sets
    +    -      *    /    =    %   &    # 
    !     ?     ^    "      '   ~      \      |
    <     >   (      )      {    }     [      ]
    :      ;     .     ,       _
Most versions of the language also allow certain other characters, such as @ and $, to be included within strings and comments. It also allow some White space characters. These are;
  • \b blank space
  • \t horizontal tab
  • \v vertical tab
  • \r carriage return
  • \f form feed
  • \n new line 
  • \\ Back slash
  • \’ Single quote
  • \" Double quote
  • \? Question mark
  • \0 Null
  • \a Alarm (Audible Note)

Saturday, 29 December 2018

C Program Structure

C program structure

C is structured. So, it is modular and the modules are function, i.e. the modules are called function. One of the functions must be called main. The program will always begin by executing the main function, which may access other functions.

To run a c program, you must include something at the beginning of the code, which will ensure your smooth compiling. It is sort of mandatory because this loads some initial code to run a program. For example;
#include <stdio.h>

The #include is a "preprocessor" directive that loads a file called stdio.h (stdio.h is a header file). Header files are collection of some build-in codes that does a lot of task to run a program.
Now look at the below program;

#include <stdio.h>
int main()
{
  printf("Hello,World"); 
  return 0; 
  //end of code(this is a comment)
}

So the whole program is enclosed by a function and this function is called 'main()'.
In later tutorial, you will learn about details of functions, how to write function, how to use it, what are required to write a function.  
Codes are written in an enclosed pair of braces, i.e., { }
Inside braces expression statements are written, i.e., printf("Hello,World");
Each expression statement must end with a semicolon (;). 
Comments (remarks) may appear anywhere within a program, as long as they are placed within the delimiters  /* and */ (e.g., /* this is for multiple comment */). Single line comment can be written after two forward slashes //.
The program is typed in lowercase. Either upper- or lowercase can be used, though it is customary to type ordinary instructions in lowercase.

Wednesday, 26 December 2018

History of C Language

History of C

C was developed by Dennis Ritchie at Bell Telephone Laboratories, Inc. (now a part of AT&T) in 1972. When Dennis Ritchie was trying to rewrite the code for UNIX operating system, C was born. He was considering to rewrite the system using the B language, Thompson's( Ken Thompson invented B programming language) simplified version of BCPL. The name of C was chosen simply as the next after B. So, C is an outgrowth of two earlier languages, called BCPL and B.

Earlier days, C was basically used within Bell Laboratories. In 1978, Brian Kernighan and Ritchie published a definitive description of the language. The Kernighan and Ritchie description is commonly referred to as "K&R C." After that, further development of C was began. By the mid 1980s, the popularity of C had become widespread. Numerous C compilers and interpreters had been written for computers of all sizes, and many commercial application programs had been developed. Many commercial software applications were started to re-written in C language.

Due to availability of various C compilers, minor incompatibilities were found between different implementations of the language. To stop this problem, the American National Standards Institute (ANSI) formed a committee, X3J11, to establish a standard specification of C in 1983. In 1990, the ANSI C standard (with formatting changes) was adopted by the International Organization for Standardization (ISO). Later the different versions of C was introduced as C89, C99 etc. and the current standard for the C programming language is C18(published in June, 2018).




Tuesday, 25 December 2018

Introduction to C Language

Introductoin to C language

C is a general-purpose, structured programming language. It is really a powerful language to write complex computer program and that's why it is really one of a popular high level language like Pascal and Fortran. It has features that allows user to write low-level programming language and it is flexible also to write system programming (i.e. operating system) and application programming. 

It's instruction set includes large number of operators, several built-in functions, control-statement keyword etc. Hence, it allows users to write additional library function. Program written in C language is very fast.

C is highly portable. So, a C program, written in one computer can be run on another with little or no modification. The reason for this is that C relegates most computer-dependent features to its library functions. 

As it said earlier that C is structured programming language which means program can be written as block in terms of function module. A proper collection of modules would make a complete program.

What Is The Difference Beween Numerals and Number?

Number is a concept, it is a mathematical concept. To express the quantitative value of the object, this  is developed in ancient history. S...