qwertyuiop1234

Lab_Excerise_10-A_Ex1

Mar 12th, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. //---Lab_Excerise_10-A_Ex1-------------
  2. #include<iostream>
  3. #include<cstring>
  4. using namespace std;
  5. int main()
  6. {
  7.     char name[] = "dhanushka";
  8.  
  9.     cout << strlen(name) << endl;
  10.     for(int r =0;r<strlen(name);r++)
  11.     {
  12.         cout<< name[r] << endl;
  13.     }
  14. //-------------------------------------
  15.     for(int r =strlen(name);r>=0;r--)
  16.     {
  17.         cout<< name[r] << endl;
  18.     }
  19. //-------------------------------------
  20.     cout<< endl;
  21.  
  22.     char name2[50];
  23.     strcpy(name2 , "21st street, Edirisinghe Mw, Colombo 10");
  24.     cout << name2 << endl;
  25.  
  26. //Convert to UPPERCASE ~!~!~!~!~!~!~!~!~
  27.     cout<< endl << "UPPERCASE > > > > " << endl;
  28.     for (int i = 0; i<=strlen(name2);i++)
  29.     {
  30.         if (islower(name2[i]))
  31.         {
  32.             name2[i] = name2[i] - 32;
  33.         }
  34.  
  35.     }
  36.     cout << name2 << endl;
  37. //---------------------------------------
  38.  
  39. //Print only numeric part ~!~!~!~!~!~!~!~
  40.     cout<< endl << "Only numeric > > > > " << endl;
  41.     for(int i=0; i<=strlen(name2); i++)
  42.     {
  43.         if (isdigit(name2[i]))
  44.         {
  45.             cout << name2[i];
  46.         }
  47.     }
  48.     cout << endl;
  49.  
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment