C



C:
C was developed by Dennis Ritchie used to re-implement Unix operating system. 
C is procedural programming language.

Procedural oriented language:
Here small parts are taken as functions.
 
Downloading and installing C:



Variable initiation:
Variables are used for storing values to locations in memory.

How to declare variable:
Data-type variable name;

Constant variable:
Whose value can't be changed during execution of program.
Syntax: const data_type variable_name;

Volatile variable:
It gives the compiler not to change the value from other parts of program unexpectedly.
Syntax: volatile data_type variable_name;

Data types:
Int: value can be both positive and negative but cannot be decimal.
2 bytes.
Syntax: data-type variable name;
Float: can hold real no's.
4 bytes.
Syntax: data-type variable name;
Char: declares the character type variable.
1 byte.
Ex: char t='a';
Double: 8 bytes.
Typedef: Allows the user to define identifier which would represent existing data type.
Better readability.
Syntax: typedef type variable-name;
Array: Collection of data of same type.
String: A array of character type.
Structure: Collection of related variables of same or different types.

Hello world program:

Loops:
Loop is  a statement that is used to execute multiple times.

For loop:
Used to execute a specific no of times.
Syntax: for(init;condition;inc/dec)
             { 
                  statements;
             }

While loop:
Executes a group of statements as long as given condition is true.
Syntax: While(condition){
                                          Statements;
                                          inc/dec;
                                       }

Do while loop:
Executes the block even if the condition fails.
Syntax: do{
                   Statement;
                    inc/dec;
                  }while(condition)


Function and calling function:
Function is a block of code that performs specific task.
Syntax: data-type function-name(){
                    Statements;
              }
If we want to call function.
function-name();

Advantage of function:
Large programs can be divided into function we can call them without re-writing the code.
By writing functions the program can be easier to understand.

Conditional Execution:
If:
Condition is true only we can execute them.
Syntax: if(condition){
                                  statement;
                                }
If-else:
Syntax: if(condition){
                                  Statement;
                                }
               else{
                          Statement;
                      }
Switch:
Allows the variable to be tested for equality among the list of values.
Syntax: Switch(expression)
{
   Case expression: Statement; break;
   Default: statement; break;
}  


Mathematical function:
Group of functions that implements the basic mathematical operation.
Abs: Gives the absolute value of integer.
Syntax: abs(int value);
Fabs: Gives the absolute value of floating point no.
Syntax: fabs(float value);
Sqrt: Computes the square root.
Syntax: sqrt(value);
Cbrt: Computes the cube root.
Syntax: cbrt(value);
Hypot: Computes the Square root of sum of two no's.
Syntax: hypot(value1,value2);
Fmax: Computes the larger of two floating values.
Syntax: fmax(float value1,float value2);
Fmin: Computes the smaller of two floating values.
Syntax: fmin(float value1,float value2);
Floor: Returns the nearest integer not greater than the given value.
Syntax: floor(value);
Ceil: Returns the nearest value not less than the given value.
Syntax: Ceil(value);
Round: Returns the nearest integer rounds the value.
Syntax: round(value);

Graphic functions:
Gd=DETECT means auto detect of resolution.
Gm graphic mode.
Path to driver.
Setbkcolor background color.

Line:

Circle:

Rectangle:



File:
A place where information can be stored.

Why files are needed?
Storing in a file will preserve your data even if the System shuts down.
Easy to access them.

File writing in C:

File reading:

String concatenation:

Substring:

Starting index of string:


Count the no of occurrences of sub-string in string:
  
Taking the input from user and printing:

Non repeating character in string:

Digit identification of a string:

Pyramid of numbers:

Highest repeated character:


Permutation of string:

Sum of a no in given string:

You Might Also Like