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

Assume that the function strlen() does not exist. Your task is to code a functio

ID: 3625884 • Letter: A

Question

Assume that the function strlen() does not exist.



Your task is to code a function named myStrLen().



As a parameter, it takes a cstring and the maximum size of the cstring. It

returns the length of the cstring. The length is the number of ASCII

characters up to but not including the null terminator ('').



Syntax: int myStrLen(const char[], const int SIZE);



The program main() is coded below. Do not modify main().



Add your code after the TODO and between the // STUDENT CODE BEGINS and //

STUDENT CODE ENDS.



*/



#include

#include

#include

#include

using namespace std;







// to suppress warning warning C4996

#pragma warning( disable : 4996 )





int main()

{

// prototype

int myStrLen(const char[], const int SIZE);



// data declarations

const int SIZE = 81; // max size + 1 of cstring

char line[SIZE];



int stringLength; // length of cstring entered



// loop exit variable

string choice;



//

// program introduction

//

cout << "Wecome to myStrLen() ";

cout << "by ";

cout << "My program can determine the length of any valid cstring ";



//

// program loop

//

do

{

// input

cout << "Enter a word, phrase or sentence: ";

cin.getline(line, SIZE);



// processing

stringLength = myStrLen(line, SIZE);



// output

cout << "The string entered was: ";

cout << line;



cout << " The length of the string is: ";

cout << stringLength;

cout << endl;



//

// program loop

//

cout << " Repeat program(y/n)? ";

cin >> choice;

cin.ignore();



} while (choice == "Y" || choice == "y");



cout << "End of program...." << endl;

cin.get();



return 0;



}



/*-------------------------------------------------------------------



Function Name: myStrLen

Parameters: value:const char[]

SIZE:const int

Returns: number of ASCII chars up to null terminator



TODO: code your myStrLen() function below.

code the header line and complete body



-------------------------------------------------------------------*/



// STUDENT CODE BEGINS

















// STUDENT CODE ENDS





Explanation / Answer

please rate - thanks

message me if any problems


#include <iostream>
using namespace std;
// to suppress warning warning C4996
#pragma warning( disable : 4996 )
int main()
{
// prototype
int myStrLen(const char[], const int SIZE);
// data declarations
const int SIZE = 81; // max size + 1 of cstring
char line[SIZE];
int stringLength; // length of cstring entered
// loop exit variable
string choice;
//
// program introduction
//
cout << "Wecome to myStrLen() ";
cout << "by ";
cout << "My program can determine the length of any valid cstring ";
//
// program loop
//
do
{
// input
cout << "Enter a word, phrase or sentence: ";
cin.getline(line, SIZE);
// processing
stringLength = myStrLen(line, SIZE);
// output
cout << "The string entered was: ";
cout << line;
cout << " The length of the string is: ";
cout << stringLength;
cout << endl;
//
// program loop
//
cout << " Repeat program(y/n)? ";
cin >> choice;
cin.ignore();
}while (choice == "Y" || choice == "y");
cout << "End of program...." << endl;
cin.get();
return 0;
}
/*-------------------------------------------------------------------
Function Name: myStrLen
Parameters: value:const char[]
SIZE:const int
Returns: number of ASCII chars up to null terminator
TODO: code your myStrLen() function below.
code the header line and complete body
-------------------------------------------------------------------*/
// STUDENT CODE BEGINS

int myStrLen(const char a[], const int SIZE)
{int i;
for(i=0;i<SIZE,a[i]!='';i++);
return i;
}
// STUDENT CODE ENDS

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