SlideShare a Scribd company logo

Using C++11- Write a function that takes a char array as an input para.docx

S
S

Using C++11: Write a function that takes a char array as an input parameter and reverses the string. The function should use two pointers, front and rear. The frontpointer should initially reference the first character in the string, and the rear pointer should initially reference the last character in the string. Reverse the string by swapping the characters referenced by front and rear, then increment front to point to the next character and decrement rear to point to the preceding character, and so on, until the entire string is reversed. Then, write a main function that takes a string as input from the user and prints the reversed string (using the above function). All input strings will be 100 characters or fewer. You must use pointers to reverse the array. If you use dynamic arrays (not required), you must delete all memory allocated to any dynamic arrays before the program ends. The program should print a string of text to the terminal before getting each line of input from the user. A session should look like one of the following examples (including whitespace and formatting), with possibly different numbers in the output: The strings printed by the program should include a newline at the end. Solution #include <iostream> #include <cstring> using namespace std; string reverse(char word[20]); int main() { char string[20]; cout<<\"enter a word: \"; cin>>string; string results = reverse(string); cout <<results; } string reverse(char word[20]) { char a=\'a\'; char b=\'b\'; char *front=&a; char *rear=&b; for (int i=0;i< (strlen(word)/2);i++) { front[0]=word[i]; rear[0]=word[strlen(word)-1-i]; word[i]=*rear; word[strlen(word)-1-i]=*front; } return word; } .

Using C++11- Write a function that takes a char array as an input para.docx

1 of 2
Download to read offline
Using C++11: Write a function that takes a char array as an input parameter and reverses the
string. The function should use two pointers, front and rear. The frontpointer should initially
reference the first character in the string, and the rear pointer should initially reference the last
character in the string. Reverse the string by swapping the characters referenced by front and
rear, then increment front to point to the next character and decrement rear to point to the
preceding character, and so on, until the entire string is reversed.
Then, write a main function that takes a string as input from the user and prints the reversed
string (using the above function). All input strings will be 100 characters or fewer.
You must use pointers to reverse the array.
If you use dynamic arrays (not required), you must delete all memory allocated to any dynamic
arrays before the program ends.
The program should print a string of text to the terminal before getting each line of input from
the user. A session should look like one of the following examples (including whitespace and
formatting), with possibly different numbers in the output:
The strings printed by the program should include a newline at the end.
Solution
#include <iostream>
#include <cstring>
using namespace std;
string reverse(char word[20]);
int main()
{
char string[20];
cout<<"enter a word: ";
cin>>string;
string results = reverse(string);
cout <<results;
}
string reverse(char word[20])
{
char a='a';
char b='b';
char *front=&a;
char *rear=&b;
for (int i=0;i< (strlen(word)/2);i++)
{
front[0]=word[i];
rear[0]=word[strlen(word)-1-i];
word[i]=*rear;
word[strlen(word)-1-i]=*front;
}
return word;
}
Ad

Recommended

Do the following problem- For assignment submission- use the format li (2).docx
Do the following problem- For assignment submission- use the format li (2).docxDo the following problem- For assignment submission- use the format li (2).docx
Do the following problem- For assignment submission- use the format li (2).docxwviola
 
please have the output look like as above and please write it in c lan.docx
please have the output look like as above and please write it in c lan.docxplease have the output look like as above and please write it in c lan.docx
please have the output look like as above and please write it in c lan.docxcgraciela1
 
In the C programming language only- you will write a program that gets.docx
In the C programming language only- you will write a program that gets.docxIn the C programming language only- you will write a program that gets.docx
In the C programming language only- you will write a program that gets.docxMichaelQEBMartinc
 
The ProgramYour program will be a line editor. A line editor is an.pdf
The ProgramYour program will be a line editor. A line editor is an.pdfThe ProgramYour program will be a line editor. A line editor is an.pdf
The ProgramYour program will be a line editor. A line editor is an.pdf4babies2010
 
Using the programming language C- In this assignment- you will write a.pdf
Using the programming language C- In this assignment- you will write a.pdfUsing the programming language C- In this assignment- you will write a.pdf
Using the programming language C- In this assignment- you will write a.pdfDaviddA7Paynez
 
Using the programming language C- In this assignment- you will write a.docx
Using the programming language C- In this assignment- you will write a.docxUsing the programming language C- In this assignment- you will write a.docx
Using the programming language C- In this assignment- you will write a.docxStewartZQKChapmana
 
In this assignment- you will write a program that gets a pattern strin.docx
In this assignment- you will write a program that gets a pattern strin.docxIn this assignment- you will write a program that gets a pattern strin.docx
In this assignment- you will write a program that gets a pattern strin.docxGordonpACKellyb
 
First program of C ( Complete Explanation )
First program of C ( Complete Explanation )First program of C ( Complete Explanation )
First program of C ( Complete Explanation )Rohit Singh
 

More Related Content

Similar to Using C++11- Write a function that takes a char array as an input para.docx

Data Structure.pdf
Data Structure.pdfData Structure.pdf
Data Structure.pdfMemeMiner
 
Functions of stdio conio
Functions of stdio   conio Functions of stdio   conio
Functions of stdio conio Bhavik Vashi
 
Create a Python function called countDiffs that takes two arguments- b.docx
Create a Python function called countDiffs that takes two arguments- b.docxCreate a Python function called countDiffs that takes two arguments- b.docx
Create a Python function called countDiffs that takes two arguments- b.docxmrichard5
 
Write a function in Assembly language that takes a value passed to it (1).docx
Write a function in Assembly language that takes a value passed to it (1).docxWrite a function in Assembly language that takes a value passed to it (1).docx
Write a function in Assembly language that takes a value passed to it (1).docxlez31palka
 
Assignment SpecificationsYou must implement a simplified version .docx
Assignment SpecificationsYou must implement a simplified version .docxAssignment SpecificationsYou must implement a simplified version .docx
Assignment SpecificationsYou must implement a simplified version .docxlynettearnold46882
 
There are two parts.1. Write code for a function that receives t.docx
There are two parts.1. Write code for a function that receives t.docxThere are two parts.1. Write code for a function that receives t.docx
There are two parts.1. Write code for a function that receives t.docxcroftsshanon
 
Create a C program that sorts a sequence of positive numbers using.docx
Create a C program that sorts a sequence of positive numbers using.docxCreate a C program that sorts a sequence of positive numbers using.docx
Create a C program that sorts a sequence of positive numbers using.docxbuffydtesurina
 
Sample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.SivakumarSample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.SivakumarSivakumar R D .
 
Create a C program that sorts a sequence of positive numbers using.docx
Create a C program that sorts a sequence of positive numbers using.docxCreate a C program that sorts a sequence of positive numbers using.docx
Create a C program that sorts a sequence of positive numbers using.docxvanesaburnand
 
Format string
Format stringFormat string
Format stringVu Review
 
This should be solved in the matrix.cpp file. Write a program which .docx
 This should be solved in the matrix.cpp file.  Write a program which .docx This should be solved in the matrix.cpp file.  Write a program which .docx
This should be solved in the matrix.cpp file. Write a program which .docxKomlin1
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingAMAN ANAND
 
Hello, I need help to to add modify the program to process as many t.pdf
Hello, I need help to to add modify the program to process as many t.pdfHello, I need help to to add modify the program to process as many t.pdf
Hello, I need help to to add modify the program to process as many t.pdfeyevision3
 
Input and output in c++
Input and output in c++Input and output in c++
Input and output in c++Asaye Dilbo
 
Use the program from Part 2 of Assignment 7 as your startin.pdf
Use the program from Part 2 of Assignment 7 as your startin.pdfUse the program from Part 2 of Assignment 7 as your startin.pdf
Use the program from Part 2 of Assignment 7 as your startin.pdfadityknits
 
LISP: Input And Output
LISP: Input And OutputLISP: Input And Output
LISP: Input And OutputLISP Content
 

Similar to Using C++11- Write a function that takes a char array as an input para.docx (20)

Data Structure.pdf
Data Structure.pdfData Structure.pdf
Data Structure.pdf
 
Functions of stdio conio
Functions of stdio   conio Functions of stdio   conio
Functions of stdio conio
 
