Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Develop a flowchart and then write a C++ program to print the initials of your f

ID: 3668123 • Letter: D

Question

Develop a flowchart and then write a C++ program to print the initials of your first name and the last name in the middle of the screen in a block format.

For example, if I use the letter I as my first initial and the letter H as my last initial, the output will be appear as (you need to center this):

IIIIIIIIII        H        H

    II            H        H

    II            H        H       

    II            HHHHHHHHHH

    II            H        H

    II            H        H

    II            H        H

IIIIIIIIII II     H        H HH

The specification of the initials is: Height is 8 characters and width is 10 characters. These are minimums and you can increase them. Note the two characters after each initial.

Please show an example if possible. It would be greatly appreciated

Explanation / Answer

Here i explained two example program in C++ program to accept your name and print initials for your reference.

#1:

#include<iostream.h>

#include<stdio.h>

#include<conio.h>

void main()

{

clrscr();

char arr[40];

cout<<"Enter The Name "<<endl;

gets(arr);

cout<<arr[0]<<".";

for(int i=0;arr[i]!='';i++)

{

if(arr[i]==' ')

{

cout<<arr[i+1]<<".";

i++;

}

}

if(arr[i]=='')

{

for(;arr[i]!=' ';i--);

cout<<"";

i++;

for(;arr[i]!='';i++)

{cout<<arr[i];}

}

getch();

}

Output

Enter The Name
Vignesh Rama Krishnamurthy

V.R.Krishnamurthy

Logic:

first print the first character by cout<<arr[0] and a dot by cout<<"." Then a loop runs till end of string and if it finds space, the next character is printed and a dot is printed. So in the above exmple if we input Vignesh Rama Krishnamurthy, the output is V.R.K. Now a loop runs in array to go back till it finds a space. Then the statement cout<<" at line 22 erases 2 characters backside. It erases "G." Now a loop again runs from next character of the the last space till the end of the string. In our example it starts from K and prints Krishnamurthy.

#2.