CapitalBaazi

 Problem

Cheems doesn't like extra content so coming straight to the point. Given the input of one line, having words separated by a single space, print each word of the input, each in a new line.
Also, change all the alphabets to uppercase along with doing this.

Input:-
Given in one line, all letters are lowercase only, separated by a single space.

Characters used in input are from 'a' to 'z' only ( 26 in total ) , both included.

Length of input   104

Output:-
Output each word with characters in uppercase.

Note:- A testcase contains only one word as the input to get partial marks. Also, the ideal solution has been provided, you can test any of your legal input to get its answer.

Sample Input
subscribe to the luv channel
Sample Output
SUBSCRIBE
TO
THE
LUV
CHANNEL
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Every word of the input has been placed in the new line with characters in uppercase as well.





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

int main() {
    string str1;
    getline(cin,str1);
    for(int i=0;i<(str1.size());i++){
        if(isspace(str1[i])){
            
            str1[i]='\n';
            
        }
        else{
            int changer='a'-'A';
            str1[i]=str1[i]-changer;
        }
    }
    cout<<str1;
}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings