Saved Bookmarks
| 1. |
Write a program to input a word(say COMPUTER) and create a triangle as follows. C C O C O M C O M P C O M P U C O M P U T C O M P U T E C O M P U T E R |
|
Answer» #include<iostream> #include<cstring>//for strlen() using namespace std; int main() { charstr[20]; cout<<“enter a word(eg.COMPUTER):”; cin>>str; int ij; for(i=0;i<strlen(str);i++) { for(j=0;j<=i;j++) cout<<str[j]<<“\t”; cout<<endl; } } |
|