Reference no: EM13677622
Strings
Learning Objectives and Outcomes
Develop a functional C program that implements a design and create a C program that declares and uses strings.
Required Setup and Tools
Standard computer lab with Pelles C and Microsoft Visio installed
Recommended Procedures
Task: Create a program to read and reverse a word.
Create a new project named "ReverseWord" and a new source file named "reverse.c". Create a main() function with the usual header and other supporting code. Add a declaration of a string variable named "word" that can hold at least 29 characters (plus the terminator). Add code to print a prompt and add a call to scanf() that reads a string into the variable word. For a hint on use of the scanf() function to read a string, see pages 451-453 of the textbook. Add another call to printf() that echoes the characters entered back to the output. Build and test the program.
Add a declaration of an int variable named "length." Then add a while loop that begins at the first character element of word and increments length while (word[length]!=0). Add a statement after the loop that prints the length found. Build and test your program, and verify that the proper length of the word is printed. Add a for loop that reverses the word. This can be accomplished as follows:
Start a loop iterator at the value 0.
Terminate the loop when the iterator is equal to (length+1)/2.
Add a char variable named temp.
In the loop, use the following statements to swap the characters in the string:
temp = word[i];
word[i] = word[length-i-1];
word[length-i-1] = temp;
Be sure to print the reversed word after exiting the for loop!
Build and test your program using at least three test cases. One test case should use a single-letter word such as "a". A second test case should use a word with an even number of letters, such as "even". A third test case should use a word with an odd number of letters, such as "odd".
Determine what must be the tension in wire
: Two wires are anchored at both ends. Wire 1 has a mass of 147 gram and a length of 9.2 meter. Determine what must be the tension in Wire 1 if its third harmonic is to equal the first overtone of Wire 2
|
Explain what would the effect be of non-zero acceleration
: One of the conditions for Uniform Circular Motion is that the acceleration be centripetal and directed toward the center of motion. Explain what would the effect be of non-zero acceleration parallel to the tangential velocity
|
Obtain the magnitude of the force
: A 1.20 T magnetic field points northeast. Obtain the magnitude of the force on a +0.55 C charge that is moving 11 m/s toward the north
|
Obtain the maximum voltage across the capacitor
: A charged capacitor with C = 690 uF is connected in series to an inductor that has L = 0.460 H and negligible resistance. obtain the maximum voltage across the capacitor
|
Develop a functional c program that implements a design
: Develop a functional C program that implements a design and create a C program that declares and uses strings.
|
Find what the magnitude of the tangential acceleration
: A flywheel with a radius of 0.260 meter starts from rest and accelerates with a constant angular acceleration of 0.750 rad/s2. Find the magnitude of the tangential acceleration, the radial acceleration, and the resultant acceleration of a point on i..
|
Determine how many turns must there be in the inductor
: In the USA, Line voltage is 120 Volt and is driven at 60 Hertz. (Rating is RMS voltage) you have a computer in your circuit that has an inductance of 5mH. Determine how many turns must there be in the inductor
|
Obtain how many electrons need to leave each object
: Two spherical objects with a mass of 8.99 kilogram each are located at a distance of 3.15 meter apart. Obtain how many electrons need to leave each object thus that the net force between them becomes zero
|
Create a simple bank account simulation
: Create a new project named "Accounts" and a new source file named "accounts.c". Enter the following skeleton program. The main() function has been implemented for you. There are four functions you will need to implement to complete the lab.
|