Android Input Form Example

Android Input Form Example


Today We Start Android Basic Input Types Like : -

1.Edittext  (Input Box Taking Value From User).
2.spinner (Spinner is a dropdown For Taking Value From User)
3.Radio ( Radio a option button for selecting one value from multiple values)
4.Button ( Button For Submitting our Data).


Now Let's Start.


First Create A New Android Project :  



Android Project

Now Open activity_main.xml file and Delete Everything Old Code We creating from Scratch.

android signup layout



 Now Make One LinearLayout with Orientation Vertical .

 Code : 

<LinearLayout android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android" >
</LinearLayout> 

Like this : 
  

Here i LinearLinear Layout Which is Perfect for beginning.  I add Orientation vertical so that my all child item inside linear layout comes one after another.

Let's Add Some Input Elements Like Edittext,Button,Radio,Spinner .
<LinearLayout android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android" >
    <EditText
        android:layout_margin="10dp"
        android:hint="Username"
        android:id="@+id/username"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <EditText
        android:id="@+id/password"
        android:hint="Password"
        android:layout_margin="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <RadioGroup
        android:id="@+id/gender"
        android:layout_margin="10dp"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <RadioButton
            android:id="@+id/male"
            android:layout_weight="1"
            android:text="Male"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
        <RadioButton
            android:id="@+id/female"
            android:layout_weight="1"
            android:text="Female"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </RadioGroup>
    <TextView
        android:text="Age"
        android:layout_margin="10dp"
        android:textAlignment="center"
        android:textSize="20dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <Spinner
        android:id="@+id/age"
        android:layout_margin="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    <Button
        android:id="@+id/submit"
        android:text="Submit"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

Our Final Design Look Like This : 

Now Let's Code in JAVA for Taking Values from this Input When Click on Submit .

MainActivity.java


package androidbasic.supercoders.in.androidbasic;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //-----Declaring Input Element and Finding in Our Layout View----
        final EditText edit_username=(EditText)findViewById(R.id.username);
        final EditText edit_password=(EditText)findViewById(R.id.password);
        final RadioGroup Gender=(RadioGroup) findViewById(R.id.gender);
        final RadioButton Male=(RadioButton) findViewById(R.id.male);
        final RadioButton FeMale=(RadioButton) findViewById(R.id.female);
        final Spinner Ages=(Spinner)findViewById(R.id.age);
        Button Submit=(Button)findViewById(R.id.submit);

        //==========Now Setting Value in Our DropDown Spinner==============
        //======For This We Have To Create A ArrayAdapter with Type String=====
        //===ArrayAdapter is Java Class And its Constructor Takes 3 Param
        //1. Current Class Context,2. Our Textview Layout ,3. Our List of Items in string.


        //====First Create a List of Item for age  ==

        List<String > list=new ArrayList<>();
        for(int i=10;i<50;i++){
            list.add(String.valueOf(i));
        }

        ArrayAdapter<String> arrayAdapter=new ArrayAdapter<>(MainActivity.this,android.R.layout.simple_dropdown_item_1line,list);

        //====Now Set the Adapter To Spinner by Using SetAdapter Method

        Ages.setAdapter(arrayAdapter);

        //====Set On Click Listener For Button ===

        Submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                //===Now Doing Some Validation====

                //====We Can Get Value of Edit Text By using method gettext==

                if(edit_username.getText().toString().isEmpty()){
                    edit_username.setError("Please Enter Username");
                }
                else if(edit_password.getText().toString().isEmpty()){
                    edit_password.setError("Please Enter Username");
                }
                else if(!Male.isChecked() && !FeMale.isChecked()){

                    //===Toast I Used Here For Small Message Display==
                    Toast.makeText(MainActivity.this, "Please Select Gender", Toast.LENGTH_SHORT).show();
                 }
                 else{
                    Toast.makeText(MainActivity.this, edit_username.getText().toString(), Toast.LENGTH_SHORT).show();
                    Toast.makeText(MainActivity.this, edit_password.getText().toString(), Toast.LENGTH_SHORT).show();
                    Toast.makeText(MainActivity.this, Ages.getSelectedItem().toString(), Toast.LENGTH_SHORT).show();

                    RadioButton selectedGender=(RadioButton)findViewById(Gender.getCheckedRadioButtonId());
                    Toast.makeText(MainActivity.this,selectedGender.getText().toString() , Toast.LENGTH_SHORT).show();
                }
            }
        });


    }
}

