csc 202 computer programming

8
CSC 202 Computer Programming What is Program ? Program is a set of instruction that a machine follows. What is Programming? Programming is to make machine work. Programming creates instruction set that a machine follows.

Upload: chinue

Post on 05-Jan-2016

18 views

Category:

Documents


0 download

DESCRIPTION

CSC 202 Computer Programming. What is Program ? Program is a set of instruction that a machine follows. What is Programming? Programming is to make machine work. Programming creates instruction set that a machine follows. Program has typically 3 parts: Input Process Output - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CSC  202          Computer Programming

CSC 202 Computer Programming

What is Program ?Program is a set of instruction that a machine follows.

What is Programming?Programming is to make machine work. Programming creates instruction set that a machine follows.

Page 2: CSC  202          Computer Programming

Anatomy of a Program

Program has typically 3 parts:

Input Process Output

Example:

Summation Program takes two numbers as input and displays their sum.

CSC 202 Computer Programming

Input: 2 , 3

Process:

sum= 2+3

Output :

Display sum:5

Page 3: CSC  202          Computer Programming

What is Software then????

• There is no hard and fast distinction between program and software. • Software is often called Program and vice versa• When it is said Software, then the program is always complete and

ready to be used.

Softwares are of two kinds

1. Application Software 2. Operating system

CSC 202 Computer Programming

Page 4: CSC  202          Computer Programming

Application softwares

• MS Word• MS Excel• Winamp• Herosoft• Windows Media player• Calculator• PowerDVD• Calculator

Operating System(OS)

• Windows XP• Windows 98• Linux• Unix• Solaris• MacOS• Windows Vista

Page 5: CSC  202          Computer Programming

Programming Language

Programming languages are used to write programs.Some of these languages are quite similar to human language.

Programs are of two kinds: Desktop application and Web application. As an example we can say MS Word is desktop application whereas Yahoo mail is a web application.

Popular Desktop Programming languages:

C Java C++/ Visual C++ C# Visual Basic

Popular Web Programming languages:

HTML PHP XML ASP ASP.NET

CSC 202 Computer Programming

Page 6: CSC  202          Computer Programming

Introduction to C

• C was invented in 1970 by Dennis Ritchie at Bell Lab.• C’s popularity became widespread in 1980s.• Father of other modern languages

Why do we choose C?• C is easier to learn• C program runs on almost all the Operating Systems• C program takes less time to run.• C programmer can easily switch to any language.

CSC 202 Computer Programming

Page 7: CSC  202          Computer Programming

Introduction to Turbo C compiler with a sample C program: adder.cpp

#include<stdio.h>#include<conio.h>

void main(){int a, b, sum;a=2;b=3;sum=a+b;

printf(“Result:\n”);printf(“Sum is %d \n”,sum);

getch();}

Page 8: CSC  202          Computer Programming

Functions

• As books are kept into different shelves in the library, instructions are also organized into different functions.

• A function is a block instructions

• A program contains one or more functions

• Each program has a function named “main” and a program starts execution from main function.

Note: For the time being, all our programs will have only one function that is main.

ProgramProgram

Instruction 1Instruction 1Instruction 2Instruction 2Instruction 3Instruction 3Instruction 4Instruction 4

Instruction 5Instruction 5

Instruction 7Instruction 7Instruction 8Instruction 8

Instruction 6Instruction 6

Function 1Function 1

Function 2Function 2

CSC 202 Computer Programming