Pages

Friday, April 11, 2014

C program to find Fibonacci Series with understanding logic

Fibonacci Series or Sequence
The Fibonacci numbers or Fibonacci series or Fibonacci sequence has first two numbers equal to 1 and 0 and the further each number is consist of the addition of previous two numbers
  1st number = 0
  2nd number = 1
  3rd number = 0+1= 1
  4th number = 1+1= 2
  5th number = 1+2= 3
  And so on.  

 The Fibonacci Sequence can be written as  0,1,1,2,3,5,8,13........



 C++ program to find Fibonacci Series upto given range.This C++ program use simple logic to get the about of writing code in C++ for Fibonacci Series
  1.     #include<iostream>
  2.     using namespace std;
  3.     int main()
  4.     {
  5.        int range, first = 0, second = 1, fibonicci=0;
  6.        cout << "Enter Range for Terms of Fibonacci Sequence: ";
  7.        cin >> range;
  8.        cout << "Fibonicci Series upto " << range << " Terms "<< endl;
  9.        for ( int c = 0 ; c < range ; c++ )
  10.        {
  11.           if ( c <= 1 )
  12.              fibonicci = c;
  13.           else
  14.           {
  15.              fibonicci = first + second;
  16.              first = second;
  17.              second = fibonicci;
  18.           }
  19.           cout << fibonicci <<" ";
  20.        }
  21.        return 0;
  22.     }

  Fibonacci Series program logic explanation
  • Before writing C++ code we understand that what is Fibonacci Series and in what sequence numbers are occurs
  • After understanding mathematically Fibonacci series completely we thought it in the form of C++ code
  • The Fibonacci series is infinite but we cant make a program that display an infinite output
  • In above program we take input the range in integer upto which Fibonacci series will be displayed
  • For this purpose a for loop has been taken which starts from 0 and terminates less than range for example if Input is 5 then for loop will run from 0 to 4.
  • In for loop if  variable c is  less or equal than 1 in this case if statement  will be executed  and if  c is greater than 1 else part will be executed for greater than 1
   e.g if range=2 than only
   if part will run.   let input is equal to 5
   Before loop variables values


   first = 0, second = 1, Fibonacci=0;
   After input range=5
   Values are changing in the following sequence
   in below table  c   representing the for loop iterations
   c    first    second   Fibonacci    Output
  

   0     0         1                 0           0 

   1     0         1                 1           0 1
  
   2     0         1           0+1=1         0 1 1
        
          1          1                1           

   3     1         1           1+1=2         0 1 1 2
     
          1         2                  2

   4    1         2             1+2=3         0 1 1 2 3  its final output
   
         2         3                  3      


     

Image View Of  Program (Click on Image To Enlarge)
Fibonacci series in C++ image Code

Fibonacci Series In C++ Programming
Fibonacci series C++ Code


If you have any queries comment below.
Read More..

Support for CSS class tags

In an earlier post I described how Run BASIC can use the DIV and CSS statements to style a web page. That works well for styling the different parts of a web page, but not for styling individual things on a page.

One new addition to Run BASIC is the ability to add a CSS class tag to an object on a web page, so that it can be manipulated.

For example the following would create a link and set a class to "button".

link #doMyBidding, "GO", [go]
#doMyBidding cssclass("button")

And the following statement would add the CSS needed to style the link (or any object that has the class tag "button"):

cssclass ".button", "{ put some css styling in here }"

Here is a link to a video demonstrating how this all works.

http://www.youtube.com/watch?v=1qomg67VdF0
Read More..

Thursday, April 10, 2014

How Can A Free Reverse Cell Phone Number Look Up Benefit You

By Cedric Bartoo


Periodically a download of charge reverse cell look up service can benefit you. As an example, you might be in the middle of a critical meeting and a person calls you merely to hold up prior to deciding to answer the phone call. You delay forever for him to call you back however, there is nothing. Since you are driving somewhere, a trip will come in suddenly. When you want to resolve it, the phone stops ringing. You want to call back the individual nevertheless, you cannot see his number. All you could see on the display is private number calling without number whatsoever.

Its likely you have been a victim for these a theft. Similar with other women, you could have kept all your personal belongings like cellphone and purse within it. So, now, there is the hassle of being forced to find all of the contact names and corresponding numbers, until you took the precaution of creating a backup copy on your hard drive. Many people dont take into consideration making a backup copy of their cell contact list. Perhaps, simply because they dont have knowledge of how without headaches it is to do this.