Here is Our Final Result 

final result


Android Development Basic

Android Development Basic

Android Project Structure


Android Project Structure -

Before we Start to make our first Android app, we first see the basic parts of an Android application project, in order to recognize them and be able to understand them better.


AndroidManifest.xml

Androidmanifest.xml

 

AndroidManifest is A xml file Which information of our app. it contains : -

1. App Permission.
2. Our Running Activites which we have to Register in AndroidManifest.xml
3. Our Broadcaster
4. Our Receiver
5. Our Services.
 

Activities

android activity

 

The Activities are the main Java classes with a layout design file  , that contain the Android code with which we are going to develop, what do we want the application to do.

Res Directory

android res

 


Res Directory also called Resource directory where all our resource file be stored like design,layout,images,menu etc.

  

Layouts 

android layout

 

The Layouts are the xml files, that contain the Android xml code with which we are going to develop, how will our application UI look like.

Values

android values

 

The Values are Also XML file Which Contain The Values of Strings,Style, Colors in To Use them in Your App.

Following are Thing Comes in Values : -

– Animation Resources
– Color State List Resource

android color




– Drawable Resources

android drawable


– Layout Resource

android layout




– Menu Resource

android menu






– String Resources

android string



– Style Resource 

android style



Drawables 

 A drawable resource is a directory in res which contain our images,layout drawable,shapes , vector graphics.
Following are The Things Comes is Drawable : -

Bitmap File
-  A bitmap graphic file (.png, .jpg, or .gif). Creates a Bitmap Drawable.
Nine-Patch File
-  A PNG file with stretchable regions to allow image resizing based on content (.9.png). Creates a Nine Patch Drawable.
Layer List
-  A Drawable that manages an array of other Drawables. These are drawn in array order, so the element with the largest index is be drawn on top. Creates a LayerDrawable.
State List
-  An XML file that references different bitmap graphics for different states (for example, to use a different image when a button is pressed). Creates a StateListDrawable.
Level List
-  An XML file that defines a drawable that manages a number of alternate Drawables, each assigned a maximum numerical value. Creates a Level List Drawable.
Transition Drawable
-  An XML file that defines a drawable that can cross-fade between two drawable resources. Creates a Transition Drawable.
Inset Drawable
- An XML file that defines a drawable that insets another drawable by a specified distance. This is useful when a View needs a background drawble that is smaller than the View’s actual bounds.
Clip Drawable
- An XML file that defines a drawable that clips another Drawable based on this Drawable’s current level value. Creates a Clip Drawable.
Scale Drawable
-  An XML file that defines a drawable that changes the size of another Drawable based on its current level value. Creates a Scale Drawable
Shape Drawable
- An XML file that defines a geometric shape, including colors and gradients. Creates a Shape Drawable.


build.gradle

build.gradle is a file which contain information of our project library,modules,
application id,version name,version code etc.


build.gradle

 

Android Hello World Example

Start Android Studio and Create a new Project.

android hello world

 Select Minimum Api Level  (Api Level Means Which Lowest Android Which You Want to Run That App).

android  api

Android Activity (Selecting Here Simple Empty Activity)

android empty activity

Android Launcher Activity Name 

mainactivity

Android Project is Ready Now Click on Green Play Button To Run Your Android Project.

Make Sure You Created Your Emulator. 
Or Connected Your Device With USB Debugging is Permission is  (For Enable USB Debugging .
Just Go To Phone-> Setting -> About -> Click on Build Number 7 times .
 then back then you see a developer option just enable the usb debugging)

android project ready

Android Hello World Example. 

android devices
 

android hello world

Install Android Studio

Today For Some User It's Difficult To Setup Android Studio.

