Saturday, December 29, 2012

Create your own youtube + slideshare presentation with popcorn.js.


I created a demo of youtube + slideshare presentation quite a long ago. Many asked me to explain how to do it. Specially this guy Michael Britt So here it is.

First of all some basics about popcorn.js. As given on their website - 
Popcorn.js is an HTML5 media framework written in JavaScript for filmmakers, web developers, and anyone who wants to create time-based interactive media on the web. Popcorn.js is part of Mozilla's Popcorn project.
Now the presentation.

What to do?

We are gonna synchronize the youtube video hosted on youtube.com with slideshare presentation hosted on slideshare.net. We'll specify for what duration which slide to be opened?

How?

Youtube and slideshare give the facility to embed  the videos and presentations hosted on their sites respectively on our webpage. Popcorn.js has youtube player which enables synchronizing youtube video to run the jobs specified in plugins. Slideshare player API let us jump to any slide we want using jumpTo function in API. (Slideshare player API)

popcorn.js has many plugins for some of the popular websites like facebook, twitter, flicker, etc. The one we are using is a "code" plugin. This plugin let us run the javascript code on the same page when the specified video duration is reached.

So lets start..

First we have to add the youtube video and slideshare presentation. Remember we are not gonna use youtube embed player instead we will be using popcorn.js youtube player to embed the video so that we can   monitor the video duration.

add script to the head section of code.



JavaScript

  
  <script type="text/javascript" src="http://popcornjs.org/code/dist/popcorn-complete.min.js"> </script>



 Now following code will embed the youtube player with given link to the page


JavaScript

  
  <script type="text/javascript"> 

    // ensure the web page (DOM) has loaded 
    document.addEventListener("DOMContentLoaded", function () { 
        var vstart=1; 

        // Create a popcorn instance by calling the Youtube player plugin 
        var example = Popcorn.youtube( 
        '#video', 
        'http://www.youtube.com/watch?v=Zm1c2WTD93w&rel=0' ); 
        example.play();
    });

  </script>


Code Description


1st line with a eventlistner ensures that the video has been loaded. After that the function starts. Here we are creating a popcorn instance by calling youtube player plugin. The plugin has 2 necessary attributes - id and link. id attribute specifies the id of the page element where the player will be embedded. In our case we have a div tag with id - video. Hence first attribute #video and second attribute is a link to the youtube video that has to be embed. 
To start the video we must use the event "play" instance_name.play(). In our case example.play().

Now let us add slideshare presentation with slideshare player api.


JavaScript

  
<script type="text/javascript">

  var flashMovie;

  //Load the flash player. Properties for the player can be changed here.
  function loadPlayer() {

      //allowScriptAccess from other domains
      var params = { allowScriptAccess: "always" };
      var atts = { id: "player" };

      //doc: The path of the file to be used
      //startSlide: The number of the slide to start from
      /*rel: Whether to show a screen with related slideshows 
        at the end or not. 0 means false and 1 is true.. */
     
      var flashvars = { doc : "linux-100419010247-phpapp01", startSlide : 1, rel : 0 };
                      
      //Generate the embed SWF file
      swfobject.embedSWF("http://static.slidesharecdn.com/swf/ssplayer2.swf", "player", "598", "480", "8", null, flashvars, params, atts);

      //Get a reference to the player
      flashMovie = document.getElementById("player");
  }

  //Jump to the appropriate slide
  function jumpTo() {

      flashMovie.jumpTo(parseInt(document.getElementById("slidenumber").value));
  }

  //Update the slide number in the field for the same
  function updateSlideNumber()  {
      document.getElementById("slidenumber").value = flashMovie.getCurrentSlide();
  }           
  </script>

Code description



This code will embed the slideshare player with specified ppt in the code by the attribute flashvars.
 Most of the attributes and functions in the code are self explanatory. The one which is hard to extract from a slides is a "doc" attribute of flashvar variable in code. It is the path of the file to be used but this path is not a link to that presentation. It can be extracted by a simple json request as follows.

http://www.slideshare.net/api/oembed/2?url=http://www.slideshare.net/haraldf/business-quotes-for-2011&format=json 

This link will give a json formatted response in which a attribute named "slide_image_baseurl" gives a value like this.

//image.slidesharecdn.com/110103quotes2010-12-110103073149-phpapp01/95/slide-

When you trim down "//image.slidesharecdn.com/" this part and "/95/slide-" this part you will get the value for doc variable.The function jumpTo()is the function which will when called with a slidenumber shows the specified slide. So in our code plugin we will be calling this function to change the slide. The updateSlideNumber() will update the changed slide number.

Now the code plugin.

According to its description on popcornjs.org

Allows for the ability to run arbitrary code ( JavaScript functions ) according to video timing.
so we will be using this plugin to call our slideshare player functions.
The plugin has following attributes that we will be using in our code. You can read about other options on http://popcornjs.org/popcorn-docs/plugins/ .

Start : Start of plugin working.
End : End of plugin working.
OnStart : The function to call on starting of the code plugin.
OnEnd : The function to call on end of the code plugin.

Here When I was making this demo I wanted to change my slides on 2nd and 5th sec of the video to the 2nd and 3rd slide so what I did is simply add this code to the function we called on the "DOMContentLoaded" event. 

JavaScript

example.code({ 
  start: 2, 
  end: 5, 
  onStart: function() { 
    flashMovie.jumpTo("2"); 
  }, 
  onEnd: function() { 
    flashMovie.jumpTo("3"); 
  } 
});

  
For other slides I simple added more "code" plugin options. Thats it. Some space for both players on the page using simple table and my video + slides presentation is ready. You can have a look on the demo here. If any questions feel free to ask.

Tuesday, July 31, 2012

Little bit popcorn.

No its not a meaningless non-technical post. Of course I am talking about popcorn which is the name of one of  mozilla's great projects. Popcorn.js is an HTML5 media framework written in JavaScript for filmmakers, web developers, and anyone who wants to create time-based interactive media on the web. Yes you read it right. 




Popcorn.js lets you synchronize your webpage elements with the embedded video tags and some of the plugins like youtube-plugin or vimeo-plugin lets you synchronize videos hosted on their sites to your webpage elements. 


I am not gonna tell more about its implementation part here. You can see documentation and tutorials for popcorn.js on popcornjs.org. I am just want to tell how popcorn.js can be used in a simple application where you can synchronize your power-point presentation with a related youtube video. 





I have created a simple demo application resting here. The video is resting on youtube and presentation slides are uploaded on slideshare The link is provided with facebook comment plugin. Feel free to ask if you have any questions. 

Wednesday, September 14, 2011

Web Development with CMS

Data is the most important factor of Internet age. Converting data into information is most necessary task for every programmer. And to use the information most efficiently for the project is the hardest job for the Developer. Those who had used their information most cleverly are now at highest positions like Google in Search Engines and Facebook in social networking. Thus Content Managing Strategy is the base of business in today's age. That gave birth to the new type of softwares - CMS.
CMS means Content Management Systems. As mentioned in Wikipedia page of CMS "A content management system (CMS) is a system providing a collection of procedures used to manage work flow in a collaborative environment."


 

The main motives behind CMS are
  • To Organize data in efficient manner.
  • Let many developers use data with lesser dependency conflicts.
  • Protecting data and access to data on the basis of developer role.
  • Better communication between developers over the platform.
  • Reduce the data redundancy and duplication.
All these issues are very obvious in website developing especially when developer let users store and manage data online like Social Networking Websites. In those cases CMS is the best solution to manage, store and deliver data with security. Joomla! is the new favorite amongst the programmers. The main focus of this post is on the Joomla!.

Joomla! logo

Joomla! is award winning CMS. Joomla! is the open source community project which let site developers build the websites with lesser coding and higher security. It not just provide the environment for development but also gives great connectivity to the databases and server with security also the access to the components of website are efficiently given to the users of CMS. 
Joomla! not only helps in site development but also highly useful in web application development. As the main concern is about information, Joomla! is highly useful in applications and projects in which 'Information or Content Management plays crucial role like 
  • Corporate Web sites or portals.
  • Online magazines, newspapers, and publications.
  • E-commerce and online reservations.
  • Community-based portals.
  • School and College Web sites.
  • Small business websites.
  • Static Websites.
Joomla! is not only for middle developers. As Joomla! is Open Source and a community project anyone can help Joomla! to make it more and more useful. Developers can also contribute by creating add-ons for Joomla!. Joomla is written in PHP - the most used server side scripting language and based on MySQL. 

Some of great websites developed with Joomla!(given on Joomla! official website)
You can also see some great websites build with Joomla! on Joomla Community Site Showcase 

One of my favorites is http://offclassroom.com/. This site is a great project of students group from ADIT college of Gujrat, India.

Joomla! is really great software to work on. Get your Joomla! now, its free and always will be free and start developing and contributing to the WEB 2.0

Technorati claim token : 5Y6CQQF4D3V3

Tuesday, July 26, 2011

Search Engine Optimization - Basic

Web has expanded a lot, and more than that. The search engines now talk in exabytes which is equal to 1 billion gigabytes. Google has more than 4000 million webpages indexed with its powerful search engine. It is very difficult to be on the top of the list in this type of tough fight which gives birth to the new career in IT - Search Engine Optimization. 


 
What is Search Engine Optimization...??

Search engine optimization (SEO) is the process of improving the visibility of a website or a web page in search engines.( source: Wikipedia).

Search Engines has their own strategies to rank the pages or websites. When you search anything through search engine, it gives thousands or even millions of result. No one is going to see all those but the sum of on the top are viewed by users. So if you want your website to be viewed by more and more users all you need is upper rank in those searches. But it is not so easy, for that you need to know how search engines work, how they rank and place the pages in their search results. Even the domain age is checked for stability of domain. Popularity of the product for which the website is created, reputation of the websites is also the factors affecting the rank because Search engines also have the competition to be on the top.

Now all these things are not possible for end users or even the companies single handily. That gives you the 1 more new career opportunity as an Search Engine Optimizer (SEO). SEO uses the some techniques like adding the mostly searched keywords in your website, removing redundant data from your website which highlights your website in Result Engine of the Search Engine.

If you are a company user and can afford an SEO thats good but if you cant then there are some simple tricks which can improve your rank in search results. 
  1. Keep the amount of data on single page High. More the data on webpage more the chances of improvement in rank of that page.
  2. Use keyword in your pages. Keywords are very useful in webpages as all the searches are done by using keywords only.
  3. Keep the keyword density moderate. If you use the keyword ( like SEO in this post) for many times the page may be declared as spam and get penalized by Search Engine.
  4. Text Formatting. While writing webpages useful tags like Meta tags, Title tag, Alt tags for images must be added.
  5. Your Home page should be the face of your site. Users mostly judge the websites by their home page. Add better functionality to your site through links from home page.
 While we are talking about increasing the rank by natural and algorithmic means some search engines provide premium services known as Search Engine Marketing in which paid rankings are provided to the webpages or websites by search engines itself. But though SEO plays vital role in increasing the rankings and most probably preferred by website admins.

Wednesday, July 6, 2011

The Puzzle Game - Source Code

Windows 7 has provided gadgets in which they have a simple puzzle game called Picture Puzzle... I made the same 1 with numbers at the places of parts of picture...
Share the code for Non-profit purpose..


Here you have to arrange all numbers in ascending order as
  
   1      2      3      4
   5      6      7      8
   9     10    11     12
   13   14    15     __

Use w a s d to swap the numbers with "__" sign considered as free space.
you can change the puzzle by just changing the contents of an array c[4][4]

© All Rights Reserved.

/*
Author: Roshan Kedar

*/

 #include<stdio.h>
#include<conio.h>
#include<process.h>
void swap(int *a,int *b);
int compare(int a[4][4], int b[4][4]);
int pos(int c[4][4], int d,int no);
void display(int a[4][4]);
void main()
{
    int a[4][4],c[4][4],no,b=1,i,j,d=16,d1=16,comp,no3;
    char no2;
    for(i=0;i<4;i++)
        {
            for(j=0;j<4;j++)
                {
                    a[i][j]=b;
                    b++;
                }
        }
    c[0][0]=4;
    c[0][1]=13;
    c[0][2]=3;
    c[0][3]=15;
    c[1][0]=6;
    c[1][1]=14;
    c[1][2]=2;
    c[1][3]=8;
    c[2][0]=7;
    c[2][1]=1;
    c[2][2]=16;
    c[2][3]=11;
    c[3][0]=12;
    c[3][1]=5;
    c[3][2]=9;
    c[3][3]=10;
    abc:;
    d1=16;
    d=16;
    comp=9;
    clrscr();
    printf("\nHey game lovers here is the gadget game for Windows");
    printf("\n\nmove the nos using w(up),a(left),s(down),d(right) and arrange them");
    printf("\n\nFor any instance 2 quit press O");
    printf("\n...........................................");
    display(c);
    printf("\t\n");
    no2=getche();
    no3=no2;
    d1=pos(c,d,16);
    if(no3==119)
        {
            if(d1<12)
                {
                    swap(&c[d1/4][d1%4],&c[(d1/4)+1][d1%4]);
                    comp=compare(c,a);
                    if(comp==6)
                            goto ab;
                    else
                            goto abc;
                }
            else
                {
                    goto abc;
                }
        }
    else if(no3==115)
        {
            if(d1>3)
                {
                    swap(&c[d1/4][d1%4],&c[d1/4-1][d1%4]);
                    comp=compare(c,a);
                    if(comp==6)
                            goto ab;
                    else
                            goto abc;
                }
            else
                {
                    goto abc;
                }
        }
    else if(no3==100)
        {
            if(d1%4>0)
                {
                    swap(&c[d1/4][d1%4],&c[d1/4][d1%4-1]);
                    comp=compare(c,a);
                    if(comp==6)
                            goto ab;
                    else
                            goto abc;
                }
            else
                {
                    goto abc;
                }
        }
    else if(no3==97)
        {
            if(d1%4<3)
                {
                    swap(&c[d1/4][d1%4],&c[d1/4][d1%4+1]);
                    comp=compare(c,a);
                    if(comp==6)
                            goto ab;
                    else
                            goto abc;
                }
            else
                {
                    goto abc;
                }
        }
    else if(no3==111)
    exit(1);
    else
        {
        goto abc;
        }
        ab:;
        clrscr();
        printf("\n\n\n\n*********congratulation puzzle solved*********");
        display(c);
        printf("16");
        getch();
}

int pos(int c[4][4],int d,int no)
{
    int i,j;
    if(no<17&&no>0)
        {
            for(i=0;i<4;i++)
                {
                    for(j=0;j<4;j++)
                        {
                            if(c[i][j]==no)
                                {
                                    d=(4*i)+(1*j);
                                    break;
                                }

                        }
                }
        }
        return d;
}
void display(int a[4][4])
{
    int i,j;
    printf("\n");
    for(i=0;i<4;i++)
        {
            printf("\n");
            for(j=0;j<4;j++)
                {
                    if(a[i][j]==16)
                    printf("\t__");
                    else
                    printf("\t%d",a[i][j]);

                }
        }
}
int compare(int a[4][4], int b[4][4])
{
    int i,j,comp=9;
    for(i=0;i<4;i++)
        {
            for(j=0;j<4;j++)
                {
                    if(a[i][j]==b[i][j])
                    comp=i+j;
                    else
                    return comp;
                }
        }
    return comp;
}
void swap(int *a,int *b)
{
    *a=*a+*b;
    *b=*a-*b;
    *a=*a-*b;
}

Wednesday, April 20, 2011

Push Box - Source Code


Here is the Source code for my 1st graphics game in C language. Share the code for non-profit purpose.

© All Rights Reserved.

Explanation :
Here I have created 11 row and 9 col char matrix which actually acts as platform for the puzzle.
To differentiate all the elements different characters are used.

H for wall
O as moving object or "Hero"
U as the object that has to pushed by hero
X as the hurdles , U must be pushed into X
a as empty spaces.

Placing Walls, Moving objects U, hurdles X and empty spaces along with the initial place of  "Hero" is covered in designing part.
You can customize your own puzzle by changing the Array elements accordingly.


Rules:

  • Movement of Hero is done by using keys w as up, a as left, s as down, d as right.
  • Hero is restricted through walls ans Xs.
  • Hero can push only one object at a time.
  • Remember only pushing is possible pulling is restricted 
  • When you push box in hurdles both the object and hurdles will disappear and the position acquired by X before pushing will become free space.
  • At any stage to Quit press o.
  • To restart press r.
  • Play keeping caps lock off.



SNAPSHOT OF PUSHBOX

/*
Author: Roshan Kedar
Compatibility: Win XP and before, Win7 32 bit (somewhat unstable)

*/

