0% found this document useful (0 votes)
31 views4 pages

Class 1

The document serves as an introduction to C programming for students at the National Institute of Technology Calicut. It outlines the necessary system setup, including recommended software for Ubuntu and Windows, and provides a basic overview of programming concepts, including algorithms, compilers, and the structure of a simple C program. Additionally, it includes instructions for writing, compiling, and running a basic C program using the terminal.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views4 pages

Class 1

The document serves as an introduction to C programming for students at the National Institute of Technology Calicut. It outlines the necessary system setup, including recommended software for Ubuntu and Windows, and provides a basic overview of programming concepts, including algorithms, compilers, and the structure of a simple C program. Additionally, it includes instructions for writing, compiling, and running a basic C program using the terminal.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

EC2025E INTRODUCTION TO C PROGRAMMING

Department of Electronics and Communication Engineering


National Institute of Technology Calicut
Winter 202425
Class 1

1 Getting started
The rst agenda is to get a system ready.

1.1 System suggested

ˆ Ubuntu 24.04 → Install gcc, g++, vscode

ˆ Windows → VS

1.2 Editor

1. gedit will do the job in Ubuntu. Save the work as yourprogramname.c

2. To run the program, open up a terminal, go to the location of the program and then type:
gcc yourprogramname.c

1.3 What is all this?

Program Collection of the instructions necessary to solve a specic problem.

Algorithm Method that is used to solve the problem.

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

2. Go to your directory using cd

(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:

i. To navigate into the root directory, use "cd /"

ii. To navigate to your home directory, use "cd" or "cd ~"

iii. To navigate up one directory level, use "cd .."

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.

3. gedit, and then type the following:

#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>

int main ( void ) {

printf ( " your_Here \ n " ) ;

return 0;
}

Both the above are same.

Compiling your program

1. Save in gedit as: nonsense.c

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.

Running your program

1. type a.out in terminal or,

2. ./a.out

What just happened?

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.

2. Function →contains statements that specify the computing operations

(a) You can give any name to your function

(b) Main →is special. Your program starts executing here. Every program should have
one.

(c) Main will call other functions.

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. Arguments →method of communicating data between functions. List of values.

3
(a) paranthesis after the function name gives the argument list.

4. The big one:

int main ( void ){

(a) →dene an integer function named main that receives NO argument values.

(b) statements of main are enclosed within braces.

(c) return 0, since main is an integer.

5. The statement:

printf ( " yourNonsenseHere \n " ) ;

→ main calls library function printf  to print sequence of characters.

(a) \n is the newline character. use it to go to next line.

(b) yourNonsenseHere is a character string or string constant.

You might also like