Tuesday 24 June 2014

C++ program to print first and last character in a string


Here is a C++ program to print first and last character in a string 


 SOURCE CODE OUTPUT
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    char str[100],temp,rep;
    cout<<"Enter string : ";
    cin>>str;
    cout<<"First character : "<<str[0];
    cout<<"\nLast character : "<<str[strlen(str)-1];
    return 0;
}


Any questions regarding to program please write in comments.

No comments:

Post a Comment