#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void display(char a[11][9]);
int pos(char a[11][9]);
void swap(char *a,char *b);
int final(char a[11][9]);
void main()
{
char a[11][9],ch;
int i,j,no,upos,final1=-1;
        int gdriver = DETECT, gmode, errorcode;  /* request auto detection */
        int x0,x1,y0,y1;
        initgraph(&gdriver, &gmode, "");    /* initialize graphics mode */
        cleardevice();

ab:;
/* Designing the Stage  */
for(i=0;i<11;i++)
{
for(j=0;j<9;j++)
{
a[i][j]='a';
}
}
for(i=0;i<11;i++)
{
a[i][0]='H';
a[i][8]='H';
}
for(i=0;i<9;i++)
{
a[0][i]='H';
a[10][i]='H';
}
for(i=1;i<11;i++)
{
for(j=2;j<9;j++)
{
if((i%2==0)&&(j%2==0))
a[i][j]='H';
}
}
a[1][1]='X';
a[1][7]='X';
a[9][1]='X';
a[9][7]='X';
a[4][3]='U';
a[4][5]='U';
a[6][3]='U';
a[6][5]='U';
a[5][1]='O';
a[1][2]='H';
a[1][4]='H';
a[1][6]='H';
a[6][7]='H';
a[7][2]='H';
a[7][4]='H';
a[7][6]='H';

/* You can change the designing part to customize your own puzzle  */
abc:;
final1=final(a);
if(final1==0)
{
clrscr();
display(a);
printf("\n\n********Congrats Puzzule Solved********");
}
else
{
clrscr();
display(a);

upos=pos(a);
ch=getche();
no=ch;

if(no==119)
{
if(a[(upos/9)-1][upos%9]!='H')
{

if(a[2][1]=='U'&&a[3][1]=='O')

{
a[1][1]='a';
a[2][1]='O';
a[3][1]='a';
goto abc;
}

else if(a[2][7]=='U'&&a[3][7]=='O')
{
a[1][7]='a';
a[2][7]='O';
a[3][7]='a';
goto abc;
}
else if((a[(upos/9)-1][upos%9]=='U')&&(a[(upos/9)-2][upos%9]=='H'))
goto abc;

else if((a[(upos/9)-1][upos%9]=='U')&&(a[(upos/9)-2][upos%9]=='U'))
goto abc;

else if((a[(upos/9)-1][upos%9]=='U')&&(a[(upos/9)-2][upos%9]!='H'))
{
swap(&a[(upos/9)-2][upos%9],&a[(upos/9)-1][upos%9]);
swap(&a[upos/9][upos%9],&a[(upos/9)-1][upos%9]);
}
else if(a[(upos/9)-1][upos%9]!='X')
swap(&a[upos/9][upos%9],&a[(upos/9)-1][upos%9]);

}
goto abc;
}
else if(no==115)
{
if(a[upos/9+1][upos%9]!='H')
{

if(a[8][1]=='U'&&a[7][1]=='O')

{
a[9][1]='a';
a[8][1]='O';
a[7][1]='a';
}

else if(a[8][7]=='U'&&a[7][7]=='O')
{
a[9][7]='a';
a[8][7]='O';
a[7][7]='a';
}

else if((a[upos/9+1][upos%9]=='U')&&(a[upos/9+2][upos%9]=='H'))
goto abc;

else if((a[upos/9+1][upos%9]=='U')&&(a[upos/9+2][upos%9]=='U'))
goto abc;

else if((a[upos/9+1][upos%9]=='U')&&(a[upos/9+2][upos%9]!='H'))
{
swap(&a[upos/9+2][upos%9],&a[upos/9+1][upos%9]);
swap(&a[upos/9][upos%9],&a[upos/9+1][upos%9]);
}
else if(a[(upos/9)+1][upos%9]!='X')
swap(&a[upos/9][upos%9],&a[(upos/9)+1][upos%9]);


}

goto abc;
}
else if(no==100)
{
if(a[upos/9][upos%9+1]!='H')
{

if(a[1][6]=='U'&&a[1][5]=='O')

{
a[1][7]='a';
a[1][6]='O';
a[1][5]='a';
}

else if(a[9][6]=='U'&&a[9][5]=='O')
{
a[9][7]='a';
a[9][6]='O';
a[9][5]='a';
}

else if((a[upos/9][upos%9+1]=='U')&&(a[upos/9][upos%9+2]=='H'))
goto abc;

else if((a[upos/9][upos%9+1]=='U')&&(a[upos/9][upos%9+2]=='U'))
goto abc;

else if((a[upos/9][upos%9+1]=='U')&&(a[upos/9][upos%9+2]!='H'))
{
swap(&a[upos/9][upos%9+2],&a[upos/9][upos%9+1]);
swap(&a[upos/9][upos%9],&a[upos/9][upos%9+1]);
}
else if(a[(upos/9)][upos%9+1]!='X')
swap(&a[upos/9][upos%9],&a[(upos/9)][upos%9+1]);
}
goto abc;
}
else if(no==97)
{
if(a[upos/9][upos%9-1]!='H')
{

if(a[1][2]=='U'&&a[1][3]=='O')

{
a[1][1]='a';
a[1][2]='O';
a[1][3]='a';
}

else if(a[9][2]=='U'&&a[9][3]=='O')
{
a[9][1]='a';
a[9][2]='O';
a[9][3]='a';
}

else if((a[upos/9][upos%9-1]=='U')&&(a[upos/9][upos%9-2]=='H'))
goto abc;

else if((a[upos/9][upos%9-1]=='U')&&(a[upos/9][upos%9-2]=='U'))
goto abc;

else if((a[upos/9][upos%9-1]=='U')&&(a[upos/9][upos%9-2]!='H'))
{
swap(&a[upos/9][upos%9-2],&a[upos/9][upos%9-1]);
swap(&a[upos/9][upos%9],&a[upos/9][upos%9-1]);
}
else if(a[(upos/9)][upos%9-1]!='X')
swap(&a[upos/9][upos%9],&a[(upos/9)][upos%9-1]);
}
goto abc;
}

else if(no==111)
{
return 0;
}
       else if(no==114)
                {
                       goto ab;
                 }
else
goto abc;
}

getch();      /* clean up */
closegraph();

}

