Question
Hello I just need help with my code! I will post my solution below, please just edit based off of it. The most important thing
Hello I just need help with my code!
I will post my solution below, please just edit based off of it.
The most important thing here is that i need to add a function to convert my output into a triangle. I am unsure of how to do this, please explain your answer.
Expected output of string triangle:
Also, the only other issue I am having with it is just that though I use a while loop, it is not pausing to take in user input of whether they want to input another string or not and immediately just ask user to enter a new string. I used the PAUSE (defined constant), but this is not working so how do I fix this?
THANK YOU!!!!!!!!
****************************************************************************************************************************************
My solution:
#include
#define PAUSE system("pause") #define MAX 100
void inReverse(char userStr[]); void inVertical(char userStr[]);
int main(){ char choice; char userStr[MAX] = ""; int i; while (choice != 'no'){ printf("Please enter string: "); scanf ("%s", userStr); if (!isdigit(userStr[i])) { printf ("The string you entered is below:" ); printf (" Forward: %s", userStr); }else{ printf ("Your string contains an invalid value. Please re-enter a new string without any numeric values "); }
printf(" Backwards: "); inReverse(userStr); printf(" Vertical:" ); inVertical(userStr); printf(" Triangle: "); printf(" "); int length = strlen(userStr); printf(" Just so you know, the length of your string was: %d", length); printf(" Would you like to enter another string? yes or no?: "); PAUSE; } return 0; }
void inReverse(char userStr[]){ int length = strlen(userStr); int i; for (i = strlen(userStr)-1; i >= 0; i--){ printf("%c", userStr[i]); } }
void inVertical(char userStr[]){ int i; int length= strlen(userStr); for (i = 0; i
String triangle: a bc d e fghi jklmn
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started