Create a Python function called countDiffs that takes two arguments- b.docx
Create a Python function called countDiffs that takes two arguments- b.docxCreate a Python function called countDiffs that takes two arguments- b.docx
Create a Python function called countDiffs that takes two arguments- b.docx
 
Functions
FunctionsFunctions
Functions
 
Write a function in Assembly language that takes a value passed to it (1).docx
Write a function in Assembly language that takes a value passed to it (1).docxWrite a function in Assembly language that takes a value passed to it (1).docx
Write a function in Assembly language that takes a value passed to it (1).docx
 
Assignment SpecificationsYou must implement a simplified version .docx
Assignment SpecificationsYou must implement a simplified version .docxAssignment SpecificationsYou must implement a simplified version .docx
Assignment SpecificationsYou must implement a simplified version .docx
 
Function
FunctionFunction
Function
 
Input-output
Input-outputInput-output
Input-output
 
There are two parts.1. Write code for a function that receives t.docx
There are two parts.1. Write code for a function that receives t.docxThere are two parts.1. Write code for a function that receives t.docx
There are two parts.1. Write code for a function that receives t.docx
 
Create a C program that sorts a sequence of positive numbers using.docx
Create a C program that sorts a sequence of positive numbers using.docxCreate a C program that sorts a sequence of positive numbers using.docx
Create a C program that sorts a sequence of positive numbers using.docx
 
Sample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.SivakumarSample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.Sivakumar
 
Create a C program that sorts a sequence of positive numbers using.docx
Create a C program that sorts a sequence of positive numbers using.docxCreate a C program that sorts a sequence of positive numbers using.docx
Create a C program that sorts a sequence of positive numbers using.docx
 
Format string
Format stringFormat string
Format string
 
This should be solved in the matrix.cpp file. Write a program which .docx
 This should be solved in the matrix.cpp file.  Write a program which .docx This should be solved in the matrix.cpp file.  Write a program which .docx
This should be solved in the matrix.cpp file. Write a program which .docx
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Hello, I need help to to add modify the program to process as many t.pdf
Hello, I need help to to add modify the program to process as many t.pdfHello, I need help to to add modify the program to process as many t.pdf
Hello, I need help to to add modify the program to process as many t.pdf
 
Input and output in c++
Input and output in c++Input and output in c++
Input and output in c++
 
Use the program from Part 2 of Assignment 7 as your startin.pdf
Use the program from Part 2 of Assignment 7 as your startin.pdfUse the program from Part 2 of Assignment 7 as your startin.pdf
Use the program from Part 2 of Assignment 7 as your startin.pdf
 
LISP: Input And Output
LISP: Input And OutputLISP: Input And Output
LISP: Input And Output
 
LISP: Input And Output
LISP: Input And OutputLISP: Input And Output
LISP: Input And Output
 

More from slyndon

Use the table below to answer the following questions- A(4) ---------.docx
Use the table below to answer the following questions- A(4) ---------.docxUse the table below to answer the following questions- A(4) ---------.docx
Use the table below to answer the following questions- A(4) ---------.docxslyndon
 
Use the Table x y 1 1 2 1+2 3 1+2+4 4 1+2+4+8 a-Extend the t.docx
Use the Table  x y  1 1  2 1+2  3 1+2+4  4 1+2+4+8      a-Extend the t.docxUse the Table  x y  1 1  2 1+2  3 1+2+4  4 1+2+4+8      a-Extend the t.docx
Use the Table x y 1 1 2 1+2 3 1+2+4 4 1+2+4+8 a-Extend the t.docxslyndon
 
Use the redox table below to answer the following questions- a) Would.docx
Use the redox table below to answer the following questions- a) Would.docxUse the redox table below to answer the following questions- a) Would.docx
Use the redox table below to answer the following questions- a) Would.docxslyndon
 
Use the References to access important values if needed for this quest (4).docx
Use the References to access important values if needed for this quest (4).docxUse the References to access important values if needed for this quest (4).docx
Use the References to access important values if needed for this quest (4).docxslyndon
 
