Welcome To The World Of Hacking


Learn Hacking|Teach Hacking|Learn To Secure|Learn To Code

Friday

C++ TUTORIAL 10: WHILE LOOP

//Generation of Fibonacci series beteen 1 and 100

#include <iostream>
using namespace std;

void printTheStatement(); //Here function declaration is  done

int main()
{
    int num1 = 1;
    int num2 = 1;
    cout<<"num1 :"<<num1<<endl;

    while(num2<100) // while loop continues till the condition satisfies
    {
        cout<<"num2 :"<<num2<<endl;
        num2+=num1;
        num1 = num2-num1;
    }
    return 0;
}

OUTPUT:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...