Skip to main content

Posts

Conditional statements in C Language

                                                       C Language Beginner level

Conditional Statements in C :

The concept of Conditional statement also can be reffered as Dacision Making . We can understand the Decision Making concept and working using the below situation  -

If The value of a variable x is greater than 5 , Program should print " Hello " and if the value of x is lower than 5 , program should print "World " . We use conditional statement as -

if(x >5)
{
printf(" Hello ") ;
}
else
{
printf(" World ") ;


There are various kind of Conditional statements , we can use in C -

If StatementIf-Else Statement Nested If Statement Switch If Statement :  Simply If a condition inside if statement is True , The If block executes otherwise ignore the If Block and compiler moves to the next lines of code . 
if( x < 10 ) { printf(" Hello World ") ; }

Note : 

If compiler gets the value of x greater than 10 in the programe code , It executes the I…
Recent posts

Strings Implementation in C Language

C Language Beginner level
Strings :

As we know , Any string is the collection of various characters or the collection of Characters , Numbers or Symbols . For example we can say " Author@89 " is a string and is the collection of the various characters , numbers , symbols  as A , u , t ,h ,o ,r ,@ ,8 ,9 .

So Come to the Strings use in the C Language -

To Store a String in variables in C language is not possible So we use the Array Concept to store the various characters . While performing any Action on a string like Copy to other string , Concatenation ( To add two strings ) , Splitting ( To break the string into parts ) etc , we need the Array to store a particular string in the C Language . When we are using Array to store a string , This string must be of similar or character data type , means each string can contain only characters .If an Array Box[20] stores the string " Author " , It is Right but The string " Author89 " is not valid . How to Initialize…

Loops in the C Language

C Language Beginner level
Loops in the C Language : 

The concept of Loops in the programming languages makes them awesome . A loop can iterate a statement as the number of times we want . Let's suppose I say someone to write a statement thousand times , he/she writes statements one by one thousand time , So it goes very lengthy and heavy process for a human being . But rather than human being A Computer program makes this heavy process very light because we only need to write a loop and the particular statement once and the compiler ( Compiler is a software that compiles C Code line by line to perform actions and showing the output . ) will write that statement thousand times .

There are various kind of loops , we use in C Language are as -

For LoopWhile LoopDo While Loop Nested Loop 
For Loop :
We mostly use for loop in the programming and can understand the syntax with below C code -

#include <stdio.h>
void main()
{
int i ;
for(i=0 ; i<101 ; i++)
{
printf(" Hello World \n &q…

Arrays in C Language

C Language Beginner level
Array is a set of similar Data Type values . We can also say an Array is like a box that holds only the values or things of same type . Array can also be reffered as the Linear Data Structure because of the linear fashion while storing data values and User defined Data Type also .


An Array always contains a contigous set of all values inside the memory .In array we use indexing starting from 0 . Thus if we have total n elements in the array , then we say the 1st element is 0th element and nth element is (n-1)th element .  We can understand the working of an array by the below diagram - 
 How to declare an array in C : 
If we want to declare an array " Box " with size of 10 elements of integer data type , we use the syntax as - 
int Box[10] ;
Note :

Here we dclared the Array and can put values inside in further code anywhere .Here Box is the Array name and 10 is the size of Array and int Data Type tells that all elements of the array are integers .Here 10…

Data Types in C Language

C Language Beginner level


Data Types in C Language : 

Data Type tells us the properties of a variable like how much Storage is allocated to a particlar variable and which kind of Data it stores .

There are various kind of Data Types available in C as -

Basic Data Types :

intfloatdoublechar 
Data Type Allocated Storage Range Note  int  2 bytes or 4 bytes  -32,768 to 32,767  float 4 bytes 1.2E-38 to 3.4E+38  It uses 6 Decimal Precision .  double 8 byte 2.3E-308 to 1.7E+308 It uses 15 Decimal Precision . char 1 byte -128 to 127 or 0 to 255 short 2 bytes  -32,768 to 32,767 long  4 bytes  -2,147,483,648 to 2,147,483,647 void  0 bytes  It does not contain any value and shows   Null value .
User Defined Data Types : ArrayStructureUnion Note : 

We can find out the Allocation Storage for any Data Type by using the sizeof( ) function in the C Code .  
How to use sizeof( ) function : 

#include <stdio.h>
void main() 
{
printf(" The Size of Integer Data Type is = %d " , sizeof( int )) ;
printf(…

Variables in C language

C Language Beginner level
Variable :

A Variable is the way to store the value while the life time of the code execution . As the name Variable indicates , definitely we can change the value of Variable when we need in the entire life cycle of a program .

We can also say a variable like a small box having a value inside it and can be changed later and can be assigned a new value .

Syntax to define a Variable in C : 

int x , y , z ;
char x , y , z ;
float x , y z ;
double x ,y , z ; 

Note :

Here we used the three variables in each statement x , y , z but we can choose more or less variables as the requirement while writing the code .Here we just defined the Variables .Here 1st statement shows that , we declared three variables x , y ,z of Integer Data Type  .Here 2nd statement shows that , we declared three variables x , y ,z of Character Data Type .Here 3rd statement shows that , we declared three variables x , y ,z of Float Data Type .Here 4th  statement shows that , we declared three variab…

C language Part 1 - Beginner Level Course , Hello World Program

C Language Beginner level

Hello World Program :

The basic syntax to write any program in the C , you have to write a main() function because when you execute this program , main() function gets loaded automatically and executes the code inside it .

Syntax to Print Hello World :

#include<stdio.h> 
void main() 
{
printf(" Hello World ") ;
return 0 ;
}

Note :

It is must to use # , before the line that we want to execute at first and # is called Preprocessor here .It is must to include some header file in the c code as need , here we included " stdio.h " header file . To execute any code in C , It is must to write inside main() function .Here we use the Curly Brackets ( { } ) to tell the compiler that , we wrote some lines inside a code block . Every block of code that contain multiple number of lines , we use { } .Here printf is a keyword , used to print anything using the C language and we use Double quotes ( " " ) to write a set of characters or a string .