Page Rank Checker

Web Tourer

This Web Browser Is Completely Design And Coded By Me. Click Here For More Information Or Download.

Hardware

Click here to learn complete Computer Hardware without paying any cost. Articles are provided free of cost by WOLWEB.

Get Free Attractive Templates For Your Blog or Website

This Website Provide Free Attractive Templates For Download. For Download Just Click Here.

Let Us C Solution

This Is A Solution For Let Us C Book Written By Yashwant Kanetkar Learning Basic C Programming.

Page Rank Checker

Page Rank checker is a free tool to check Google™ page ranking of any web site pages easily and to display your site's PageRank™ value on your web pages

Alexa

Alexa is the leading provider of free, global web metrics. Search Alexa to discover the most successful sites on the web by keyword, category, or country.

Showing posts with label C Programming. Show all posts
Showing posts with label C Programming. Show all posts

Sunday, 26 October 2014

Program For Finding Rank Of Matrix In C



This program is for finding rank of matrix and solving system of linear equation
Let's try it.

#include<stdio.h>
#include<conio.h>
    float a[10][10];
    float b[10];
    int m,n;
void setorder();
void getmatrix();
int chkzero(int i);
void printrank();
void print();
void rowop(int i);
void changerow(int i, int l);

void main()    {
    clrscr();
    int i=1;
    int chk;
   
    setorder();
    getmatrix();
    clrscr();
    print();
    for(i=1;i<m;)    {
chk = chkzero(i);
        if((a[i-1][i-1]==0) && (chk==1) )    {
            changerow(i,i);

        }
        else    {
            rowop(i);
            i++;
        }
    }
        printf("\n\tFinal Matrix Is:\n\n");
          print();
          printrank();

    getch();
}

void setorder()     {
printf("Enter Order of Matrix\n");
scanf("%d%d",&m,&n);
clrscr();
}

void getmatrix()    {
        int x,y,z;
        printf("Enter Coefficient Matrix\n");
        for(x=0;x<m;x++)    {
              for(y=0;y<n;y++)      {
                    scanf("%f" ,&a[x][y]);
              }
        }

        clrscr();

        printf("Enter Matrix of Constants\n");
         for(z=0;z<m;z++)    {
           scanf("%f",&b[z]);
         }
         clrscr();
}

void changerow(int i,int l)    {
    float temp,temp1;
int j;
    if(a[i][l-1]==0)    {
        i++;
        changerow(i,l);
    }
    else    {
        temp1=b[i-1];
        b[i-1]=b[i];
        b[i]=temp1;
        for(j=0;j<n;j++)    {
            temp=a[i-1][j];
            a[i-1][j]=a[i][j];
            a[i][j]=temp;
        }
        printf("\t\tR%d%d\n\n",i,i+1);
        print();
    }
}

void rowop(int i)    {
    float temp1,temp2,temp3;
int j;
    int l=1;
    int k=i;
    int o=i;
    temp1=a[o-1][o-1];
    //    printf("\n%d",i);
    for(;i<m;i++,l++)    {
        temp2=a[i][i-l];
if(temp1!=0)  {
        b[i]=b[i]-(temp2/temp1)*b[i-l];
        for(j=0;j<n;j++)    {
            a[i][j]=a[i][j]-(temp2/temp1)*a[i-l][j];
        }
}
    if(temp2!=0)    {
        printf("\n\tR%d=R%d-(%.3f/%.3f)*R%d\n",i+1,i+1,temp2,temp1,k);
        print();
    }

    }


}

int chkzero(int i)      {
int k=i;
int j=0;

     for(;j<n;j++)     {
          if (a[k][j]==0)   {
                //  return 0;
          }

           else       {
         //      break;
               return 1;
            
           }
     }

}

void print()    {
    int x,y;
    for(x=0;x<m;x++)    {
        for(y=0;y<n;y++)    {
            printf("%10.3f ",a[x][y]);
        }
        printf("\t%12.3f",b[x]);
        printf("\n");
    }
    printf("\n");
}

void printrank()     {
        int x,y;
        int rank=0;
        for(x=0;x<m;x++)     {
            for(y=0;y<n;y++)     {
                  if (a[x][y]!=0)   {
                         rank++;
                         break;
                  }
            }
        }
       printf("\n\t\tRank of given matrix is %d",rank);
}

Sunday, 18 May 2014

Matchsticks Game In C-Who Forced Select Last


This is the coding for the matchstick selection game created in C. This is actually a one sided game always computer will win this game. This game has total mathematical basis. For any query give the comment.
For executing it simply copy this coding and paste it in the compiler you want and execute it.

Rule For The Game:
1.There are total 21 matchsticks.
2.You can select either 1, 2, 3 or 4 matchsticks at a time.
3.After the person picks Computer does its picking.
4.Whoever is forced to pick up the last matchstick loses the game.