In terms of a police report, no end with creating a report. You will find the time for it to be spent for following high on the problem. Regardless of whether you can see the persons number you arent. Setting up a police report isnt be considered a good step unless you do not mind enduring all the hassle of doing so. The better option will be to wait for the person to you together with ask because of their name at the very least.

The true secret is to discover paid site, that is reputable with higher reviews. People change their cell numbers on occasion. The cell phone companies tend not to delete the existing numbers from other system. Instead they recycle the previous numbers. Quite simply, someone else using a different name may be while using cell phone number you want to test, unless the site that offers the paid cell lookup service updated its search system. So, look for a site that offers a regularly updated search system to achieve accurate specifics of the cell number you are keen on checking.

By using a site with a huge database is often a victorious one so you can get accurate details about a particular cell phone number. How do you determine if they have a large database? One smart way is to see its site and check out the offered services. If the site offers other services like neighborhood check and criminal record check or a paid cell lookup service, you can find high chances how the database for cell lookup is big. It also ensures that the database available from this type of site could possibly be reliable.

Indeed, utilizing a track cell number download service is very tempting. However there are certain risks if you do this. You have the potential for malware infecting your laptop or computer. As there are the issue of whether or not the provided details are reliable you arent. This is applicable to both paid and download cell lookup service.




About the Author:



Read More..

Wednesday, April 9, 2014

Buying Car Laptop Desks At Pro Desks American Stores

By Merv Carlson


Thanks to technology improvements such as laptops, peoples work and study are becoming simpler. In recent times, any time coming to a workplace, you can easily notice many different modern gadgets like laptops, iPads, smart phones, wireless printers, and so on. The nice thing about these units is that they are wireless so they can be taken with you on the go, even when youre in a vehicle. You can not put the mobile computer on your lap while youre driving. Here is where car laptop desk comes into play. A vehicle laptop desk will provide users with the full comfortable access to their laptops while they are in their cars or cars.

The benefits laptops can bring to people in this high-tech modern world are indisputable. The usefulness and mobility have made laptops develop into a must-have piece for a number of people, particularly for businessmen. Nevertheless, unsuitable posture while using laptops may result in health issues for laptop users. People can experience back pain, eye strain and also neck pull if they work on the laptops for long hours.

Pro Desks provides perfect mobile computing solutions. The company is located in North America but they ship their products around the world. These laptop mounts can easily fit with all GMC as well as the Chevrolet cars. If you do a quick research, you can find some of their most powerful car computer stand models such as the Enforcer II, the Navigator, the Enforcer. No other products made by competitors can be compared to the Enforcer II in terms of having advanced features and durability. It is the advanced features that make the Enforcer II gain such good rating on the market. This typical car laptop holder fit laptop of all sizes, including the ones with widescreens. Additionally, it can also accommodate laptops that were ruggedized without any problems. Take note that this laptop desk is basically an interchangeable base plate, thus you can move it to a different vehicle if needed. This car laptop holder is a wise investment since you will not to change the mount when you change your car models. Just remove and re-install the mounting system using the tools provided, use suitable base and you are done.

Now we take a closer look at the features of the Pro Desks Mongoose. Pro Desks Mongoose car laptop desks easily stand out from other products made by competitors in terms of quality and durability. You can find no other car laptop desks which have more advanced features than the Mongoose. One of the most impressive features is the 360 degree rotating pedestal arm holding the slide. It fits well with laptop of any sizes, including the 17 widescreen ones. One more innovative feature of the Mongoose is the custom base plate. Mongoose is a no-drilling car laptop desk, which means no modifications will be done to your car while the Mongoose is being installed. Mongoose is also referred to as a "seat rail desk".

The Pro Desk Navigator is considered as a very durable laptop desk for cars. This laptop desk is specifically designed in order to provide years of service since it can also be removed from one vehicle and transferred to another. You just need to remove the base and then install it to the new car. This is a no-drilling product so no car modifications are required. You can have a passenger as usual without worrying that the desk system will affect the movement of him. Your passenger can comfortably work on the laptop. He just needs to adjust the position a little bit.

The Pro Desks Navigator is best suited for people who work in fields which require on-site work such as supply sales professionals, utility companies and services. Almost all on-the-go professionals will benefit from this laptop mount. With the advanced locking system, this car laptop holder has the best theft protection feature on the market.




About the Author:



Read More..

How Top Rated St Petersburg Marinas Provide Winterization Solutions For Boat Owners

By Jessie Drolet


Sailing is truly a fun-filled pastime. It is a great enjoyment you can have with friends and family. It is a great way to enjoy the sun and water. It is however, quite a seasonal activity. It may not be feasible to go sailing during the winter months. During the cold season, it would be a good idea for you to look into winterization services of St. Petersburg marinas.

A boat can incur quite a bit of damage, especially if you leave it out during the winter season. With lesser use of it during this time, having your vessel dry stored is a good idea. You will be able to avoid getting it damaged by both sea water and the harsh weather.

A vessel such as this has several complex systems that could be adversely affected by weather. Having your yacht dry stored will avoid this during the times that it will not be getting much use. Thus, it is best to look into winterization methods that these marina companies provide.

Using specialized storage racks, you can have your yacht stored above the ground to minimize damage. It will be lifted out of the water using special lift trucks that can do this task safely. These trucks will take the boat out of the water and position it on the racks. You can opt for either indoor or outdoor storage.

This is also a perfect time for you to have maintenance services done on your yacht. These professionals will be able to look into all the boats parts and equipment and conduct any repairs if needed. By doing so, your boat is brought back to its top condition.

There is no need to risk having your sailing vessel damaged during winter. St. Petersburg marinas offer winterization services that will keep your boat protected. They will also bring your boat back to its prime condition with maintenance servicing while in storage. Having your boat stored will cost much less than having to repair damage caused by being exposed during the winter.




About the Author:



Read More..

Tuesday, April 8, 2014

Read and print string

Q. Write a simple C program to accept your name and print it.

Ans.

/*c program to introduction of string*/
/*c program to accept your name and print it*/
#include<stdio.h>
#include<conio.h>
int main()
{
 char str[30];
 printf("Enter your name : ");
 gets(str);
 puts(str);
 getch();
 return 0;
}

/***************Output*******************/
Screen shot for read and print string via gets() and puts()



/*Another way to write above program to intro of string*/
#include<stdio.h>
#include<conio.h>
int main()
{
 char str[30];
 printf("Enter your name : ");
 scanf("%s", &str);
 printf("Your name is %s",str);
 getch();
 return 0;
}


/***************Output*******************/
Screen shot for read and print string via scanf() and printf()


Related Programs:
Read More..

A Simple Pong Game using JavaScript

Pong Game in JavaScript Screenshot


Having the knowledge of moving images using JavaScript, we’ll be creating a small Ping Pong game as an example for this post.


Today we’ll learn to do a few new things in JavaScript:


1. Executing some code every specified time interval (for game loop).

2. Tracking and using mouse movements.

3. Attaching code (function) to events.


Game Theory


As you should be knowing, in this game there is one ball and two paddles at two ends. One is user-controlled the other, for this example, is CPU controlled. User has to move the paddle in order not to let the ball pass through, CPU also has to do the same thing. Whoever’s side the ball passes through looses the game.


There are a few objects which can interact with each other, these are ball, paddles, walls. Let’s see the various interactions that can take place between these:




  1. Ball Hitting Upper/Lower Wall – Ball will bounce off.




  2. Ball Passing Through Either Side – Player or CPU, depending on whose side ball passed through, will loose the game.




  3. Ball Hitting Paddle – It’ll bounce off




We’ll need to take care of these events:




  1. Page Load – Game objects will be initialized




  2. Game Start – Mouse click on the player paddle will start the game.




  3. Mouse Movements – Inside the game area (a div), the paddle will follow the y-position of the mouse. Paddle however should not get past the boundaries.




  4. CPU Paddle – The paddle will follow the ball by moving up/down depending the relative position of the ball. We’ve added a little intelligence by only moving the paddle while ball is coming towards it. This will make the movement as well as the game look more real.




Code


NOTE: Put two files ball_small.png, paddle.png (Right-Click "Save As") in the same directory the script is in.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pong Game In JavaScript</title>

<style>
#box
{
width: 500px;
height: 300px;
margin: auto;
border: 5px solid #ccc;
position: relative;
overflow: hidden;
}

.ob
{
position: absolute;
border: 0px;
}
</style>
<script type="application/javascript">

// CHANGE THESE, IF REQUIRED
var Speed = 5; // Speed of ball (pixels/step)
var CPUSpeed = 5; // Speed of CPU Paddle (pixels/step)

// Short references to objects
var paddle1;
var paddle2;
var ball;
var box;
var msg;


// For internal use
var dx, dy; // Speed in x and y directions
var ballX, ballY; // x and y positions of ball
var playerY; // y position of player paddle (x fixed)

