206k views
0 votes
Write a c++ program that prints the intial letter of any name​

1 Answer

6 votes

Answer:

#include<iostream>

using namespace std;

int main(){

char str[20];

int i=0;

std::cout<<"Enter a name:" ;

cin>>str;

cout<<*str;

while(str[i]!='\0'){

if(str[i]==' '){

i++;

cin>>*(str+i);

}

i++;

}

return 0;

}

User Woggioni
by
5.3k points