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

Write a C++ program using pointers to do the following: 1. declare two strings a

ID: 3535701 • Letter: W

Question

Write a C++ program using pointers to do the following:

1. declare two strings

a. char inStr01[20];

b. char inStr02[20];

c. char inSrt03[40];

2. using cin, ask for and read something into inStr01 and inStr02

3. then….

a. Print out inStr01

b. Print out inStr02

c. Print the length of inStr01

d. Print the length of inStr02

e. Print the longer of the two strings

f. Concatenate inStr01, a space, and then inStr02

Into inStr03

g. Print out inStr03

Output should look like

First string xxxxxxxxxxx

Second string zzzzzzzzzzzzzzz

Length of 1st string is 11

Length of second string is 15

The longer string is zzzzzzzzzzzzzzz

The concatenation is xxxxxxxxxxx zzzzzzzzzzzzzzz

This is assuming inStr01 is xxxxxxxxxxx

This is assuming inStr02 is zzzzzzzzzzzzzzz

Explanation / Answer

#include<iostream.h>

#include<string.h>

void main()

{

int len1,len2;

char str1[30],str2[30],str3[60];

cout<<"enter 1 string ";

cin>>str1;

cout<<"enter 2 string ";

cin>>str2;

len1=strlen(str1);

len2=strlen(str2);

if(len1>len2)

cout<<"string 1 is longest "<<str1;

else

cout<<"string 2 is longest "<<str2;

strcat(str1," ");

strcpy(str3,str1);

strcat(str3,str2);

cout<<" string 3 is "<<str3;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote