Class 1
Class 1
1 Getting started
The rst agenda is to get a system ready.
Windows → VS
1.2 Editor
2. To run the program, open up a terminal, go to the location of the program and then type:
gcc yourprogramname.c
Solve-a-problem Express solution as an algorithm and then develop program to implement that
algorithm.
Levels of languages
binary numbers that corresponded directly to specic machine instructions and locations in the
memory
↓
symbolic names referring to actions or locations
↓
abstract instruction/statements converted to specic machine instructions or locations
Compiler analyzes a program developed in a particular computer language and then translates it
into a form that is suitable for execution on your particular computer system.
1
First Piece of Code
1. Open terminal
(a) ls: The ls command will show you ('list') the les in your current directory. Used with
certain options, you can see sizes of les, when les were made, and permissions of les.
Example: "ls ~" will show you the les that are in your home directory.
(b) cd: The cd command will allow you to change directories. When you open a terminal
you will be in your home directory. To move around the le system you will use cd.
Examples:
iv. To navigate to the previous directory (or back), use "cd -"
v. To navigate through multiple levels of directory at once, specify the full directory
path that you want to go to. For example, use, "cd /var/www" to go directly to the
/www subdirectory of /var/. As another example, "cd ~/Desktop" will move you to
the Desktop subdirectory inside your home directory.
#i n c l u d e < s t d i o . h>
2
int main ( void ) {
printf ( " your_Here \ n " ) ;
return 0;
}
#i n c l u d e < s t d i o . h>
return 0;
}
2. gcc nonsense.c
3. When the compiler compiles and links your program, it creates an executable version of your
program. Using the GNU or standard C compiler, this program is called a.out by default.
Under Windows, it is often called a.exe instead.
2. ./a.out
1. #i n c l u d e < s t d i o . h>
→tells the compiler to include information about the standard input/output library.
(b) Main →is special. Your program starts executing here. Every program should have
one.
i. some that we write, others from the libraries. e.g. the openCV library has lot of
image processing functions: like for copying an image.
3
(a) paranthesis after the function name gives the argument list.
(a) →dene an integer function named main that receives NO argument values.
5. The statement: