Welcome to the DS Lab, where we explore the world of data structures and their applications. Data structures provide a way to organize and store related variables in a structured manner. In this lab, we will dive into different data structures and understand how they can be used effectively.
Structures, also known as structs, allow us to group multiple related variables into a single unit. Each variable within a structure is referred to as a member. By organizing variables in this way, we can create more organized and modular code structures.
Linux is a developer's paradise, offering an open-source operating system with free programming tools for various programming languages. In this article, we will guide you through writing, compiling, and running a simple C program on Ubuntu Linux. This foundational knowledge will serve as a stepping stone for more complex and useful C programs that you can develop and run on Linux.
While we have tested the steps and commands on an Ubuntu 22.04 LTS system, they should work the same on other versions such as Ubuntu 20.04 or Debian 11.
To compile C programs on Linux, we will utilize the command-line tool called the terminal. You can open the terminal by using the Ubuntu Dash or pressing the key combination Ctrl+Alt+T.
Before you can compile and execute a C program, you need to ensure that the essential packages are installed on your system. To do this, enter the following command in your Linux Terminal as the root user:
$ sudo apt-get install build-essentialNow that you have the necessary packages installed, it's time to write your first C program. Use a text editor of your choice to create a new file and write your C code.
To compile your C program, use the GCC (GNU Compiler Collection) compiler. In the Terminal, enter the following command to generate an executable version of your program:
Syntax:
$ gcc [programName].c -o programNameOnce your C program is compiled successfully, you can proceed to run it. Use the following syntax to execute the compiled C program:
$ ./programNameReplace programName with the name you provided during compilation.
By following these steps, you can write, compile, and run C programs on Linux. This knowledge will lay the foundation for exploring more complex algorithms and data structures in the DS Lab.
Feel free to experiment with different C programs, explore various data structures, and enhance your programming skills. Happy coding in the DS Lab!