Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

For Loop in C++

Last modified on May 26th, 2018 at 1:51 pm

Example of For loop:

#include <iostream>

using namespace std;

int main()

{

int i, n;

int factorial= 1;

cout << “Enter a number: “;

cin >> n;

for (i= 1; i <= n; ++i) {

factorial*= i;

}

cout<< “Factorial of “<<n<<” = “<<factorial;

return 0;

}

Prof. Fazal Rehman Shamil
Researcher, Publisher of International Journal Of Software Technology & Science ISSN: 2616-5325
Instructor, SEO Expert, Web Programmer and poet.
Feel free to contact.