In This I Will Show How To Install Android Studio.

 
On Windows 
and On Ubuntu.

Let's Start
For Ubuntu : -
Install JDK 6 or Later. (Better To Use Latest Version)

command : -

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default

Now Let's Download Android SDK from Here For Ubuntu.

https://developer.android.com/sdk/index.html

After Installing Java and Downloading Android Studio.

Now Extract The file to home directory.

For This.

Use : tar zxvf android.tar.gz /home/Your_user_directory/


Let set The Path For android Studio and Java.

Now Open Your Bashrc file by Running This Code (Not in Root User).

sudo gedit ~/.bashrc

Paste This Line To Bottom of The File.

//please check your sdk location in file manager first

export ANDROID_HOME=/home/Your_Username/Android/Sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export JAVA_HOME=/usr/lib/jvm/java-8-oracle

now save and close this file.

after that reload the file for system.
so run this command.

source ~/.bashrc

Now Open Your android studio.

By Running the command.

android-studio/bin/studio.sh.

Then Follow This Screens.

android studio setup
 

android studio setup

android studio setup



android studio setup

please check you android-studio location first in my case it in home user directory.

now this was fresh install so you have to select do not import setting.
after that update some libraries.

Now its Ready To Use.

For Windows :

Installing android on Windows Does not required lots of thing.
Just download
jdk: -

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

and
android studio 

Then simply Run the executable file
.
https://developer.android.com/sdk/index.html

All will Done by window automatic.

Extract ZIP File Using PHP Code

Extract ZIP File Using PHP Code

 

Zip Archieve is Very Usefull for Lots of file Single Archieve File.

But Let's Today We Extract That Zip in Our Server Using PHP Codes.


Let's Start.

In This Example I Upload A Zip File from HTML form And Extract Using PHP.

Our Form Code : (upload.html) 




<html>
    <head>
        <title>Extract Zip File.</title>
    </head>
    <body>
        <!---As You Enctype Is Necessary When We Uploading Files--->
        <form action="upload.php" method="post" enctype="multipart/form-data">
            <p>Please Select Your Zip file.</p>
            <input type="file" name="zip">
            <button type="submit">Upload</button>
            
        </form>
    </body>
</html>

(upload.php) codes 

<?php

//------Function For Extracting Zip File-------------
function extracted($file){
    
    //-----PHP ZIP Archive Object------
    $zipArchive    = new ZipArchive();
    $arch_filename = $file;
    
    //-----Opening Zip File-------------
    $result        = $zipArchive->open($file);
    
    //------If Open Successfully Then Extract it-------
    
    if ($result === TRUE) {
        
        //-----Directory Where Extracting File-------
         $zipArchive ->extractTo("extracted");
         return true;
    }
    else{
        return false;
    }
   
}
//---------End Extract Function--------------


//------Function For Extracting Zip Specific File Type-------------
function extracted_spec($file,$type){
    
    //-----PHP ZIP Archive Object------
    $zipArchive    = new ZipArchive();
    $arch_filename = $file;
    $dest_dir="extracted";
    //-----Opening Zip File-------------
    $result        = $zipArchive->open($file);
    
    //------If Open Successfully Then Extract it-------
    
    if ($result === TRUE) {
        
        //======================Finding File Type===============================================
        for ($i = 0; $i < $zipArchive->numFiles; ++$i) {
            $path = $zipArchive->getNameIndex($i);
            $ext  = pathinfo($path, PATHINFO_EXTENSION);
            if (!preg_match('/(?:'.$type.')/i', $ext))
                continue;
            $dest_basename = pathinfo($path, PATHINFO_BASENAME);
            copy("zip://{$arch_filename}#{$path}", "$dest_dir/{$dest_basename}");
        }
        
        
        //======================Extracting Specific File Type==================================
        $i = 0;
        for ($i = 0; $i < $zipArchive->numFiles; $i++) {
            $stat = $zipArchive->statIndex($i);
            $e    = pathinfo(basename($stat['name']), PATHINFO_EXTENSION);
            if ($e == $type) {
                $i = 1;
                return true;
            } 
        }
        if($i==0){
                return false;
        }
    }
    else{
        return false;
    }
   
}
//---------End Extract Function--------------

