Vcoderz Community
We create websites that have it all, beauty & brains
Lebanon Web Design & Development - Coddict
 

Go Back   Vcoderz Community > Computer Zone > Computers & Information Technologies > E-Learning Center

Notices

E-Learning Center E-Learning tutorials and competitions.

Reply
 
Share Thread Tools Search this Thread
Old 11-17-2010   #1
JaSS.lb
Registered Member
 
JaSS.lb's Avatar
 
Last Online: 06-20-2011
Join Date: Mar 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Groans: 0
Groaned at 0 Times in 0 Posts
Default Operating system

plz some help for my project i don't know how to do it
Operating System ===> Ubuntu ====> C language

The Project Is:

The Fibonacci Sequence is the series of numbers 0, 1, 1, 2, 3, 5, 8, ....
Formally, it can be expressed as:
fib0 = 0;
fib1 = 1;
fibn = fibn-1 + fibn-2;
Write a program C using the fork() system call that generates the fibonacci sequence in the child process. the number of sequence will be provided in the command line. for example, if 5 is provided, the first numbers in the fibonacci sequence will be output by the child process. because the parent and child processes have their own copies of data, it will be necessary for the child to output sequence. have the parent invoke the wait() call to wait for the child process to complete before exiting the program. perform the necessary error checking to ensure that non-negative number is passed on the command line.


JaSS.lb is offline   Reply With Quote
Old 11-17-2010   #2
Tawa
 
Tawa's Avatar
 
Last Online: 08-02-2018
Join Date: Mar 2006
Posts: 6,245
Thanks: 2,120
Thanked 3,365 Times in 1,740 Posts
Groans: 29
Groaned at 44 Times in 35 Posts
Default

I'm not sure if this is what you want, but give it a try:

Code:
#include <stdio.h>

int main(){
    int i;

    do{
        printf("Input Number: ");
        scanf("%d", &i);
    }while(i < 0);

    if(fork()==0){
        int j;
        int fibn=0;
        int fibnminus1=0;
        int fibnminus2=0;
        for(j = 0; j < i; j++){
            fibnminus2 = fibnminus1;
            fibnminus1 = fibn;
            if(j < 2)
                fibn = j;
            else
                fibn = fibnminus1+fibnminus2;                
            printf("%d, ", fibn);
        }
        printf("...\n");
        return 0;
    }else{
        wait();
    }

    return 0;
}
__________________
What we do in life, echoes in eternity.
Tawa is offline   Reply With Quote
Old 12-10-2010   #3
JaSS.lb
Registered Member
 
JaSS.lb's Avatar
 
Last Online: 06-20-2011
Join Date: Mar 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Groans: 0
Groaned at 0 Times in 0 Posts
Default

Thx Tawa For The Solution
JaSS.lb is offline   Reply With Quote
Reply

  Vcoderz Community > Computer Zone > Computers & Information Technologies > E-Learning Center

Tags
operating



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:50 PM.


Lebanon web design and development
Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Share