Saved Bookmarks
| 1. |
Write a program to input a line of text and display the first characters of each word. Use only console I/O functions. For example, if the input is “Save Water, save Nature”, the output should be “SWSN”. |
|
Answer» #include<iostream> #include<cstdio> using namespace std; int main() { int i; charstr[80]; cout<<“Enter a string\n”; gets(str); if(str[0]!=32) cout<<str[0]; for(i=0;str[i]!=’\0′;i++) if(str[i]==32 && str[i+1]!=32) cout<<str[i+1]; } |
|