Question
Hi guys, I need help with my code. My xcode tells me Build Failed and I dont know what I'm doing wrong. I just need
Hi guys,
I need help with my code. My xcode tells me "Build Failed" and I dont know what I'm doing wrong. I just need a second pair of eyes to look over this. This is for c programming.
Here the assignment:
You are to DESIGN and WRITE a short program that will:
- Allow the user to enter a string with up to 100 letters.
- The program will display the string:
- Forward
- Backward
- Vertical
- As a triangle made from the letters of the string
- The program will display the number of letters in the string.
- Once everything above was displayed, the program will ask the user if he or she wishes to enter a different string or quit.
YOU CANNOT
- Use global variables, in this or any program ever.
- Use goto statement(s) , in this or any program ever.
Here my Code:
#include
#include
int main(){
int num = 1;
char str[100];
int r,j,k;
while (num==1){
printf("enter word");
scanf("%s", &str);
print("forword ");
printf("%s", str);
printf("backward");
for (r = 0; str[r]!='\0'; ++r){
for (j = r -1; j >=0; r--) {
printf("%c", str[j]);
}
}
printf("vertical");
for (j = 0; str[j]!='\0'; j++) {
printf("%c ", str[j]);
}
printf("triangle");
for (j=1; j <= r; j++) {
for (int k =0; k < j; k++) {
printf("%c", str[k]);
}
printf(" ");
}
printf("NO. of letter in the string: %d", r);
printf("leave?: ");
scanf("%d",&num);
}
return 0;
}
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