C

What is C ?
  • The C Language is developed for creating system applications that direct interacts to the hardware devices such as drivers, kernals etc.
  • C programming is considered as the base for other programming languages, that is why it is known as mother language.

History of C Language :
  • C programming language was developed in 1972 by Dennis Ritchie at bell laboratories of AT&T (American Telephone & Telegraph), located in U.S.A.
  • Dennis Ritchie is known as the founder of c language.
  • It was developed to overcome the problems of previous languages such as B, BCPL etc.
  • Initially, C language was developed to be used in UNIX operating system. 
  • It inherits many features of previous languages such as B and BCPL.

Features of C Language :
  • Simple
  • Machine Independent or Portable
  • Structured programming language
  • Mid-level programming language
  • Rich Library
  • Extensible
  • Recursion
  • Fast Speed
  • Pointers
  • Memory Management

Con's of C language :
  • It doesn't have run time checking mechanism.
  • It doesn't support OOPS.
  • It doesn't support exception handling.
  • It doesn't support namespace feature.
  • It doesn't support generic programming.
  • It doesn't function with default arguments.

How to install Turbo C++ ?
  • Search for turbo c++ in google.


  • Go to the official website and click on the download link.


  • Click on the setup file.
                    

  • Click on next.
                     

  • Accept the terms in license agreement.
                         

  • Click on install.
                         

  • Click on finish.
                

  • Click on start turbo c++.
                            

  • Program to display Hello C.
                    

Basic concepts in c :
  • A variable is a name of memory location. It is used to store data. Its value can be changed and it can be reused many times. 
  • It is a way to represent memory location through symbol so that it can be easily identified.
  • Syntax: type variable_list; [ Ex : int a;  float b;  char c; ]. Here, a, b, c are variables and int,float,char are data types.
  • We can also provide values while declaring the variables. int a=10,b=20; //initialization.
  • A data type specifies the type of data that a variable can store such as integer, floating, character etc.

Control Statements :
  • Control statements enable us to specify the flow of program control i.e, the order in which the instructions in a program must be executed.
  • The if statement in C language is used to perform operation on the basis of condition. By using if-else statement, we can perform operation either condition is true or false.
  • The single if statement in C language is used to execute the code if condition is true. syntax: if(expression) {  //code to be executed  }
  • The if-else statement in C language is used to execute the code if condition is true or false. 
  • Syntax: if(expression) { //code to be executed if condition is true } else { //code to be executed if condition is false  }
  • The switch statement in C language is used to execute the code from multiple conditions.
                     

Functions in C :
  • To perform any task, we can create function. A function can be called many times.
  • Syntax: return_type function_name(data_type parameter..){  //code to be executed  }
  • If a function returns any value, we need to call function to get the value returned from the function. Syntax: variable=function_name(arguments...);
  • In the below example i created cube function which returns a value and at the time of calling a function it calls parameterized function by passing a value.
  

  • Array in C language is a collection or group of elements (data). All the elements of c array are homogeneous (similar).
  • Syntax: data_type array_name[array_size]; ( int marks[5]; )

Types of Loops in
 C 
:
There are three types of loops in C language.
  • do while :
    • It iterates the code until condition is false. Here, condition is given after the code. So at least once, code is executed whether condition is true or false. It is better if we have to execute the code at least once.
    • Syntax: do{  //code to be executed  }while(condition);
  • while :
    • Like do while, it iterates the code until condition is false. Here, condition is given before the code. So code may be executed 0 or more times. It is better if number of iteration is not known by the user.
    • Syntax: while(condition){  //code to be executed  }
  • for :
    • Like while, it iterates the code until condition is false. Here, initialization, condition and increment/decrement is given before the code. So code may be executed 0 or more times. It is good if number of iteration is known by the user.
    • Syntax: for(initialization;condition;incr/decr){ //code to be executed  }

Strings in C :
  • String in C language is an array of characters that is terminated by \0 (null character).
  • There are two ways to declare string in c language.
    • By char array : Declaring string by char array in C language. char ch[6]={'n', 'i', 'k', 'h', 'i', 'l', '\0'}; (or) char ch[]={'n', 'i', 'k', 'h', 'i', 'l', '\0'};
    • By string literal : char ch[]="nikhil";
  • The only difference between char array and string literal is that string literal cannot be changed whereas string declared by char array can be changed.
                          

.Mathematical Functions :
  • C Programming allows us to perform mathematical operations through the functions defined in <math.h> header file. 
  • The <math.h> header file contains various methods for performing mathematical operations such as sqrt(), pow(), ceil(), floor() etc.
  • There are various methods in math.h header file. The commonly used functions of math.h header file are given below.
    • ceil(number) : Rounds up the given number. It returns the integer value which is greater than or equal to given number.
    • floor(number) : Rounds down the given number. It returns the integer value which is less than or equal to given number.
    • sqrt(number) : Returns the square root of given number.
    • pow(base, exponent) : Returns the power of given number.
    • abs(number) : Returns the absolute value of given number.
           
 
File Handling in C :
  • File handling in C language is used to open, read, write, search or close file. It is used for permanent storage.
  • There are many functions in C library to open, read, write, search and close file. A list of file functions are given below.
    • fopen() : opens new or existing file.
    • fprintf() : write data into file.
    • fscanf() : reads data from file.
    • fputc() : writes a character into file.
    • fgetc() : reads a character from file.
    • fclose() : closes the file.
    • fseek() : sets the file pointer to given position.
    • fputw() : writes an integer to file.
    • fgetw() : reads an integer from file.
    • ftell() : returns current position.
    • rewind() : sets the file pointer to the beginning of the file.