Introduction
In this lab, you will learn how to write a C program to reverse a given string. The program will take input from the user, reverse the string and output the result to the console. This concept can be used to check if a string is a palindrome, because a palindrome string will have the same value even after we reverse it.
Note: You need to create the file ~/project/main.c
yourself to practice coding and learn how to compile and run it using gcc.
cd ~/project
## create main.c
touch main.c
## compile main.c
gcc main.c -o main
## run main
./main
Skills Graph
%%%%{init: {'theme':'neutral'}}%%%%
flowchart RL
c(("`C`")) -.-> c/UserInteractionGroup(["`User Interaction`"])
c(("`C`")) -.-> c/BasicsGroup(["`Basics`"])
c(("`C`")) -.-> c/ControlFlowGroup(["`Control Flow`"])
c(("`C`")) -.-> c/FunctionsGroup(["`Functions`"])
c/UserInteractionGroup -.-> c/output("`Output`")
c/BasicsGroup -.-> c/variables("`Variables`")
c/BasicsGroup -.-> c/data_types("`Data Types`")
c/BasicsGroup -.-> c/operators("`Operators`")
c/ControlFlowGroup -.-> c/while_loop("`While Loop`")
c/ControlFlowGroup -.-> c/for_loop("`For Loop`")
c/UserInteractionGroup -.-> c/user_input("`User Input`")
c/FunctionsGroup -.-> c/function_parameters("`Function Parameters`")
c/FunctionsGroup -.-> c/function_declaration("`Function Declaration`")
subgraph Lab Skills
c/output -.-> lab-123323{{"`Reverse a String Program`"}}
c/variables -.-> lab-123323{{"`Reverse a String Program`"}}
c/data_types -.-> lab-123323{{"`Reverse a String Program`"}}
c/operators -.-> lab-123323{{"`Reverse a String Program`"}}
c/while_loop -.-> lab-123323{{"`Reverse a String Program`"}}
c/for_loop -.-> lab-123323{{"`Reverse a String Program`"}}
c/user_input -.-> lab-123323{{"`Reverse a String Program`"}}
c/function_parameters -.-> lab-123323{{"`Reverse a String Program`"}}
c/function_declaration -.-> lab-123323{{"`Reverse a String Program`"}}
end