C Program for Pigeon Breeding Problem
The problem is as follows…
Initially i have a pair of adult pigeons(capable of breeding) which give rise to another young pair every month until it reaches the age of 5 years(60 months).But the young pair starts breeding only when it is 2 months old.Once the adult pigeon pair starts breeding it never stops untils the age of 5 years.Assume the age of initial adult pigeon is 2 months old.This program takes the no. of months as input and will calculate the total no. of pigeons over a given time(as given by the input).This problem is framed, based on my own imagination and i call this problem as PIGEON BREEDING PROBLEM.Heres the code
#include<stdio.h>
#include<process.h>
struct node
{
int age;
struct node *link;
};
typedef struct node* NODE;
NODE getnode()
{
NODE x;
x=(NODE)malloc(sizeof(struct node));
if(x==NULL)
{
printf(“Out of memory\n”);
exit(1);
}
return x;
}
void main()
{
unsigned long int count=1;
unsigned int months,i;
NODE first=getnode();/*this is the intial adult pair*/
first->age=2; /*assume the age of initial adult pair as 2*/
first->link=NULL;
printf(“Enter the no. of months\n”);
scanf(“%u”,&months);
for(i=0;iage>=2)&&(temp->age<=60)) { NODE temp1=getnode(); temp->age+=1;
temp1->age=1;
temp1->link=first;
first=temp1;
temp=temp->link;
++count;
}
else
{
temp->age+=1;
temp=temp->link;
}
}
}
printf(“Total no. of pairs after %u months=%ld\n”,months,count);
}
Popularity: 1% [?]
By using/following this site you agree to our Legal Disclaimer


Thanks for sharing your thoughts in my blog about the Inspiron 1525 dell issue..
Nice site!! keep up the gud work.
Thanks for your support
thinking out of the box..nice effort..!!
Ya ofcourse…it’s something very unusual and different…i like it…:-)
Leave your response!
EMAIL SECURITY »
How to Block Unwanted Emails
Do you want to block emails from your ex wife/husband? Do you want to block those annoying offers and newsletters that reach your inbox? Well here is a way to block all those unwanted and …
NETWORK HACKS »
How to Find the IP Address of a Remote Computer
Most of you may be curious to know how to find the IP address of your friend’s computer or to find the IP address of the person with whom you are chatting in Yahoo messenger or Gtalk. …
PC SECURITY »
10 Tips for a Total Online Security
With the sudden rise in the Internet usage across the globe over the past few years, there has also been a rise in the amount of online scams and frauds. Today most of the Internet users are unaware …
VIRUS CREATION »
A Virus Program to Disable USB Ports
In this post I will show how to create a simple virus that disables/blocks the USB ports on the computer (PC). As usual I use my favorite C programming language to create this virus. Anyone with …
XP HACKS »
How to Hack Windows Administrator Password
This hack will show you how to reset Windows administrator password (for Win 2000, XP, Vista and Win 7) at times when you forget it or when you want to gain access to a computer …
Categories
Blogroll
Recent Comments
Most Commented
Most Popular
Log In | Entries (RSS) | Comments (RSS) | Sitemap | Arthemia Premium theme by Michael Jubel