+ 2
I need a person can help me in c++because i am novice
14 Answers
+ 4
yes i do this way
+ 2
tnx u
+ 1
i am newrly coding so i have problem in some program although they are simple
+ 1
like this
+ 1
#include<iostream>
#include<math.h>
using namespace std;
int f(int );
int main()
{
int i,fact ;
cout « "please enter an integer number= ";
cin » i;
f;
return 0;
}
int f(int)
{
int i,fact ;
if ( i != 0) {
return (i* fact (i - 1));
}
return 1;
}
+ 1
or
+ 1
#include<iostream>
using namespace std;
int main()
{
char c;
if (c != 'e')
{
cout « "enere a char=";
cin » c;
cout « "enter e for exit=";
}
return 0;
}
+ 1
Your first program should look like this:
#include<iostream>
using namespace std;
int f(int i);
int main()
{
int i;
cout << "please enter an integer number= ";
cin >> i;
cout << f(i) << endl;
return 0;
}
int f(int i)
{
if (i != 0) {
return (i * f(i - 1));
}
return 1;
}
You could also change the 4 f to fact, which makes more sense (you had one that way.)
+ 1
I think others will make me mock because others know very well
0
The last code doesnt make sense to me... it would be better for enter anything to exit. Like this
int main(){
int c;
cout << "Press anything to exit...";
cin >> c;
if (c==" ") {
return 0;
}
else {
return 0;
}
}
0
You might run into a few, but most have been where you are and will go out of their way to help.