Introduction to programming
-
Upload
kimera-richard -
Category
Technology
-
view
37 -
download
0
Transcript of Introduction to programming
18/04/23 01:34 AM CSC Alliance — 1
Kimera RichardE-mail: [email protected]
Phone: 0701 437989INSTITUTE OF COMPUTER SCIENCE
DEPARTMENT OF INFORMATION SYSTEMS AND TECHNOLOGY
Intro to Computer Programming
http://Westechies.blogspot.comhttp://kimrichies.blogspot.com
MUST- ICS [email protected]
What is a program
A sequence of instructions that a computer can interpret and execute;
If I tell you the way from ICS to Administration Block … I will tell sequence of instructions…. Any wrong instruction leads to a undesired result.
A program is something that runs on your computer. In case of MS Windows program is of .EXE or .COM extensions
MS Word, Power point, Excel are all computer programs
MUST- ICS [email protected]
Discussion Question:
How advantageous is Computer Programming in relation to National development?
MUST- ICS [email protected]
Programming Concepts
Data Types
Variables
Operators
Conditional Statements
Looping Statements
Functions and working with Files
Application programming Interfaces (API’s)
e.t.c
MUST- ICS [email protected]
Data Types and Variables
Data Type: It is basically a scheme for representing data OR data storage location e.g Int, String, float, boolean, byte, e.t.c
A variable is a named data storage location in your computer's memory. By using a variable's name in your program, you are, in effect, referring to the data stored there.
MUST- ICS [email protected]
Operators
Operators are symbols which take one or more operands or expressions and perform arithmetic or logical computations.
E.g +, -, *, /, %, =, ++, - -. ==, <, >, //, &&
Operands are variables or expressions which are used in conjunction with operators to evaluate the expression.
Combination of operands and operators form an expression.
MUST- ICS [email protected]
Conditional Statements
If…else statement – Tests if a certain condition is true/ false and executes a given statement
Switch Statement – Similary works as the if..else statement
MUST- ICS [email protected]
Looping Statements
Executes a certain condition and loops up to when the set condition is met
Examples of statement include;
While loop
Do…….while
Break and continue
goto
for
MUST- ICS [email protected]
Functions/Methods
Functions/Methods are independent sections in a code that perform some specific task and optionally returns a value when called
The help break a complex problem or task into a smaller portions
MUST- ICS [email protected]
Writing Computer Programs
A programmer uses an editor to create or modify files containing C code e.g Notepad, Codeblocks, Visual studio, Android studio, e.t.c
Code is also known as source code.
After a source file/Project has been created, the programmer must invoke the compiler before the program can be executed (run).
For advanced IDE’s(Integrated Drive Electronics), the program is compiled as you code.
MUST- ICS [email protected]
Introduction to programming languages
Programming languages can be;
Server side languages Server side languages – Code is stored on the server and accessed by a clied basically through the browser. E.g php
Client side languages Client side languages – code can be stored on either the client or server e.g HTML
Interpreted languages Interpreted languages – Code will execute even if it contains errors, no compile is needed e.g HTML
Compiled languages Compiled languages – Code will not execute/run if the compile fails to understand some statements e.g C, Java
Any more???
MUST- ICS [email protected]
Categories of Programming languages
Procedure languages Procedure languages – Follow a step by step program execution e.g C, C++, e.t.c
Object Oriented Programming languages Object Oriented Programming languages – Classes are used a data types for Objects.
Event Driven Languages- Event Driven Languages- The program runs basing on user actions, this is common in GUI programming. Events can be generated when a user clicks a button, touches the scroon, moves a mouse, types on the key board, etc. Examples… Java, Visual Basic, C++. OO Php
Scripting languages Scripting languages – light weight languages e.g php, python, javascript
Mobile programming language – Mobile programming language – Light weight languages that run on mobile devices e.g Android, windows OS, swift/Objective C, Symbian, WebOS, Blackberry OS.
MUST- ICS [email protected]
Programming support Tools
Basic Editors e.g Notepad, Notepad ++
IDE’s (WYSIWYG) e.g Netbeans, Dreamweaver, Codeblocks
Content management systems e.g Joomla, Wordpress, Drupal, etc
Mockups – pencil, fireworks, etc
MUST- ICS [email protected]
Example of program written in C
#include <stdio.h>
int main( void )
{
int value1, value2, product ;
printf(“Enter two integer values: “) ;
scanf(“%d%d”, &value1, &value2) ;
product = value1 * value2 ;
printf(“Product = %d\n”, product) ;
return 0 ;
}
MUST- ICS [email protected]
Example of program written in Java
/* Sample Java Program */
public class Sample {
public static void main (String [] args)
{int i;for (i = 1; i <= 10; i++) { System.out.println
("Number: " + i);}
}}
MUST- ICS [email protected]
Example of program written in Objective C
#import <Foundation/Foundation.h>
int main() {
/* my first program in Objective-C */
NSLog(@"Hello, World! \n");
return 0;
}
Source: http://www.tutorialspoint.com/objective_c/objective_c_environment_setup.htm
MUST- ICS [email protected]
Example of program written in Android
package com.example.kim.myapplication;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
return super.onOptionsItemSelected(item);
}
}
MUST- ICS [email protected]
Discussion Question
If we are to teach Computer programming in Secondary Schools, which one of the above programming languages would be simpler
Lets think about the our school labs and resources available
MUST- ICS [email protected]
QUESTIONS
What do you think could be the best way of teaching computer programming in your school?
MUST- ICS [email protected]