| vatwomen0 (2) | |
|
Sir what is the code for a program that input a name horizontal and display the name in vertical position using looping any kind of looping? PLSSS help IT IS MY ASS. EX. INPUT:Enter A name:John OUTPUT: J O H N | |
|
Last edited on
|
|
| vlad from moscow (3654) | |
|
If you will use class std::string to keep an entered name then the code can look the following way for ( std::string::size_type i = 0; i < s.size(); i++ ) std::cout << s[i] << std::endl; where s is declared as std::string s; Or you can use the for statement based on range (if your compiler supports it ) for ( char c : s ) std::cout << c << std::endl; or if you are using MS VC++ foreach( char c in s ) std::cout << c << std::endl; Otherwise if you will use a character array then the code can look as for ( const char *p = s; *p; ++p ) std::cout << *p << std::endl; where s is declared something as char s[N]; EDIT: if you need to output each letter in upper case then you should apply function toupper from header <cctype>. For example for ( char c : s ) std::cout << toupper( c ) << std::endl; EDIT: The same can be done with standard algorithms. For example by means of std::transform | |
|
Last edited on
|
|
| vatwomen0 (2) | |
| can you send me THE code plsss | |
|
|
|
| Stewbond (1842) | |||
You didn't really try. Here's some code, but this isn't a favor. If you can't get this sort of thing on your own, you will not (or at least should not) pass the class. Things will get much harder and if you don't take the time to learn it now, you will get so far behind and so frustrated when things start to get complicated.
| |||
|
|
|||