Diaplay string using write() function .

 



#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    char * str1="c++";
    char * str2="progamming";
    int m=strlen(str1);
    int n=strlen(str2);

    for (int i = 0i < ni++)
    {
        cout.write(str2,i);
        cout<<""<<endl;
    }

    for (int i = ni > 0i--)
    {
        cout.write(str2,i);
        cout<<""<<endl;
    }

    // concertinateing the string
    cout.write(str1,m).write(str2,n);
    cout<<"\n"<<endl;
    cout.write(str1,5);

}

output :
p pr pro prog proga progam progamm progammi progammin progamming progammin progammi progamm progam proga prog pro pr p c++progamming c++p

Comments

Popular Post

Define a class to represent a Bank Account. Include the following members: Data Members: i. Name of the depositor ii. Account number iii. Type of account iv. Balance amount in the account Member Functions: 1. To Input initial values 2. To deposit an amount 3. To withdraw an amount after checking the balance 4. To display name and balance Also write constructor for this class that takes four arguments. It should also handle type of account as savings by default