Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---Lab_Excerise_10-A_Ex1-------------
- #include<iostream>
- #include<cstring>
- using namespace std;
- int main()
- {
- char name[] = "dhanushka";
- cout << strlen(name) << endl;
- for(int r =0;r<strlen(name);r++)
- {
- cout<< name[r] << endl;
- }
- //-------------------------------------
- for(int r =strlen(name);r>=0;r--)
- {
- cout<< name[r] << endl;
- }
- //-------------------------------------
- cout<< endl;
- char name2[50];
- strcpy(name2 , "21st street, Edirisinghe Mw, Colombo 10");
- cout << name2 << endl;
- //Convert to UPPERCASE ~!~!~!~!~!~!~!~!~
- cout<< endl << "UPPERCASE > > > > " << endl;
- for (int i = 0; i<=strlen(name2);i++)
- {
- if (islower(name2[i]))
- {
- name2[i] = name2[i] - 32;
- }
- }
- cout << name2 << endl;
- //---------------------------------------
- //Print only numeric part ~!~!~!~!~!~!~!~
- cout<< endl << "Only numeric > > > > " << endl;
- for(int i=0; i<=strlen(name2); i++)
- {
- if (isdigit(name2[i]))
- {
- cout << name2[i];
- }
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment