+ 1

Program to calculate the number of steps

25th Nov 2016, 2:32 AM
vinay
vinay - avatar
10 odpowiedzi
+ 1
#include <iostream> using namespace std; int main() { string str = "This is test "; int nos_of_spaces = 0; for(int i=0;i<str.length();i++){ if(str[i] == ' '){ nos_of_spaces++; } } cout<<str<<" contains "<<nos_of_spaces<<" spaces"<<endl; return 0; }
28th Nov 2016, 3:55 PM
Abhishek Kumar
Abhishek Kumar - avatar
0
Number of steps of what??
25th Nov 2016, 5:12 AM
Abhishek Kumar
Abhishek Kumar - avatar
0
example...if we wrote something The no of steps are 3
28th Nov 2016, 2:39 PM
Jarvis
Jarvis - avatar
0
please tell
28th Nov 2016, 3:23 PM
Jarvis
Jarvis - avatar
0
your question is unclear it would be nice if you could explain with some example
28th Nov 2016, 3:40 PM
Abhishek Kumar
Abhishek Kumar - avatar
0
I am tasking that how to make a program which can tell that how many steps are in a given string for example Abhishek Kumar it has only one space so how to make this program which can tell the number of steps
28th Nov 2016, 3:43 PM
Jarvis
Jarvis - avatar
0
asking
28th Nov 2016, 3:44 PM
Jarvis
Jarvis - avatar
0
hope it helped :)
28th Nov 2016, 3:56 PM
Abhishek Kumar
Abhishek Kumar - avatar
0
thanks
28th Nov 2016, 3:57 PM
Jarvis
Jarvis - avatar
0
if it worked for you plz VOTE UP the answer
28th Nov 2016, 4:02 PM
Abhishek Kumar
Abhishek Kumar - avatar