Help me | Sololearn: Learn to code for FREE!
0

Help me

a. Write code c++ that defines a function that takes your full name as a parameter and returns the modified name with the abbreviation of the middle name only, as follows: input: Rami Yusuf Daraghma return: Rami Y. Daraghma b. Important notes to be considered in your solution: 1. do not use string library functions such as (strlen,strcpy,.., etc) 2. use char s[] to define the full name 3. do not use string class data type. 4. you can use gets_s() or getline to read the full name c. Write a test program that uses the function above on your full name and then repeat the function call on your friend's full name.

23rd Nov 2021, 3:58 PM
Dęęmā Jābī
Dęęmā Jābī - avatar
4 Answers
23rd Nov 2021, 4:08 PM
A͢J
A͢J - avatar
+ 3
char* modified(char* s) { char* m = new char; int j = 0; int f = 0; for(int i=0; i<50; i++) { if (f==0) { if (s[i]==' ') f=1; m[j] = s[i]; j++; } else if (f==1) { m[j] = s[i]; j++; m[j] = '.'; j++; f=2; } else if (f==2) { if (s[i]==' ') { m[j] = s[i]; j++; f=3; } } else { m[j] = s[i]; j++; } } return m; } https://code.sololearn.com/cC0M3BGCrM7w
23rd Nov 2021, 11:05 PM
SoloProg
SoloProg - avatar
+ 2
⭐Nakul Pasi S/0 Krishnalal Pasi⭐ Stop posting copy answer.
24th Nov 2021, 5:28 AM
A͢J
A͢J - avatar
+ 1
#include <iostream> using namespace std; void remove(char* s,int n) { for(int i=n;s[i]=NULL;i++) s[i]=s[i+1]; } void fun(char* s,int n) { for(int i=n;s[i]=NULL;i++) if() s[i+2]='.'; while(s[i]!='') i++; remove(s,i+); } int main() { char name[50]; cout<<"enter your full name:"; cin.getline(name,50,/n); cout<<"\n modifide name:"; cout<<fun(s,n)<<endl; return 0; }
23rd Nov 2021, 4:09 PM
Dęęmā Jābī
Dęęmā Jābī - avatar