void display(char a[11][9])
{

int i,j,x1=100,y1=100,x2=120,y2=120;
int poly[8];
for(i=0;i<11;i++)
{
for(j=0;j<9;j++)
{
if(a[i][j]=='H')
{
poly[0]=poly[6]=x1;
poly[1]=poly[3]=y1;
poly[4]=poly[2]=x2;
poly[7]=poly[5]=y2;
rectangle(x1,y1,x2,y2);
setfillstyle(SOLID_FILL,RED);
fillpoly(4,poly);
}
if(a[i][j]=='U')
{
poly[0]=poly[6]=x1+3;
poly[1]=poly[3]=y1+3;
poly[4]=poly[2]=x2-3;
poly[7]=poly[5]=y2-3;
rectangle(x1+3,y1+3,x2-3,y2-3);
setfillstyle(SOLID_FILL,YELLOW);
fillpoly(4,poly);
}
if(a[i][j]=='X')
{
poly[0]=poly[6]=x1+3;
poly[1]=poly[3]=y1+3;
poly[4]=poly[2]=x2-3;
poly[7]=poly[5]=y2-3;
rectangle(x1+3,y1+3,x2-3,y2-3);
setfillstyle(SOLID_FILL,BLACK);
fillpoly(4,poly);
}
if(a[i][j]=='O')
{
poly[0]=poly[6]=x1+3;
poly[1]=poly[3]=y1+3;
poly[4]=poly[2]=x2-3;
poly[7]=poly[5]=y2-3;
rectangle(x1+3,y1+3,x2-3,y2-3);
setfillstyle(SOLID_FILL,CYAN);
fillpoly(4,poly);
}
if(a[i][j]=='a')
{
poly[0]=poly[6]=x1;
poly[1]=poly[3]=y1;
poly[4]=poly[2]=x2;
poly[7]=poly[5]=y2;
rectangle(x1,y1,x2,y2);
setfillstyle(SOLID_FILL,GREEN);
fillpoly(4,poly);
}
x1=x1+20;
x2=x2+20;
}
x1=100;
x2=120;
y1=y1+20;
y2=y2+20;
}
}

int pos(char a[11][9])
{
int i,j,pos;
for(i=1;i<11;i++)
{
for(j=1;j<9;j++)
{
if(a[i][j]=='O')
{
pos=9*i+j;
return(pos);
}
}
}
}

void swap(char *a,char *b)
{
char temp;
temp=*a;
*a=*b;
*b=temp;
}

int final(char a[11][9])
{
int i,j,final=0;
        for(i=0;i<11;i++)
{
for(j=0;j<9;j++)
{
if(a[i][j]=='U')
{
final=1;
return(final);
}
}
}
return(final);
}

Thanks to Prerak Dhoot, Pritesh Dhokchaule, Saurabh Kabra, Ankesh Porwal for supporting me.
Thanks to Anirudh Tomer for sharing his knowledge.
Thanks to Microsoft who provided graphics.h with much simpler help topics.