Use the References to access important values if needed for this quest.docx
Use the References to access important values if needed for this quest.docxUse the References to access important values if needed for this quest.docx
Use the References to access important values if needed for this quest.docxslyndon
 
Use the power method- in Matlab to determine the highest eigenvalue an.docx
Use the power method- in Matlab to determine the highest eigenvalue an.docxUse the power method- in Matlab to determine the highest eigenvalue an.docx
Use the power method- in Matlab to determine the highest eigenvalue an.docxslyndon
 
Use the MBR (nearest neighbor) technique to classify this wine- (use t.docx
Use the MBR (nearest neighbor) technique to classify this wine- (use t.docxUse the MBR (nearest neighbor) technique to classify this wine- (use t.docx
Use the MBR (nearest neighbor) technique to classify this wine- (use t.docxslyndon
 
Use the Hazen-Williams equation to compute friction loss with C-120- A.docx
Use the Hazen-Williams equation to compute friction loss with C-120- A.docxUse the Hazen-Williams equation to compute friction loss with C-120- A.docx
Use the Hazen-Williams equation to compute friction loss with C-120- A.docxslyndon
 
Use the four compounds below to answer the questions-Of the four chemi.docx
Use the four compounds below to answer the questions-Of the four chemi.docxUse the four compounds below to answer the questions-Of the four chemi.docx
Use the four compounds below to answer the questions-Of the four chemi.docxslyndon
 
Use the following information- a- Beginning cash balance on March 1- $.docx
Use the following information- a- Beginning cash balance on March 1- $.docxUse the following information- a- Beginning cash balance on March 1- $.docx
Use the following information- a- Beginning cash balance on March 1- $.docxslyndon
 
Use the following information to answer the next question- The followi.docx
Use the following information to answer the next question- The followi.docxUse the following information to answer the next question- The followi.docx
Use the following information to answer the next question- The followi.docxslyndon
 
Use the following information Prepare a cash budget for the month end.docx
Use the following information  Prepare a cash budget for the month end.docxUse the following information  Prepare a cash budget for the month end.docx
Use the following information Prepare a cash budget for the month end.docxslyndon
 
Use the following ERD for questions a- and b (a) when we create the p.docx
Use the following ERD for questions a- and b  (a) when we create the p.docxUse the following ERD for questions a- and b  (a) when we create the p.docx
Use the following ERD for questions a- and b (a) when we create the p.docxslyndon
 
Use the Factor Theorem to determine whether x - c is a factor of f- I.docx
Use the Factor Theorem  to determine whether x - c is a factor of f- I.docxUse the Factor Theorem  to determine whether x - c is a factor of f- I.docx
Use the Factor Theorem to determine whether x - c is a factor of f- I.docxslyndon
 
Use the below table to answer the following questions-Selling price -.docx
Use the below table to answer the following questions-Selling price -.docxUse the below table to answer the following questions-Selling price -.docx
Use the below table to answer the following questions-Selling price -.docxslyndon
 
Use strong induction to prove that T(n) O(log n) where T(1) - 10 and.docx
Use strong induction to prove that T(n)  O(log n) where T(1) - 10 and.docxUse strong induction to prove that T(n)  O(log n) where T(1) - 10 and.docx
Use strong induction to prove that T(n) O(log n) where T(1) - 10 and.docxslyndon
 
Use STROBE to analyze Annas written observations about Hy Perteks- Now.docx
Use STROBE to analyze Annas written observations about Hy Perteks- Now.docxUse STROBE to analyze Annas written observations about Hy Perteks- Now.docx
Use STROBE to analyze Annas written observations about Hy Perteks- Now.docxslyndon
 
Use SQL to Create a table with at least 4 attributes one of which is t.docx
Use SQL to Create a table with at least 4 attributes one of which is t.docxUse SQL to Create a table with at least 4 attributes one of which is t.docx
Use SQL to Create a table with at least 4 attributes one of which is t.docxslyndon
 
Use row reduction to determine all values of and for which the syste.docx
Use row reduction to determine all values of  and  for which the syste.docxUse row reduction to determine all values of  and  for which the syste.docx
Use row reduction to determine all values of and for which the syste.docxslyndon
 
Use RIMS to create and run a program as a solution to each of the two.docx
Use RIMS to create and run a program as a solution to each of the two.docxUse RIMS to create and run a program as a solution to each of the two.docx
Use RIMS to create and run a program as a solution to each of the two.docxslyndon
 

More from slyndon (20)

Use the table below to answer the following questions- A(4) ---------.docx
Use the table below to answer the following questions- A(4) ---------.docxUse the table below to answer the following questions- A(4) ---------.docx
Use the table below to answer the following questions- A(4) ---------.docx
 
Use the Table x y 1 1 2 1+2 3 1+2+4 4 1+2+4+8 a-Extend the t.docx
Use the Table  x y  1 1  2 1+2  3 1+2+4  4 1+2+4+8      a-Extend the t.docxUse the Table  x y  1 1  2 1+2  3 1+2+4  4 1+2+4+8      a-Extend the t.docx
Use the Table x y 1 1 2 1+2 3 1+2+4 4 1+2+4+8 a-Extend the t.docx
 
Use the redox table below to answer the following questions- a) Would.docx
Use the redox table below to answer the following questions- a) Would.docxUse the redox table below to answer the following questions- a) Would.docx
Use the redox table below to answer the following questions- a) Would.docx
 