//---Set Directory For Zip Files---
$dir = "zips/";

//----Creating Unique File Name---------
$file = $dir.time().basename($_FILES["zip"]["name"]);

//---validation checking form submit or not----
if(isset($_POST["submit"])) {

    //----Move Uploaded File is a PHP Function for Moving Temp Location File To Specific Directory------
    if (move_uploaded_file($_FILES["zip"]["tmp_name"], $file)) {

        echo "File ". basename( $_FILES["zip"]["name"]). " has been uploaded.";
        //-----After Uploading Passing The File Path To Another Which Only Extract Our File.---
        
        if(extracted($file)){
            echo "File Successfully Extracted";
        }
        else{
            echo "Invalid Zip File Or Failed To Extract File";
        }

    } else {
        echo "Error During Uploading File";
    }
}
else{
    echo "No Data";
}

In Above Example I create Two Functions


1.For Extract All Contents inside File.

extracted("path/to/file"); 

2.For Specific File Type.

extracted_spec("path/to/file","file type e.g pdf");

Free Trusted SSL Certificate

Free Trusted SSL Certificate

Hello Again Let's Today We See How TO Get Free SSL for Our Website.

Let's Start.

Open https://www.cloudflare.com/

cloudflare


Then Signup Your Account.

  
add site


Then Select Free Plan.


Click Confirm Plan.




After that see everthing where we pointed our domain 

Currently my domain using my hostgator nameserver.

Now Cloud Works as A proxy between your domain and your server


E.g YOUR Domain===>CloudFlare==>Your Server

 
Then Continue.


Now Copy

Both Nameserver Details.

alice.ns.cloudflare.com
wesley.ns.cloudflare.com
Then open your domain panel.





Now Currently its pointing to hostgator name server let's change it.

Now its done.

After That Open Cloudflare.


Now here you see its taking so time.

so you have to wait.

for fully active.
after that do some changes

click on pages rules.

Create page rules.

 

 


1. *.youdomain.com

add a setting.
always use https.


2. rule : http://yourdomain.com/*

3. add rule redirect.

https://www.youdomain.com/

then save and deploy

In crypto 

Always use https

now everthing lets wait.

in free version it takes 24hrs max..

so wait.




Thanks.
Video Tutorial

CSS Basics Tutorial

CSS Basics Tutorial

HTML CSS Tutorial

Topics

  • Introduction
  • Syntax
  • Selector
  • Using CSS in HTML Pages
  • CSS Rules
  • CSS Fonts
  • CSS Text Formating
  • CSS Box Model
  • CSS Backgrounds

CSS Introduction 


Cascading Style Sheets (CSS)
Applies to HTML Pages For Designing the Layout and View Appearance of Your Website.


A styled HTML document produced by the CSS  

<!DOCTYPE html>
<html>
<head>
 <title>CSS Style</title>
 <style type="text/css">
  body {
   background: yellow;
  }
  p {
   color: red;
   font-size: 20px;
  }
 </style>
</head>
<body>
 <p>Hello World</p>

</body>
</html>

css background

CSS Usage : 

css html

 

CSS Syntax

css selector { property-name:values } 

Css Selector - HTML Dom Elements Selecting By Elements Tag,Class name or By id.

Property-name : like - background , font-size , color , text-alignment etc.
Property -values: like - orange , 17px, center, etc. 

css syntax

CSS Elements Selecting Syntax

  • Single Element Type
Syntax : - Single Element Type - p { color:red; } 
HTML Element : -  <p>Hello World! I Select All p Tag Elements</p> 
  • Multi Element Type 
Syntax : - h1,h2,h3 { background : orange } 
HTML Element : <h1>Hello H1<h1><h2>Hello H2<h2><h3>Hello H3<h3>
  • All Element Type 
