1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Serhud [2]
3 years ago
11

To inspire unit 1 App

Computers and Technology
1 answer:
Tasya [4]3 years ago
5 0
Is there more to this or ?
You might be interested in
Your team will write a function that reverses a C-string, to practice using pointers. You must use pointers and C-strings for th
Nutka1998 [239]

Answer:

Here is the C++ program:

#include <iostream> //to use input output functions

#include<string.h> // to manipulate strings

using namespace std; //to identify objects like cin cout

void ReverseString(char* original_str){ // function that reverses a C-string

       char* ptr1 = original_str;  // pointer that points to the start of C-string

       char* ptr2 = original_str; // pointer that points to the start of C-string initially

       for (int i = 0; i < strlen(original_str)- 1; i++) {//iterates through the length of the C-string

           ptr2++;} //moves ptr2 to the end of the C-string

       while(ptr1 < ptr2) {// swaps each character of C-string using pointers

               char temp = *ptr1; //declares a temp variable to hold character that *ptr1 points to

               *ptr1 = *ptr2;

               *ptr2 = temp;

               ptr1++; //increments ptr1 moving it forward

               ptr2--;   }} //decrements ptr2 moving it backwards

int main(){ //start of main() function

       char input_str[]="";  /// declare a C-string

       cout<<"Enter original string: "; //prompts user to enter a string

       cin>>input_str; // reads that C-string from user

       ReverseString(input_str); //calls function to revserse the input string

       cout<<"\nReversed string: "<<input_str;} // displays the reversed string

Explanation:

The program has a function ReverseString that takes a C-style string as parameter and reverses the string using pointers.

The ptr1 and ptr2 are pointers that initially point to the beginning of original string.

for (int i = 0; i < strlen(original_str)- 1; i++) this statement has a for loop that iterates through the original string and moves the ptr2 to point at the end or last character of the C-string. strlen() method is used to get the length of the C-string. At each iteration ptr2 moves one time forward until the last character of the C-string is reached.

while(ptr1 < ptr2) statement has a while loop that works as follows:

checks if ptr1 is less than ptr2. This evaluate to true because the index of first character that ptr1 points to is 0 and last character is 5 so 0<5. Hence the statements inside while loop execute which swaps the character of C-string from beginning and end index using ptr1 and ptr2. a temp variable is declated to hold character that *ptr1 points to.

For example

original_string = "xyz" Then temp = *ptr1; stores the character that *ptr1 points to i.e. 'x'

*ptr1 = *ptr2; This statement assigns the character that *ptr2 points to the *ptr1. Basically these pointers are used as indices to the C-string. So this means that the *ptr1 now stores the last character of the C-string that is pointed to by *ptr2. So *ptr1 = 'z'

*ptr2 = temp; This statement assigns the character that temp stores to the *ptr2. We know that temp contains the first character i.e 'x'. So *ptr2 = 'x'      

ptr1++; The ptr1 is incremented to 1. This means it moves one position ahead and now points to the second character of the C-string.

ptr2--; The ptr2 is decremented to 1. This means it moves one position backwards and now points to the second character of the C-string.

Now the while loop breaks because ptr1 < ptr2 condition evaluates to false.

So the original string is reversed using pointers. Hence the output is:

zyx

screenshot of the program along with its output is attached.

3 0
3 years ago
How exactly do you find the circumference by using C++ Programming? I really need a specific answer.
adelina 88 [10]

Answer:

C++ Program to Find Area and Circumference of a Circle

Area of Circle = PI X Radius X Radius. Where, Where PI is a constant which is equal to 22/7 or 3.141(approx)

Circumference or Circle = 2 X PI X Radius.

Circumference or Circle = PI X Diameter.

Explanation:

3 0
3 years ago
Directory servers from different vendors are synchronized through ________.
andriy [413]
With a little digging I've done, finding this question with different answers the one you want is D. none of the above
6 0
3 years ago
How do you change your username
Rasek [7]

Answer:

Google it, I can't send links, but the brainly faq link should show up

3 0
3 years ago
Read 2 more answers
Give an explanation of one network connection (it will every helpful​
charle [14.2K]

Answer:

WiFi, Ethernet, Broadband, Dial-up. Any of those.

Explanation:

Network connections are all different. Those listed are some of the many examples of network connections.

7 0
3 years ago
Other questions:
  • Plz answer these questions...those who give answer get the brainliest......hurry up..!!!​
    14·1 answer
  • Ned and mary ann are saving their files to a cd
    15·1 answer
  • Smart art can be used to create _____that highlights relationships betweeen two items
    8·2 answers
  • Pomógłbymi ktoś z takim zadaniem? C++
    8·1 answer
  • Who is a data base administrator
    12·1 answer
  • ______ is a type of computer software that is installed into devices such as printers, print servers, and various types of commu
    5·1 answer
  • Write a program in C/C++ to draw the following points: (0.0,0.0), (20.0,0.0), (20.0,20.0), (0.0,20.0) and (10.0,25.0). For this
    6·1 answer
  • Stephanie would like to know the average number of regular hours worked by her employees. In cell B11, create a formula using th
    8·1 answer
  • Which of the following is the best way to keep up with trends in your industry?
    8·1 answer
  • Public class Billing {
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!