Use the References to access important values if needed for this quest (4).docx
Use the References to access important values if needed for this quest (4).docxUse the References to access important values if needed for this quest (4).docx
Use the References to access important values if needed for this quest (4).docx
 
Use the References to access important values if needed for this quest.docx
Use the References to access important values if needed for this quest.docxUse the References to access important values if needed for this quest.docx
Use the References to access important values if needed for this quest.docx
 
Use the power method- in Matlab to determine the highest eigenvalue an.docx
Use the power method- in Matlab to determine the highest eigenvalue an.docxUse the power method- in Matlab to determine the highest eigenvalue an.docx
Use the power method- in Matlab to determine the highest eigenvalue an.docx
 
Use the MBR (nearest neighbor) technique to classify this wine- (use t.docx
Use the MBR (nearest neighbor) technique to classify this wine- (use t.docxUse the MBR (nearest neighbor) technique to classify this wine- (use t.docx
Use the MBR (nearest neighbor) technique to classify this wine- (use t.docx
 
Use the Hazen-Williams equation to compute friction loss with C-120- A.docx
Use the Hazen-Williams equation to compute friction loss with C-120- A.docxUse the Hazen-Williams equation to compute friction loss with C-120- A.docx
Use the Hazen-Williams equation to compute friction loss with C-120- A.docx
 
Use the four compounds below to answer the questions-Of the four chemi.docx
Use the four compounds below to answer the questions-Of the four chemi.docxUse the four compounds below to answer the questions-Of the four chemi.docx
Use the four compounds below to answer the questions-Of the four chemi.docx
 
Use the following information- a- Beginning cash balance on March 1- $.docx
Use the following information- a- Beginning cash balance on March 1- $.docxUse the following information- a- Beginning cash balance on March 1- $.docx
Use the following information- a- Beginning cash balance on March 1- $.docx
 
Use the following information to answer the next question- The followi.docx
Use the following information to answer the next question- The followi.docxUse the following information to answer the next question- The followi.docx
Use the following information to answer the next question- The followi.docx
 
Use the following information Prepare a cash budget for the month end.docx
Use the following information  Prepare a cash budget for the month end.docxUse the following information  Prepare a cash budget for the month end.docx
Use the following information Prepare a cash budget for the month end.docx
 
Use the following ERD for questions a- and b (a) when we create the p.docx
Use the following ERD for questions a- and b  (a) when we create the p.docxUse the following ERD for questions a- and b  (a) when we create the p.docx
Use the following ERD for questions a- and b (a) when we create the p.docx
 
Use the Factor Theorem to determine whether x - c is a factor of f- I.docx
Use the Factor Theorem  to determine whether x - c is a factor of f- I.docxUse the Factor Theorem  to determine whether x - c is a factor of f- I.docx
Use the Factor Theorem to determine whether x - c is a factor of f- I.docx
 
Use the below table to answer the following questions-Selling price -.docx
Use the below table to answer the following questions-Selling price -.docxUse the below table to answer the following questions-Selling price -.docx
Use the below table to answer the following questions-Selling price -.docx
 
Use strong induction to prove that T(n) O(log n) where T(1) - 10 and.docx
Use strong induction to prove that T(n)  O(log n) where T(1) - 10 and.docxUse strong induction to prove that T(n)  O(log n) where T(1) - 10 and.docx
Use strong induction to prove that T(n) O(log n) where T(1) - 10 and.docx
 
Use STROBE to analyze Annas written observations about Hy Perteks- Now.docx
Use STROBE to analyze Annas written observations about Hy Perteks- Now.docxUse STROBE to analyze Annas written observations about Hy Perteks- Now.docx
Use STROBE to analyze Annas written observations about Hy Perteks- Now.docx
 
Use SQL to Create a table with at least 4 attributes one of which is t.docx
Use SQL to Create a table with at least 4 attributes one of which is t.docxUse SQL to Create a table with at least 4 attributes one of which is t.docx
Use SQL to Create a table with at least 4 attributes one of which is t.docx
 
Use row reduction to determine all values of and for which the syste.docx
Use row reduction to determine all values of  and  for which the syste.docxUse row reduction to determine all values of  and  for which the syste.docx
Use row reduction to determine all values of and for which the syste.docx
 
Use RIMS to create and run a program as a solution to each of the two.docx
Use RIMS to create and run a program as a solution to each of the two.docxUse RIMS to create and run a program as a solution to each of the two.docx
Use RIMS to create and run a program as a solution to each of the two.docx
 

Recently uploaded

mean stack mean stack mean stack mean stack
mean stack mean stack  mean stack  mean stackmean stack mean stack  mean stack  mean stack
mean stack mean stack mean stack mean stackNuttavutThongjor1
 
Website Fixer-Upper Series to Boost your Online Presence
Website Fixer-Upper Series to Boost your Online PresenceWebsite Fixer-Upper Series to Boost your Online Presence
Website Fixer-Upper Series to Boost your Online PresenceSamantha Russell
 
UNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATION
UNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATIONUNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATION
UNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATIONSayali Powar
 
2.20.24 Asian Americans and the Myth of the Model Minority.pptx
2.20.24 Asian Americans and the Myth of the Model Minority.pptx2.20.24 Asian Americans and the Myth of the Model Minority.pptx
2.20.24 Asian Americans and the Myth of the Model Minority.pptxMaryPotorti1
 
Detailed Presentation on Human Rights(1).pptx
Detailed Presentation on Human Rights(1).pptxDetailed Presentation on Human Rights(1).pptx
Detailed Presentation on Human Rights(1).pptxDrOsiaMajeed
 
Intuition behind Monte Carlo Markov Chains
Intuition behind Monte Carlo Markov ChainsIntuition behind Monte Carlo Markov Chains
Intuition behind Monte Carlo Markov ChainsTushar Tank
 
Exit Essay - Save the Filipino Language by Renz Perez.docx
Exit Essay - Save the Filipino Language by Renz Perez.docxExit Essay - Save the Filipino Language by Renz Perez.docx
Exit Essay - Save the Filipino Language by Renz Perez.docxMYDA ANGELICA SUAN
 
D.pharmacy Pharmacology 4th unit notes.pdf
D.pharmacy Pharmacology 4th unit notes.pdfD.pharmacy Pharmacology 4th unit notes.pdf
D.pharmacy Pharmacology 4th unit notes.pdfSUMIT TIWARI
 
HOW TO DEVELOP A RESEARCH PROPOSAL (FOR RESEARCH SCHOLARS)
HOW TO DEVELOP A RESEARCH PROPOSAL (FOR RESEARCH SCHOLARS)HOW TO DEVELOP A RESEARCH PROPOSAL (FOR RESEARCH SCHOLARS)
HOW TO DEVELOP A RESEARCH PROPOSAL (FOR RESEARCH SCHOLARS)Rabiya Husain
 
Grantseeking Solo- Securing Awards with Limited Staff PDF.pdf
Grantseeking Solo- Securing Awards with Limited Staff  PDF.pdfGrantseeking Solo- Securing Awards with Limited Staff  PDF.pdf
Grantseeking Solo- Securing Awards with Limited Staff PDF.pdfTechSoup
 
Media Relations for Public Relations Class
Media Relations for Public Relations ClassMedia Relations for Public Relations Class
Media Relations for Public Relations ClassCorinne Weisgerber
 
The Ministry of Utmost Happiness by Arundhati Roy
The Ministry of Utmost Happiness by Arundhati RoyThe Ministry of Utmost Happiness by Arundhati Roy
The Ministry of Utmost Happiness by Arundhati RoyTrushali Dodiya
 
IR introduction Introduction, Principle & Theory
IR introduction Introduction, Principle & TheoryIR introduction Introduction, Principle & Theory
IR introduction Introduction, Principle & Theorynivedithag131
 
UniSC Fraser Coast library self-guided tour
UniSC Fraser Coast library self-guided tourUniSC Fraser Coast library self-guided tour
UniSC Fraser Coast library self-guided tourUSC_Library
 
UniSC Sunshine Coast library self-guided tour
UniSC Sunshine Coast library self-guided tourUniSC Sunshine Coast library self-guided tour
UniSC Sunshine Coast library self-guided tourUSC_Library
 
The Institutional Origins of Canada’s Telecommunications Mosaic
The Institutional Origins of Canada’s Telecommunications MosaicThe Institutional Origins of Canada’s Telecommunications Mosaic
The Institutional Origins of Canada’s Telecommunications MosaicUniversity of Canberra
 
SOCIAL JUSTICE LESSON ON CATCH UP FRIDAY
SOCIAL JUSTICE LESSON ON CATCH UP FRIDAYSOCIAL JUSTICE LESSON ON CATCH UP FRIDAY
SOCIAL JUSTICE LESSON ON CATCH UP FRIDAYGloriaRamos83
 
50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...
50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...
50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...Nguyen Thanh Tu Collection
 
Writing Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdf
Writing Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdfWriting Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdf
Writing Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdfMr Bounab Samir
 

Recently uploaded (20)

mean stack mean stack mean stack mean stack
mean stack mean stack  mean stack  mean stackmean stack mean stack  mean stack  mean stack
mean stack mean stack mean stack mean stack
 
Website Fixer-Upper Series to Boost your Online Presence
Website Fixer-Upper Series to Boost your Online PresenceWebsite Fixer-Upper Series to Boost your Online Presence
Website Fixer-Upper Series to Boost your Online Presence
 
UNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATION
UNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATIONUNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATION
UNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATION
 
2.20.24 Asian Americans and the Myth of the Model Minority.pptx
2.20.24 Asian Americans and the Myth of the Model Minority.pptx2.20.24 Asian Americans and the Myth of the Model Minority.pptx
2.20.24 Asian Americans and the Myth of the Model Minority.pptx
 
Detailed Presentation on Human Rights(1).pptx
Detailed Presentation on Human Rights(1).pptxDetailed Presentation on Human Rights(1).pptx
Detailed Presentation on Human Rights(1).pptx
 
Intuition behind Monte Carlo Markov Chains
Intuition behind Monte Carlo Markov ChainsIntuition behind Monte Carlo Markov Chains
Intuition behind Monte Carlo Markov Chains
 
Exit Essay - Save the Filipino Language by Renz Perez.docx
Exit Essay - Save the Filipino Language by Renz Perez.docxExit Essay - Save the Filipino Language by Renz Perez.docx
Exit Essay - Save the Filipino Language by Renz Perez.docx
 
D.pharmacy Pharmacology 4th unit notes.pdf
D.pharmacy Pharmacology 4th unit notes.pdfD.pharmacy Pharmacology 4th unit notes.pdf
D.pharmacy Pharmacology 4th unit notes.pdf
 
HOW TO DEVELOP A RESEARCH PROPOSAL (FOR RESEARCH SCHOLARS)
HOW TO DEVELOP A RESEARCH PROPOSAL (FOR RESEARCH SCHOLARS)HOW TO DEVELOP A RESEARCH PROPOSAL (FOR RESEARCH SCHOLARS)
HOW TO DEVELOP A RESEARCH PROPOSAL (FOR RESEARCH SCHOLARS)
 
Grantseeking Solo- Securing Awards with Limited Staff PDF.pdf
Grantseeking Solo- Securing Awards with Limited Staff  PDF.pdfGrantseeking Solo- Securing Awards with Limited Staff  PDF.pdf
Grantseeking Solo- Securing Awards with Limited Staff PDF.pdf
 
Media Relations for Public Relations Class
Media Relations for Public Relations ClassMedia Relations for Public Relations Class
Media Relations for Public Relations Class
 
The Ministry of Utmost Happiness by Arundhati Roy
The Ministry of Utmost Happiness by Arundhati RoyThe Ministry of Utmost Happiness by Arundhati Roy
The Ministry of Utmost Happiness by Arundhati Roy
 
Capter 5 Climate of Ethiopia and the Horn GeES 1011.pdf
Capter 5 Climate of Ethiopia and the Horn GeES 1011.pdfCapter 5 Climate of Ethiopia and the Horn GeES 1011.pdf
Capter 5 Climate of Ethiopia and the Horn GeES 1011.pdf
 
IR introduction Introduction, Principle & Theory
IR introduction Introduction, Principle & TheoryIR introduction Introduction, Principle & Theory
IR introduction Introduction, Principle & Theory
 
UniSC Fraser Coast library self-guided tour
UniSC Fraser Coast library self-guided tourUniSC Fraser Coast library self-guided tour
UniSC Fraser Coast library self-guided tour
 
UniSC Sunshine Coast library self-guided tour
UniSC Sunshine Coast library self-guided tourUniSC Sunshine Coast library self-guided tour
UniSC Sunshine Coast library self-guided tour
 
The Institutional Origins of Canada’s Telecommunications Mosaic
The Institutional Origins of Canada’s Telecommunications MosaicThe Institutional Origins of Canada’s Telecommunications Mosaic
The Institutional Origins of Canada’s Telecommunications Mosaic
 
SOCIAL JUSTICE LESSON ON CATCH UP FRIDAY
SOCIAL JUSTICE LESSON ON CATCH UP FRIDAYSOCIAL JUSTICE LESSON ON CATCH UP FRIDAY
SOCIAL JUSTICE LESSON ON CATCH UP FRIDAY
 
50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...
50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...
50 ĐỀ THI THỬ TỐT NGHIỆP THPT TIẾNG ANH 2024 CÓ GIẢI CHI TIẾT - GIỚI HẠN KHO...
 
Writing Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdf
Writing Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdfWriting Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdf
Writing Agony Letter & If type O+1 & Diphthongs + Text “Arab Science”.pdf
 

Using C++11- Write a function that takes a char array as an input para.docx

  • 1. Using C++11: Write a function that takes a char array as an input parameter and reverses the string. The function should use two pointers, front and rear. The frontpointer should initially reference the first character in the string, and the rear pointer should initially reference the last character in the string. Reverse the string by swapping the characters referenced by front and rear, then increment front to point to the next character and decrement rear to point to the preceding character, and so on, until the entire string is reversed. Then, write a main function that takes a string as input from the user and prints the reversed string (using the above function). All input strings will be 100 characters or fewer. You must use pointers to reverse the array. If you use dynamic arrays (not required), you must delete all memory allocated to any dynamic arrays before the program ends. The program should print a string of text to the terminal before getting each line of input from the user. A session should look like one of the following examples (including whitespace and formatting), with possibly different numbers in the output: The strings printed by the program should include a newline at the end. Solution #include <iostream> #include <cstring> using namespace std; string reverse(char word[20]); int main() { char string[20]; cout<<"enter a word: "; cin>>string; string results = reverse(string);
  • 2. cout <<results; } string reverse(char word[20]) { char a='a'; char b='b'; char *front=&a; char *rear=&b; for (int i=0;i< (strlen(word)/2);i++) { front[0]=word[i]; rear[0]=word[strlen(word)-1-i]; word[i]=*rear; word[strlen(word)-1-i]=*front; } return word; }