[go: up one dir, main page]

0% found this document useful (0 votes)
12 views19 pages

Class02

The document covers the fundamentals of computer programming, including the importance of algorithms and problem-solving techniques. It explains the physical components of a computer, the nature of programming languages, and the role of compilers and interpreters. Additionally, it discusses the use of Linux with the C programming language and provides a simple example of a C program.

Uploaded by

sanjaysr292617
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)
12 views19 pages

Class02

The document covers the fundamentals of computer programming, including the importance of algorithms and problem-solving techniques. It explains the physical components of a computer, the nature of programming languages, and the role of compilers and interpreters. Additionally, it discusses the use of Linux with the C programming language and provides a simple example of a C program.

Uploaded by

sanjaysr292617
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/ 19

RECALL FROM LAST CLASS

• Course plan
• The necessity of learning Computer Programming
• Computer is a Machine to solve problems
• Defined a problem
• Steps to solve a problem
• Different types of problem
HOW TO SELECT THE BEST
DESIGN/ALGORITHM?

• What does “the best algorithm” mean?


• Measures of efficiency
• With reference to space & Time
• Which takes minimum time/minimum memory
PROBLEM SOLVING USING
COMPUTER AND THE BASIC
COMPONENTS OF COMPUTER
COMPUTER –PHYSICAL COMPONENTS
• Central Processing Unit (CPU)
• Monitor
• Keyboard/Mouse
• What all are there in CPU?
• Processor (m/c)
• Arithmetic/Logic Unit
• Memory unit
PHYSICAL COMPONENTS OF A COMPUTER
PHYSICAL COMPONENTS:
PROCESSOR & ALU
MEMORY: RAM & ROM
IS COMPUTER INTELLIGENT THAN US?
• Does computer can do anything?
• Is there any problem which can not be solved by a
computer?
• Computer is a dumb machine which does what we
instruct it to do.
• It does not do anything other than what we instruct it to
do
• Suppose we want to solve a problem, how do we
tell/instruct the computer ?
HOW DO WE INSTRUCT THE COMPUTER?

• We write set of instructions(program/code) in a


programming language like C
• What is a programming language?
• It is a large set of instructions written by somebody
else
• Eg: C is a large set of instructions written/developed
by Dennis Ritchie at AT&T Bell Laboratories in the
early 1970s
COMPUTER - A DUMB MACHINE
• A machine can understand only switch off and switch on
states
• Similarly computer also knows only
– 0 (switch-off)
– 1 (switch-on)
– ie. binary (two) language
• Earlier times, there were only machine level languages
– ie. collection of 0’s and 1’s
• Programmers have to write their program in a binary
language
• Disadvantages : - Very tedious to write & error prone.
– So, how to make it easy?
ASSEMBLY LANGUAGE
• Another language which uses symbolic names instead of
binary numbers
• Who converts the assembly language to machine level
language?
• Assembler is a program (set of instructions) which
converts assembly language to machine level language
– eg: 8085/8086/MASM
• Disadvantages of assembly language: The instructions in
assembly language differs from machine to machine.
– Hence, the assembly language is not portable.
• How to make it better?
HIGHER LEVEL LANGUAGE

• Language which are not machine dependent


• Advantages: Easy for the programmer, portability
– Examples of higher level languages:
• FORTRAN, C, C++, JAVA, Python, R, Go, etc.
• Who converts higher level language to the form
which computer can understand?
• Compiler : A program which does this conversion
• Interpreter : Line by line conversion
COMPILERS vs INTERPRETERS
Compiler Interpreter

Converts the whole program Converts line by line


Faster Slower
Debugging difficult than interpreter Debugging easy

Eg.: Fortran, C, C++ Eg.: BASIC, Python


OPERATING SYSTEM(OS)

• Another Program
• Controls the entire operation of a computer system
• What are the operations/activities done on a computer?
– Movies/ Music/ Games/ Programming in C
• Examples of Operating systems
• Windows
• Unix/Linux
• Mac OS
• We use Linux with C
WHY DO WE USE LINUX WITH C?

• Linux is a type of Unix OS


• Unix was written primarily in C language
• Very few assumptions on the machine
• It is easy to use Unix or its variants such as Redhat/
Fedora/ SuSe/ Ubuntu in any machine
• Linux & C are portable, good companions
HOW DO WE SOLVE A PROBLEM USING
COMPUTER?
• Problem:
– Print the sentence “C is a nice programming language.”
• Only one step:
– Print the sentence
• What all we have to do?
• Write the step in C Language (Edit it )
• Convert it into a form which the machine can understand
(Compile)
• Obtain the output (Execute)
C PROGRAM TO PRINT
“C IS A NICE PROGRAMMING LANGUAGE.”

#include <stdio.h>
main()
{
printf(“C is a nice programming language”);
}

stdio.h is a standard library file written by the developers


of C language which helps in printing the statement
Thank You

You might also like