adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Program in C++ to print abbreviation of given full name.

Program in C++ to print abbreviation of given full name.



#include<iostream>
#include<string.h>
 using namespace std;
 int main()
  {
    char str[100],abb[40];
    int j=0;
    cout<<"Enter Full Name :-";
    cin.getline(str,30);
    for(int i=0;i<strlen(str);i++)
      {
       if(i==0){
         abb[j]=str[i];
         abb[++j]='.';
        }
       else if(str[i]==' '){
         abb[++j]=str[i+1];
         abb[++j]='.';
        }
       }
   cout<<"Abbreviation = "<<abb;
   return 0;
  }
Output:-









Post a Comment

0 Comments