Syntax : - * { padding:5px; }
HTML Element : <p>selected me</p> <h2>Selected me</p>  

  • Element By id  ( # )
Syntax :  - #p1 , #p2 { marging:5px  }
HTML Element : - <p id=”p1”>paragraph1</p><p id=”p2”>paragraph2</p>

  • Element By Class ( . )
Syntax : - .p1,.h1 { color :seagreen; }
HTML Element : - <p class=”p1>Class p1</p><h1 class=”h1”>Heading 1</h1>

  • Element with class 
Syntax : -  p.p1 { font-style:italic; }
HTML Element : - <p class=”p1>Only Select me</p><p class=”p2”>Not Select me</p>
  •  Descendents Selector (E.g : - Only Select li element which parent is ul )
Syntax : - ul li { color : green; } 
HTML Element : - <ul><li>select me</li><li>select me</li></ul> 

Using CSS in HTML Pages

We Can Use CSS in HTML Pages in 3 ways: -  

Inline css - 

E.g :

<p style=”color:red”>I am a inline CSS Style Paragaraph Tag</p>


Internal CSS - 
E.g : 



<html>
<head>
<style>  p { color:red; } </style>
<!----Internal CSS--->
</head>
<body>
<p> My Color Changed By Internal CSS</p>
</body>
</html>


External CSS - 
E.g : 

<html>
<head>
<link rel=”stylesheet” href=”style.css”>
<!---Linking External CSS Using Href-->
</head>
<body>
<p>My Style Changed By External CSS style.css</p>
</body>
</html>

style.css
 
p{color:red;}
h1{color:blue;}

As a Developer i Not Prefered To Using Inline CSS use minimum inline CSS Try to Use CSS Externally or Internally Because managing all element style easy.

You think what you like to edit?
100 time paragraph tag style?
Or
Just 1 change in External CSS 

 CSS Rules

Now What happened If Multiple Style Comes To Same Elements ?

E.g : - in Internal i add 

p{ color :red; }


And in External I add
p{ color:black;}

Then Here is a Some Rules Which we See How It Works And Whom It Select.


Important ( <p style=’color:red!important’>Important</p>)

This always Comes First when we Selecting Element whether any internal external or inline css added important works first.

Inline css (we already see inline css above)

This comes in Second Position.

Now Inline and External Had Some Different Case.

Rule with selector :
1. ID
2. class
3. descendant/element type
4. universal
5. HTML attribute



This Rules Followed By Internal and External but Internal Always Comes First Then External.

CSS Fonts


  • CSS font is  Very important part of CSS for Customizing Fonts in Our Webpage. We Can Customize this fonts using Css.
  • Change Font Weight
  • Change Color
  • Change line height (line gap between paragraph)
  • Change Font Size
  • Change Font Style

 Example : - 

 
<!DOCTYPE html>
<html>
<head>
 <title>CSS Style</title>
 <style type="text/css">
  #p1 {           color: red;font-size: 20px; }
  #p2{   font-family: sans-serif;  line-height: 40px;  }
  #p3{   font-style: italic;font-weight: 600;  }
 </style>
</head>
<body>
 <p id="p1">I am p1 text  with css font property color red and font size 20px </p>
<p id="p2">I am p2 text with css font property font family sans-serif and line height 20px</p>
 <p id="p3">I am p3 with css property font style italic and font weight 600</p>
</body>
</html> 
 
css fonts 
CSS Box Model 

All elements in HTML can be considered as boxes. In CSS, the term "box model" is used when talking about design and layout.

Css BOX Model is Wraps HTML elements.It consists of: margins, borders, padding, and the  content.  

Css BOX Model

CSS Box Model Example

 
<!DOCTYPE html>
<html>
<head>
<title>Box Model</title>
<style type="text/css">
body{
padding: 10px;
background: red;
}
#box{
margin: 20px;
padding: 20px;
border:10px solid yellow;
}
</style>
</head>
<body>
<div id="box">
<p>I m inside a box Model</p>
</div>
</body>
</html>

Results :  


CSS Box Model


CSS Box Model

Thanks. 

Video Demo.

Tic Tac Toe in C Programming

Tic Tac Toe in C Programming

c program tic tac toe

In Student Life or as a Programing Beginning or in Interview. This is Most Fav Question and Beginning of Any Programing. The Common Question is Write a Program in C for Tic Tac Toe Game.

So Let's Start .

 In My Program I Break My All Instruction in Functions So its Easy To Understand Specificic Functions.

Tic Tac Toe Program Functions : -

1. ShowTicTacToeBoard() = Display Our Game Board With Data.
2. showGameInstruction() = Display Game Instructions.
3. IntitialIzeGame() = Initialize Our Game Board.
4. declareWinner() = Show The User Who Win. 
5. rowCrossed() = Check Row Matched.

 (E.g 1=1=1 in row)

6.columnCrossed() = Check Column Crossed

 (E.g = 1
            1
            1)

7. diagonalCrossed() = Check Diagonal Crossed 

 (E.g = 1
                1
                    1 )


8. gameOver() = Check Game is Over or Not.
9. StartGame() = Start Our Game .


Our Final Program: -



//************C Header File**********************//
#include <stdio.h>
#include <stdbool.h>
#include <bits/stdc++.h>
//****Length Of Our Board i.e 3*3 so Side is 3****//
#define SIDE 3
#define CPU 1
#define PLAYER 2
#define CPUMOVE 'O'
#define PLAYERMOVE 'X'
//******Our Tic Tac Toe Board With Data*********//
void ShowTicTacToeBoard(char board[][SIDE]){
 printf("\n\n");
     
    printf("\t\t  %c | %c  | %c  \n", board[0][0],
                             board[0][1], board[0][2]);
    printf("\t\t--------------\n");
    printf("\t\t  %c | %c  | %c  \n", board[1][0],
                             board[1][1], board[1][2]);
    printf("\t\t--------------\n");
    printf("\t\t  %c | %c  | %c  \n\n", board[2][0],
                             board[2][1], board[2][2]);
  
    return;
}

//****Our First Time Instruction Board********//
void showGameInstruction(){
	printf("||============Tic Tac Toe Game==========||\n");
	printf("---Choose A Cell For Your Chance-------\n");
	printf("\n\n");
	printf("\t\t 1 | 2 | 3 \t\t\t\n");
	printf("\t\t 4 | 5 | 6 \t\t\t\n");
	printf("\t\t 7 | 8 | 9 \t\t\t\n");
	printf("\n\n");
}

void IntitialIzeGame(char board[][SIDE], int moves[])
{
	//************Intialize Random No. With Current Time From Millisec************//

    srand(time(NULL)); 
    
    //************Intial Our Tic Tae Board is Empty***************//

    //***********For Each Row Loop*************//
    for (int i=0; i<SIDE; i++)
    {
    	//*********For Each Row Column Loop (Means Cell)*****//
        for (int j=0; j<SIDE; j++)
        {
            //=====Intial There is No Any Run So it is Blank===//
            board[i][j] = ' ';

        }

    }
     
    //====With Our Chance=============
    for (int i=0; i<SIDE*SIDE; i++)
        moves[i] = i;
 
    //****Randomize The Data************//
    std::random_shuffle(moves, moves + SIDE*SIDE);
    return;
}


void declareWinner(int whoseTurn)
{
    if (whoseTurn == CPU)
        printf("COMPUTER has won\n");
    else
        printf("HUMAN has won\n");
    return;
}

bool rowCrossed(char board[][SIDE])
{
	//*********Checking Our Board Data That MAtch any Row in 3 units*****
    for (int i=0; i<SIDE; i++)
    {
        if (board[i][0] == board[i][1] &&
            board[i][1] == board[i][2] && 
            board[i][0] != ' ')

            //=======if match return true=========
            return (true);
    }

    //=============else false=========
    return(false);
}

bool columnCrossed(char board[][SIDE])
{
		//*********Checking Our Board Data That MAtch any Columns in 3 units*****
    for (int i=0; i<SIDE; i++)
    {
    	//===same as above but this time m running loop after static values===
        if (board[0][i] == board[1][i] &&
            board[1][i] == board[2][i] && 
            board[0][i] != ' ')
            return (true);
    }
    return(false);
}

