Goal of this assignment: To be able to 1) install software, 2) use vi editor, 3) use gcc compiler, and 4) use basic UNIX based folder navigation commands.
- Every student should be able to download and install a software system. You will need to install software that allows us to compile and run the C program written by us.
a.If you have a Windows system do the following.
- Install Cygwin on your system. You may follow https://cygwin.com/install.html . Ensure that you have selected some
lynx, wget, curl, tar, bash-completion, vim, tmux, git, diffutils, make, gcc-c, gcc-c++, gcc-fortran, openssh
- Familiarize yourself with the vi commands by experimenting on your system.
- If you have a Mac system do the following.
- Invoke your terminal This link shows how to use the terminal http://www.macworld.co.uk/feature/mac-software/get-more-out-of-os-x-
- Install gcc if it is not available.
c.If you have a Linux system, do the following.
- gcc is usually available on any Linux system. Install it if it is not available.
- On your computer, create and edit welcome.c file as shown below. Compile/link the program using gcc, run the generated program. NOTE DON” T copy and paste the welcome.c but type the program yourself using all of the vi commands. You must familiarize yourself with the vi editor.
// Name: Your name here
// Section: Your section here
- Purpose of program:
- This program is a demo program to understand the basics of
- how to create a c file, edit it, save it, compile it and
- execute it.
- Function main begins program execution int main(void)
ID = 4518;
shipweight = 24.625f;
//Initialize Shipping weight
- display the string printf(” Welcome to C\n”);
//display contents of variables printf(“The ID of the item is %d\n”, ID);
printf(“The shipping weight of the item is %0.3f\n”, shipweight);
//We have to return
} // end function main
To compile and link your source code program in the file named welcome.c in your current directory, using the following command:
gcc –o executableFileName welcome.c
where executableFileName is the file name for the executable program generated from welcome.c
To run your executable program, use the following command:
- During the lab session, install Cygwin and gcc on the lab computer. Work on question 2 again using the Cygwin environment. Enter the welcome.c program code using vi editor. Demonstrate to your Lab TA, your work for question 2.
- Write a C program that displays the following information on the screen/display. Also demonstrate how an executable program is obtained during lab session. Please ensure that you have adequate comments including the header section and comments around code.
I hear and I forget.
I see and I remember.
I do and I understand.