#include<stdio.h>
#include<conio.h>
void main()
{
    clrscr();
    int usr=0,comp=0,rmn=21;
    printf("Rules For The Game:\n");
    printf("1.There are total 21 matchsticks.\n2.You can select either 1, 2, 3 or 4 matchsticks at a time.\n3.After the person picks Computer does its picking\n4.Whoever is forced to pick up the last matchstick loses the game.");
    do
    {
        rmn=rmn-comp;    \*Calculates remaining sticks after each loop complition*\
        printf("\n\nRemaining Matchsticks: %d",rmn);
        printf("\nEnter number of matchsticks you pick: ");
        scanf("%d",&usr);
        clrscr();
        if((usr<=4 && rmn>=6) || (usr==1 && rmn<=6))
        {
            rmn=rmn-usr;    \*calculates remaining matchsticks after user input*\
            if(rmn!=0)
            {
                comp=5-usr;    \*This is a tricky part and has pure mathematical basis i.e. always computer will select a number which is got by this expression*\
                printf("\nYou have selected %d Matchsticks",usr);
                printf("\nComputer Selected %d Matchsticks",comp);
            }
            else if(rmn==0)    \*prints the result of game actually result is same because always computer will win*\
            {
                printf("\nRemaining Matchsticks Are %d",rmn);
                printf("\nYOU LOST THE GAME");
                break;
            }
        }
        else
        {
            printf("\nPlease Enter a valid choice i.e. 1 2 3 or 4");
            comp=0;
        }
    }while(1);        \*used for infinite loop i.r. loop will continue till it doesn't encounter 'break;' statement*\
    getch();
}

The logic behind the program is:
There are total 21 matchsticks and who forced to select last one is lost and we wanted to make a program in which computer always win so the last matchstick should be selected by the user. so we wanted that whenever the last selection of user is come into the picture at that time there should be only 1 matchstick remaining and there is a rule that user or computer can select at most 4 matchsticks at a time so for making force on user to select last matchstick whenever the user's second last (last is the turn when there is only 1 matchstick remaining) selection turn is arrived at that time there should be 6 matchsticks remaining so user selects any number of match sticks from 1,2,3 or 4 after that computer selects (5-number of matchsticks selected by the user ) so at the selection turn of user there is only one matchstick is remaining. This last step is possible only if at each turn the sum of selected matchsticks by computer and selected matchsticks by user is 5. so we tell the computer via program that after each time the selection done by user computer should select (5-number of matchsticks selected by the user) matchsticks so at each turn there should 5 matchsticks less than the previous turn.

So the whole program is run in following fashion
At 1st turn
Remaining Matchsticks :- 21
User selects 1,2,3 or 4 matchsticks
Computer Selects 5-number of matchsticks selected by the user

At 2nd turn
Remaining Matchsticks :- 16
User selects 1,2,3 or 4 matchsticks
Computer Selects 5-number of matchsticks selected by the user

At 3rd turn
Remaining Matchsticks :- 11
User selects 1,2,3 or 4 matchsticks
Computer Selects 5-number of matchsticks selected by the user

At 4th turn
Remaining Matchsticks :- 6
User selects 1,2,3 or 4 matchsticks
Computer Selects 5-number of matchsticks selected by the user

At 5th turn
Remaining Matchsticks :- 1
User selects 1 matchstick because only 1 matchstick is remaining

Thursday, 15 May 2014

Calender In C-Takes Year And Prints Day At 1 Jan


I am Posting here this is article basically for the begginers in C programing. The programme given below will first ask the user to type the year (year should be greater than 2000) and then tell us that what will be the day at 1January of the year enter NEW
Description : I am Posting here this is article basically for the begginers in C programing. The programme given below will first ask the user to type the year (year should be greater than 2000) and then tell us that what will be the day at 1January of the year entered by the user. For using it simply copy and paste the code given below and compile it using any c compiler.

#include<stdio.h>
#include<conio.h>
int cal(int );
int prnt(int );
void main()
{
   clrscr();
   int yr;
   printf("enter year ");
   scanf("%d",&yr);
   cal(yr);
   getch();
}
int cal(int yr)
{
   int diff, lp_yr;
   unsigned int totds;
   diff=yr-2001;                 \*calculate number of years between provided year and 2001 *\
   lp_yr=diff/4;                    \*calculate number of leap years between provided year and 2001*\
   totds=365*diff+lp_yr+1; \*calculate total days between 1 Jan of provided year and 1 Jan 2001 *\
   printf("%u\n\n",totds);      \*prints total days between 1 Jan provided year and 1 Jan 2001 *\
   prnt(totds);
}
int prnt(int totds)
{
   int dycd;
   dycd=totds%7; \*This is the main part of the program this is purely mathematical part see calender and try to understand if have any doubt give comments I will surely give you reply*\
   switch (dycd)
  {
   case 1:
     printf("monday");
     break;
   case 2:
     printf("tuesday");
     break;
   case 3:
     printf("wednesday");
     break;
   case 4:
     printf("thursday");
     break;
   case 5:
     printf("friday");
     break;
   case 6:
     printf("saturday");
     break;
   case 0:
     printf("sunday");
     break;
  }
}