1 of 22

CS0 101 : Computer Programming

Instructor

Dr. Bidyut Kr. Patra, Associate Professor

Department of Computer Science & Engineering

1

3/16/2023

2 of 22

How the courses are run?

  • There are 20 TAs, who are M.Tech and IDD students of the CSE dept.
  • TAs will primarily help you in the Lab. Part and Tutorial Classes.
  • Students in CSO 101 is divided into 10 sections.
  • Five sections will attend this course in this semester.

2

3/16/2023

3 of 22

Objectives

  • To give basic programming skills.
  • To give conceptual understanding of computers and their working.
  • At the end of the course the student is expected to write a moderately complex

C program.

3

3/16/2023

4 of 22

Evaluation Criteria (May be modified)

Theory (80%)

  • Mid Semester Exam : [30]
  • End Semester Exam : [40]
  • Assignment Sheet I /Quiz : [10]

Laboratory (20%):

  • Continuous Evaluation: [15]
  • Viva-voce: [5]

4

3/16/2023

5 of 22

Books and Course Page

  • You may follow any standard ANSI C book.

  • E. Balaguruswamy. Programming in ANCI C, Tata McGraw-Hill (8th Edition)

  • Brian W. Kernighan, ‎Dennis M. Ritchie. The C Programming Language, Prentice Hall (2nd Edition)

  • V. Rajaraman and Neeharika Adabela. Fundamentals of Computers, Eastern Economy Edition
  • Course Page
  • https://sites.google.com/site/patrabidyutkr/teachingiitbhu/cso-101-odd-semester2024-2025

5

3/16/2023

6 of 22

Lab. Part

  • Use only Linux/Ubuntu/Fedora Operating System.

Use ANSI C (Standard C).

  • A brief about the 1st exercise will be given towards the end of this class.

6

3/16/2023

7 of 22

Policies, Guidelines,…

  • Questions in the examinations will be from what will be taught in the classes.
  • Ask your doubts and questions to me. Do not discuss in the class with your friends.
  • Attendance for Lab. Part is important and will be counted.
  • Grading will be strictly according to your performance, attendance, etc.

7

3/16/2023

8 of 22

Introduction: Computer

  • A device basically meant to do computations.
  • A machine that can follow a sequence of instructions to accomplish a task.
  • Parts which physically does the execution are called Hardware.
  • The sequence of steps (instructions) can be called as Software.

8

3/16/2023

9 of 22

9

3/16/2023

  • Hardware: Keyboard, Mouse, Monitor, Printer, CPU,

Memory, etc.

  • Software: Set of programs, like –

OS: Interface between hardware & user.

Compiler: Translates from high level language to machine Language.

Tools: Internet access, Voice, Video, Games, etc.

Hardware and Software

10 of 22

Computer (Conceptually)

10

3/16/2023

11 of 22

An Example

Work to be done: Buy 1 kg Alu.

Sequence of Steps:

    • Take Bag, Money.
    • Go to Market.
    • Search for good Alu.
    • Buy 1kg Alu.
    • Go home.
    • Stop.

11

3/16/2023

12 of 22

A Model ( Human)

12

3/16/2023

  • Body 🡺 Hardware
  • Thinking Process (Mind) 🡺 Software

13 of 22

Early Computers

  • Fixed-program computer: Can do specific task(s) which is wired (fixed) into the hardware. E.g.: A Calculator.

Drawback: No flexibility

  • Stored-program computer: By creating an instruction set architecture and detailing the computation as a series of instructions (the program), the machine becomes much more flexible.

13

3/16/2023

14 of 22

Stored-Program Computers

  • Program is also seen as data.
  • Program is also stored in memory as data.
  • The ability to treat instructions as data is what makes assemblers, compilers and other automated programming tools possible.

14

3/16/2023

15 of 22

Von Neumann Architecture

15

3/16/2023

16 of 22

Are there other architectures?

  • Harvard architecture Stores program in a separate memory and data in a separate memory.
  • But, these are rarely used in general purpose computers.

16

3/16/2023

17 of 22

What you have to do?

  • Learn basic commands to work with the linux/Ubuntu operating system.
  • Learn vi editor. (This is a software tool which is used to create files, edit them).

17

3/16/2023

18 of 22

Your first lab exercise

  • Create a file named first.c whose contents should be:

  • #include<stdio.h>

int main()

{

printf(“ Hello IIT(BHU)”);

return 0;

}

18

3/16/2023

19 of 22

How to Run a Program

  • After you create the file whose name is first.c you need to compile this file to get executable file.
  • At the command prompt do
      • $ cc first.c
  • If the compilation is successful this gives a file called a.out
      • $ ./a.out
  • The above command executes it.

19

3/16/2023

20 of 22

Homework

  • Read some book on C language and understand first.c
  • In the lab the TAs will verify your programs, and they will ask you some questions related to your programs. You will be awarded some marks in alternative of the lab classes.
  • The lecture slides will be kept in a web site.

20

3/16/2023

21 of 22

Your 2nd lab exercise

  • Create a file named second.c whose contents should be:
  • #include<stdio.h>

int main( )

{

int a, b;

printf(“Enter an integer value for variable a:”);

scanf(“%d”, &a);

printf(“Enter an integer value for variable b:”);

scanf(“%d”, &b);

printf(“a+b = %d\n”, a+b);

return 0;

}

  • This will find sum of two integers.
  • Extend this to find their difference, product and division.

21

3/16/2023

22 of 22

Next Class …

  • Introduction to Languages, algorithms, etc.

22

3/16/2023