Hi guys,
I am just a newbie with C++ though I have minute experience with Java and Python. I was trying something with C++ but came across an error in very early stages of the lesson. I was wondering if someone here can guide me with it. The problem is that I was doing a code in CodeBlocks and it just doesn't wanna work while the same coding works perfectly in Dev C++. I am just not a big fan of Dev C++ due to it being discontinued now while in Beta stages. In C:B, it gives me a terminal with 'Hello World' message while in Dev C++ it correctly gives the factorial of the number entered. The program I am trying to run is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
int main()
{
int num, factorial = 1;
cout<<"Enter the number: ";
cin>>num;
for (int i = 1; i<=num; i++)
{
factorial = factorial*i;
}
cout<<"The factorial of the number is";
cout<<factorial;
getch();
return 0;
}
Can anyone please enlighten me as to why does C:B refuse to grow up from the 'Hello World' program?
Thanks!
Edit: Strangely, it started working on its own. All I did was re-add the .cpp file to the project. Guess, it didn't get added properly, first time around. Right now I am going through the the C++ tutorial made available here at cplusplus.com