bool diagonalCrossed(char board[][SIDE])
{
			//*********Checking Our Board Data That MAtch any Diagonal from right in 3 units*****
    if (board[0][0] == board[1][1] &&
        board[1][1] == board[2][2] && 
        board[0][0] != ' ')
        return(true);
         
         	//*********Checking Our Board Data That MAtch any Diagonal from Left in 3 units*****

    if (board[0][2] == board[1][1] &&
        board[1][1] == board[2][0] &&
         board[0][2] != ' ')
        return(true);
 
    return(false);
}

bool gameOver(char board[][SIDE])
{
	//==========Return if Diagonal or Column or row any match result==========
    return(rowCrossed(board) || columnCrossed(board)
            || diagonalCrossed(board) );
}

void StartGame(int whoseTurn)
{
    //=======initialize board with 3*3============ 
    char board[SIDE][SIDE];
     
     //======Intialize Moves Lenght 3*3=9 Total 9 Turn will available==== 
    int moves[SIDE*SIDE];
     
    //========Start Game============
    IntitialIzeGame(board, moves);
     
    //====== Display Instruction Before Start our Game================
    showGameInstruction();
     
    int moveIndex = 0, x, y;
     
    //=======Keep RUnning Our Till Our Game Not End===================
    while (gameOver(board) == false &&  moveIndex != SIDE*SIDE)
    {
        if (whoseTurn == CPU)
        {
            x = moves[moveIndex] / SIDE;
            y = moves[moveIndex] % SIDE;
            board[x][y] = CPUMOVE;
            printf("COMPUTER has put a %c in cell %d\n",
                    CPUMOVE, moves[moveIndex]+1);
            ShowTicTacToeBoard(board);
            moveIndex ++;
            whoseTurn = PLAYER;
        }
         
        else if (whoseTurn == PLAYER)
        {
            x = moves[moveIndex] / SIDE;
            y = moves[moveIndex] % SIDE;
            board[x][y] = PLAYERMOVE;
            printf ("HUMAN has put a %c in cell %d\n",
                    PLAYERMOVE, moves[moveIndex]+1);
            ShowTicTacToeBoard(board);
            moveIndex ++;
            whoseTurn = CPU;
        }
    }
 
    // If the game has drawn
    if (gameOver(board) == false && 
            moveIndex == SIDE * SIDE)
        printf("It's a draw\n");
    else
    {
        // Toggling the user to declare the actual
        // winner
        if (whoseTurn == CPU)
            whoseTurn = PLAYER;
        else if (whoseTurn == PLAYER)
            whoseTurn = CPU;
         
        // Declare the winner
        declareWinner(whoseTurn);
    }
    return;
}
int main(){
	StartGame(CPU);
}

Our Final Result: 

1. g++ tic_tac_toe.c
2. ./a.out

||============Tic Tac Toe Game==========||
---Choose A Cell For Your Chance-------


         1 | 2 | 3           
         4 | 5 | 6           
         7 | 8 | 9           


COMPUTER has put a O in cell 2


            | O  |  
        --------------
            |    |  
        --------------
            |    |  

HUMAN has put a X in cell 3


            | O  | X
        --------------
            |    |  
        --------------
            |    |  

COMPUTER has put a O in cell 1


          O | O  | X
        --------------
            |    |  
        --------------
            |    |  

HUMAN has put a X in cell 9


          O | O  | X
        --------------
            |    |  
        --------------
            |    | X

COMPUTER has put a O in cell 5


          O | O  | X
        --------------
            | O  |  
        --------------
            |    | X

HUMAN has put a X in cell 7


          O | O  | X
        --------------
            | O  |  
        --------------
          X |    | X

COMPUTER has put a O in cell 4


          O | O  | X
        --------------
          O | O  |  
        --------------
          X |    | X

HUMAN has put a X in cell 8


          O | O  | X
        --------------
          O | O  |  
        --------------
          X | X  | X

HUMAN has won
 
0