Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Computing I -- COMP.1010 Honor Statement
- The practice of good ethical behavior is essential for maintaining
- good order in the classroom, providing an enriching learning
- experience for students, and as training as a practicing computing
- professional upon graduation. This practice is manifested in the
- University's Academic Integrity policy. Students are expected to
- strictly avoid academic dishonesty and adhere to the Academic
- Integrity policy as outlined in the course catalog. Violations
- will be dealt with as outlined therein.
- All programming assignments in this class are to be done by the
- student alone. No outside help is permitted except the instructor
- and approved tutors.
- I certify that the work submitted with this assignment is mine and
- was generated in a manner consistent with this document, the
- course academic policy on the course website on Blackboard, and
- the UMass Lowell academic code.
- Date: 11/20/2019
- Name: Jensen Packard
- */
- #include <stdio.h>
- void strInput(char str[], int numch);
- void reverseString(char str[], int numch);
- int main(int argc,char *argv[])
- {
- int numch = 80;
- char str[numch+1];
- printf("Please enter a string:\n");
- strInput(str, numch);
- reverseString(str, numch);
- return 0;
- }
- void strInput(char str[], int numch) {
- int i = 0;
- char in;
- while((in = getchar()) != '\n' && i <= (numch-1)) {
- str[i] = in;
- i++;
- }
- str[i] = '\0';
- printf("%s\n", str);
- }
- void reverseString(char str[], int numch)
- {
- int count = 0;
- for(int i = 0; i < 80; i++)
- {
- if (str[i] == '\0')
- {
- break;
- }
- ++count;
- }
- for(int x = 0; x < count/2; x++)
- {
- char hold = str[x];
- str[x] = str[count - x - 1];
- str[count - x - 1] = hold;
- }
- printf("%s\n", str);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement