Learn to Code via Tutorials on Repl.it!

← Back to all posts
How to make a Input/Output bot in C++
h
YYX999Piano (1)

Hello, this is how to make a input/output bot in C++.
First let's get the basics:

#include <iostream>
#include <cmath>
using namespace std;

int main() {
   return 0;
}

We put <cmath> to use math.
Now, we have to make a input.
To make a input, we have to make a variable:

The DataTypes:

int: stores an integer.
float: stores a integer.
string: stores some text.

#include <iostream>
#include <cmath>
using namespace std;

int main() {
   //the variable generation
   float input1;
   float input2;
   return 0;
}

We leave the variables undefined to make a input.
Then, we make a input for each variable.

#include <iostream>
#include <cmath>
using namespace std;

int main() {
   //the variable generation
   float input1;
   float input2;
   //the code generation
   cin >> input1;
   cin >> input2; 
   return 0;
}

Then, we make the final output:

#include <iostream>
#include <cmath>
using namespace std;

int main() {
   //the variable generation
   float input1;
   float input2;
   //the code generation
   cin >> input1;
   cin >> input2;
   cout << input1 * input2; 
   return 0;
}

I hope this tutorial helped you!

Comments
hotnewtop
DynamicSquid (4897)

1) Why use cmath? That's for things like pow() and sqrt()
2) I wouldn't really call this a bot, it's just input output
3) This doesn't really matter but it's called declaration instead of generation

CodeLongAndPros (1622)

@DynamicSquid Actually, there are code generators:

[int(c) for c in list]