CrazyEngineers
  • WAP in C

    Updated: Oct 22, 2024
    Views: 1.1K
    5) write a program to print a histogram of fibonaci series of n item i.e if input is 7
    then output will be
    1, 1, 2, 3, 5, 8, 13
    *
    *
    **
    ***
    *****
    ********
    *************
    .

    pliz solve it, if any 1 is here. i kno the algorithm bt its difficult to impliment 😔
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • simplycoder

    MemberAug 30, 2014

    Vidisha Singh
    5) write a program to print a histogram of fibonaci series of n item i.e if input is 7
    then output will be
    1, 1, 2, 3, 5, 8, 13
    *
    *
    **
    ***
    *****
    ********
    *************
    .

    pliz solve it, if any 1 is here. i kno the algorithm bt its difficult to impliment 😔
    Hello Vidhisha,
    The first program is called as printing the Fibonacci series for first n terms.
    The second is very famous, loop pattern printing.

    I suggest you to refer the tutorials here on this forum,
    <a href="https://www.crazyengineers.com/threads/beginners-tutorial-the-c-language.46520">Beginners Tutorial : The C-language.</a>

    In case if you are stuck, please share your work and we would be glad to hlp you complete it.
    Take care,
    SC
    Are you sure? This action cannot be undone.
    Cancel
  • avii

    MemberAug 30, 2014

    what have you tried so far? post some code
    Are you sure? This action cannot be undone.
    Cancel
  • Sanyam Khurana

    MemberAug 30, 2014

    Please remember, People are not here to do your homework.

    Best advice is, show us what you have done so far, or at least what you have tried, this way you'll learn more & solve your problem too.

    Doesn't matter that if your program is not working, but at least show what you have tried yourself.
    Are you sure? This action cannot be undone.
    Cancel
  • jeshukb09

    MemberAug 31, 2014

    Hi Vidisha...
    I am here giving you just the main program part. Rest of the program and all has to be done by yourself.
    The keywords which I am using here is related to C++.

    variable 'f' is an array of N elements, where N is the number inputted by the user.

    cout<<"The fibonocci series is : ");
    for (i=1;i<=N;i++)
    {
    f(i)=1;
    if (i>2)
    f(i)=f(i-1)+f(i-2);
    cout<<"\t"<<f(i);
    }
    for i=1;N<=N;i++
    {
    for j=1;j<=f(i);j++
    cout<<"*";
    cout<<"\n";
    }

    Actually the above given program is the logic. I have tried it in MATLAB programming and it is working. So I think it should work with this logic in C++. (Actually I have used C++ 6 years before. so I have some doubt in the syntax.) For reference I am giving below the actual program that I have done in MATLAB.


    clear all
    clc
    N=input('Please enter the no.of number in the series : ');
    f=zeros(1,N);
    disp('The fibonocci series is : ');
    for i=1:1:N
    f(i)=1;
    if i>2
    f(i)=f(i-1)+f(i-2);
    end
    end
    disp(f);
    for i=1:1:N
    for j=1:f(i)
    fprintf('%s','*');
    end
    fprintf('\n');
    end

    Hope this will surely Help You.....
    Are you sure? This action cannot be undone.
    Cancel
  • avii

    MemberAug 31, 2014

    ^somebody please remove this. this will encourage more noobie behaviour
    Are you sure? This action cannot be undone.
    Cancel
  • [Prototype]

    MemberSep 1, 2014

    jeshukb09
    Hi Vidisha...
    I am here giving you just the main program part. Rest of the program and all has to be done by yourself.
    The keywords which I am using here is related to C++.

    variable 'f' is an array of N elements, where N is the number inputted by the user.

    cout<<"The fibonocci series is : ");
    for (i=1;i<=N;i++)
    {
    f(i)=1;
    if (i>2)
    f(i)=f(i-1)+f(i-2);
    cout<<"\t"<<f(i);
    }
    for i=1;N<=N;i++
    {
    for j=1;j<=f(i);j++
    cout<<"*";
    cout<<"\n";
    }

    Actually the above given program is the logic. I have tried it in MATLAB programming and it is working. So I think it should work with this logic in C++. (Actually I have used C++ 6 years before. so I have some doubt in the syntax.) For reference I am giving below the actual program that I have done in MATLAB.


    clear all
    clc
    N=input('Please enter the no.of number in the series : ');
    f=zeros(1,N);
    disp('The fibonocci series is : ');
    for i=1:1:N
    f(i)=1;
    if i>2
    f(i)=f(i-1)+f(i-2);
    end
    end
    disp(f);
    for i=1:1:N
    for j=1:f(i)
    fprintf('%s','*');
    end
    fprintf('\n');
    end

    Hope this will surely Help You.....
    Well done making the above 3 guys look idiot. You're the king man. That was such a tough one to solve. How could you even do it? 👀😲
    Are you sure? This action cannot be undone.
    Cancel
  • Sanyam Khurana

    MemberSep 1, 2014

    First let people show their own code. That way they'll learn even more. If they simply ask without trying, and you provide them with answers, they'll learn nothing, they'll simply have a mentality set that I'll just ask other people to do my homework.

    You are thinking to help people here, and I really appreciate it. However, UN-intentionally you are doing more harm to them. Hope you understand, what we are actually trying to imply here. 😀
    Are you sure? This action cannot be undone.
    Cancel
  • avii

    MemberSep 2, 2014

    [Prototype]
    Well done making the above 3 guys look idiot. You're the king man. That was such a tough one to solve. How could you even do it? 👀😲
    Must some super haxx0r. may be Ankit Fadia.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register