New course! Every coder should learn Generative AI!
Try a free lesson+ 4
C++
A robot can type 300 letters per minute. The given program takes the text input time (in minutes). Task Complete the code to calculate and output the number of letters that will be typed in a given time. Sample Input 20 Sample Output 6000 Hint To calculate the length of the text, you need to multiply the time by a count (letters per minute). Attempt in comments
18 Answers
+ 3
Tanvir, you forgot to declare the variable "result"
Corrected code:
#include <iostream>
using namespace std;
int main() {
int speed = 300; //speed of the robot
int time, result; //declare variables
cin >> time; //input the time
result = time * speed;
cout << result; //output the result
return 0;
}
+ 2
include <iostream>
using namespace std;
int main() {
int computer = 300;
int time;
cin >> time ;
result = computer * time;
cout << result ;
return 0;
}
Does this work??
+ 2
#include <iostream>
int result = computer * time;
+ 1
Doesnt work though
+ 1
Nope
+ 1
Yeah... That's it.. Thanks Simba
+ 1
#include<iostream>
using namespace std;
int main ()
{
int n; // n is given time
cin>>n;
cout<<n*300;
return 0;
}
+ 1
#include<iostream>
int main()
{
int n = 300;
int time;
cin>>time;
cout<<n*time;
return 0;
}
0
include <iostream>
using namespace std;
int main() {
int computer = 300;
int time = 1;
cin >> time * computer;
cout << time ;
return 0;
}
0
Yay... You made the solution urself...
0
Oh... I didn't test that btw...
😅😅😅
0
What's the error..?? I mean, can u please tell me.. I am not in a position to test it... Sorry
Pardon my poor English.... 😩😩
0
Lothar
Please correct me... I am new to cpp
0
Thanks Chris
0
#include < iostream>
Using namespace std;
Int main()
{
Double time,letters;
/*Double will be used because time can be in hours and minutes both */
Cin>>time ;
Letters = 300* time ;
Cout <<letters;
Return 0 ;
}
0
int count = 300; // letter in a minute
int time = 20;
cin >> time;
//your code goes here
count *= time;
cout << count << endl;
0
#include <iostream>
using namespace std;
int main() {
int speed = 300; //speed of the robot
int time, result; //declare variables
cin >> time; //input the time
result = time * speed;
cout << result; //output the result
return 0;
}
Good Luck
0
#include <iostream>
using namespace std;
int main() {
int speed = 300; //speed of the robot
int time, result; //declare variables
cin >> time; //input the time
result = time * speed;
cout << result; //output the result
return 0;
}