Click here to Skip to main content
14,546,974 members

C / C++ / MFC

 
Questionuploadig adobe reader file in local host in c language Pin
sunycity4-Oct-15 22:31
Membersunycity4-Oct-15 22:31 
AnswerRe: uploadig adobe reader file in local host in c language Pin
Jochen Arndt4-Oct-15 22:54
professionalJochen Arndt4-Oct-15 22:54 
QuestionCFileDialog OnTypeChange issue Pin
_Flaviu1-Oct-15 20:59
Member_Flaviu1-Oct-15 20:59 
QuestionRe: CFileDialog OnTypeChange issue Pin
_Flaviu2-Oct-15 3:00
Member_Flaviu2-Oct-15 3:00 
AnswerRe: CFileDialog OnTypeChange issue Pin
Maximilien2-Oct-15 4:06
MemberMaximilien2-Oct-15 4:06 
GeneralRe: CFileDialog OnTypeChange issue Pin
_Flaviu4-Oct-15 21:29
Member_Flaviu4-Oct-15 21:29 
QuestionA c program to project expected number of rabbits on a farm Pin
Arnold Mukisa29-Sep-15 8:27
MemberArnold Mukisa29-Sep-15 8:27 
AnswerRe: A c program to project expected number of rabbits on a farm Pin
Arnold Mukisa29-Sep-15 8:30
MemberArnold Mukisa29-Sep-15 8:30 
Ive been able to write this but i feel it can be sized down and made better your direct ideas will be of much help as I am only abt 2weeks in c programming but hv been working very hard to learn
thks take a look

#include<stdio.h>
int main()
{
int initialrabbits,no_months,Kittens[10],Rabbits,count=1,kits,totalkittens;
    printf("\nEnter initial no of rabbits:\a ");
    scanf("%d",&initialrabbits);

    printf("\nEnter number of months to be projected:\a ");
    scanf("%d",&no_months);

        for(count=1;count<=no_months;count++)
        {
            if (count==1){
            Kittens[0]=initialrabbits*8;
            Rabbits=initialrabbits;
            kits=Kittens[0];
            totalkittens=Kittens[0];}

            else if (count==2){
            Kittens[1]=initialrabbits*8;
            Rabbits=initialrabbits;
            kits=Kittens[1];
            totalkittens=Kittens[0]+Kittens[1];}

            else if (count==3){
            Kittens[2]=(Kittens[0]+initialrabbits)*8;
            Rabbits=Kittens[0]+initialrabbits;
            kits=Kittens[2];
            totalkittens=Kittens[1]+Kittens[2];}

            else if (count==4){
            Kittens[3]=(Kittens[0]+Kittens[1]+initialrabbits)*8;
            Rabbits=Kittens[0]+Kittens[1]+initialrabbits;
            kits=Kittens[3];
            totalkittens=Kittens[2]+Kittens[3];}

            else if (count==5){
            Kittens[4]=(Kittens[0]+Kittens[1]+Kittens[2]+initialrabbits)*8;
            Rabbits=Kittens[0]+Kittens[1]+Kittens[2]+initialrabbits;
            kits=Kittens[4];
            totalkittens=Kittens[3]+Kittens[4];}

            else if (count==6){
            Kittens[5]=(Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+initialrabbits)*8;
            Rabbits=Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+initialrabbits;
            kits=Kittens[5];
            totalkittens=Kittens[4]+Kittens[5];}

            else if (count==7){
            Kittens[6]=(Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+initialrabbits)*8;
            Rabbits=Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+initialrabbits;
            kits=Kittens[6];
            totalkittens=Kittens[5]+Kittens[6];}

            else if (count==8){
            Kittens[7]=(Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+Kittens[5]+initialrabbits)*8;
            Rabbits=Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+Kittens[5]+initialrabbits;
            kits=Kittens[7];
            totalkittens=Kittens[6]+Kittens[7];}

            else if (count==9){
            Kittens[8]=(Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+Kittens[5]+Kittens[6]+initialrabbits)*8;
            Rabbits=Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+Kittens[5]+Kittens[6]+initialrabbits;
            kits=Kittens[8];
            totalkittens=Kittens[7]+Kittens[8];}

            else if (count==10){
            Kittens[9]=(Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+Kittens[5]+Kittens[6]+Kittens[7]+initialrabbits)*8;
            Rabbits=Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+Kittens[5]+Kittens[6]+Kittens[7]+initialrabbits;
            kits=Kittens[9];
            totalkittens=Kittens[8]+Kittens[9];}


            printf("\n\tMONTH %d",count);
            printf("\nNUMBER OF RABBITS: %d",Rabbits);
            printf("\nKittens produced this month: %d",kits);
            printf("\nTotal kittens now: %d\n",totalkittens);

        }

return 0;
}

SuggestionRe: A c program to project expected number of rabbits on a farm Pin
David Crow29-Sep-15 15:42
MemberDavid Crow29-Sep-15 15:42 
GeneralRe: A c program to project expected number of rabbits on a farm Pin
David Crow29-Sep-15 15:34
MemberDavid Crow29-Sep-15 15:34 
QuestionRe: A c program to project expected number of rabbits on a farm Pin
Paul Conrad1-Oct-15 7:33
subeditorPaul Conrad1-Oct-15 7:33 
GeneralRe: A c program to project expected number of rabbits on a farm Pin
David Crow1-Oct-15 10:19
MemberDavid Crow1-Oct-15 10:19 
Question0 bytes CImage saved Pin
_Flaviu28-Sep-15 23:47
Member_Flaviu28-Sep-15 23:47 
QuestionRe: 0 bytes CImage saved Pin
CPallini29-Sep-15 0:02
mveCPallini29-Sep-15 0:02 
AnswerRe: 0 bytes CImage saved Pin
_Flaviu29-Sep-15 0:06
Member_Flaviu29-Sep-15 0:06 
AnswerRe: 0 bytes CImage saved Pin
_Flaviu29-Sep-15 0:33
Member_Flaviu29-Sep-15 0:33 
SuggestionRe: 0 bytes CImage saved Pin
Jochen Arndt29-Sep-15 0:36
professionalJochen Arndt29-Sep-15 0:36 
GeneralRe: 0 bytes CImage saved Pin
_Flaviu29-Sep-15 0:57
Member_Flaviu29-Sep-15 0:57 
GeneralRe: 0 bytes CImage saved Pin
Jochen Arndt29-Sep-15 0:59
professionalJochen Arndt29-Sep-15 0:59 
GeneralRe: 0 bytes CImage saved Pin
_Flaviu29-Sep-15 1:00
Member_Flaviu29-Sep-15 1:00 
QuestionHow to drag a node from treeview to listbox in MFC. What is the event ? Pin
Member 1199023524-Sep-15 16:50
MemberMember 1199023524-Sep-15 16:50 
AnswerRe: How to drag a node from treeview to listbox in MFC. What is the event ? Pin
Jochen Arndt24-Sep-15 22:13
professionalJochen Arndt24-Sep-15 22:13 
Questionhelp Pin
robsons200724-Sep-15 16:01
Memberrobsons200724-Sep-15 16:01 
AnswerRe: help Pin
robsons200724-Sep-15 16:05
Memberrobsons200724-Sep-15 16:05 
AnswerRe: help Pin
robsons200724-Sep-15 16:06
Memberrobsons200724-Sep-15 16:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.