var cpuY; // y position of CPU paddle (x fixed)
var iID; // To store ID of set interval used to clear it when required

// Attach a function to onLoad event
window.onload = Init;

// INITIALIZE GAME OBJECTS
function Init()
{
// Make short refrences to objects

paddle1 = document.getElementById(paddle1);
paddle2 = document.getElementById(paddle2);
ball = document.getElementById(ball);
box = document.getElementById(box);
msg = document.getElementById(msg);

// Initial values
ballX = (box.offsetWidth / 2) - (ball.offsetWidth / 2);
ballY = (box.offsetHeight / 2) - (ball.offsetHeight / 2);
cpuY = (box.offsetHeight / 2) - (paddle2.offsetHeight / 2);
playerY = (box.offsetHeight / 2) - (paddle1.offsetHeight / 2);
dx = dy = Speed;

paddle1.style.left = 20 + px;
paddle1.style.top = playerY + px;
paddle2.style.left = box.offsetWidth - (20 + paddle2.offsetWidth) + px;
paddle2.style.top = cpuY + px;
ball.style.left = ballX + px;
ball.style.top = ballY + px;

// Show message

msg.innerHTML = <h2>Click on Paddle to Start Game.</h2>;
}

// START GAME
function Start()
{
// Attach a function to onmousemove event of the box
box.onmousemove = MovePaddle;
// Call GameLoop() function every 10 milliseconds

iID = setInterval(GameLoop(), 10);

msg.innerHTML = ;
}

// MAIN GAME LOOP, CALLED REPEATEDLY
function GameLoop()
{
// MOVE BALL
ballX += dx;
ballY += dy;

// See if ball is past player paddle

if(ballX < 0)
{
clearInterval(iID);
Init();

box.onmousemove = ;

msg.innerHTML = <h2>You Loose!<br/>Click on Paddle to Re-Start Game.</h2>;
}

// See if ball is past CPU paddle

if((ballX + ball.offsetWidth) > box.offsetWidth)
{
clearInterval(iID);
Init();

box.onmousemove = ;

msg.innerHTML = <h2>You Win!<br/>Click on Paddle to Re-Start Game.</h2>;
}

// COLLISION DETECTION

// If ball hits upper or lower wall
if(ballY < 0 || ((ballY + ball.offsetHeight) > box.offsetHeight))
dy = -dy; // Make x direction opposite

// If ball hits player paddle

if(ballX < (paddle1.offsetLeft + paddle1.offsetWidth))
if(((ballY + ball.offsetHeight) > playerY) && ballY < (playerY + paddle1.offsetHeight))
dx = -dx;

// If ball hits CPU paddle
if((ballX + ball.offsetWidth) > paddle2.offsetLeft)
if(((ballY + ball.offsetHeight) > cpuY) && ballY < (cpuY + paddle2.offsetHeight))
dx = -dx;

// Place ball at calculated positions

ball.style.left = ballX + px;
ball.style.top = ballY + px;

// MOVE CPU PADDLE
// Move paddle only if ball is coming towards the CPU paddle
if(dx > 0)
{
if((cpuY + (paddle2.offsetHeight / 2)) > (ballY + ball.offsetHeight)) cpuY -= CPUSpeed;
else cpuY += CPUSpeed;

paddle2.style.top = cpuY + px;
}
}


// TO MOVE PLAYER PADDLE ON MOUSE MOVE EVENT
function MovePaddle(e)
{
// Fetch y coordinate of mouse
var y = (e.clientY - (box.offsetTop - document.documentElement.scrollTop));
// Here, (box.offsetTop - document.documentElement.scrollTop) will get the relative
// position of "box" w.r.t to current scroll postion

// If y below lower boundary (cannot go above upper boundary -
// mousemove event only generated when mouse is inside box
if(y > (box.offsetHeight - paddle1.offsetHeight))
y = (box.offsetHeight - paddle1.offsetHeight);

// Copy position
playerY = y;
// Set position

paddle1.style.top = y + px;
}
</script>
</head>

<body bgcolor="#fff">
<h1 align="center">Pong Game Example in JavaScript</h1>

<div id="box">
<img class="ob" id="paddle1" src="paddle.PNG" onclick="javascript: Start()"/>

<img class="ob" id="paddle2" src="paddle.PNG" />
<img class="ob" id="ball" src="ball_small.PNG" />

</div>
<div id="msg" align="center"></div>
</body>
</html>

Related Posts:


Read More..