D EVELOPING P ROGRAMS USING ALGORITHMS AND FLOW CHARTS AND VICE VERSA Week 14 Mr.Mohammed Rahmath.

Slides:



Advertisements
Similar presentations
An Introduction to Programming By :- Vishal Hirani B.Tech II year (CSE)
Advertisements

Representing an algorithm using Flowcharts
Exercise (1).
Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
Algorithm & Flow Charts Decision Making and Looping Presented By Manesh T Course:1090 CS.
Chapter 1 Pseudocode & Flowcharts
Fundamentals of Algorithms MCS - 2 Lecture # 4
CS1010 Programming Methodology
LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.
ITEC113 Algorithms and Programming Techniques
D IVIDE AND CONQUER STRATEGY, D ATA TYPE, A LGORITHM DESIGN AND PRACTICE. Week 13 Mr.Mohammed Rahmath.
Understanding Loops Using C Language Week 15 Mr.Omer Salih.
Developing logic (Examples on algorithm and flowchart)
Algorithm & Flowchart.
Chapter 1 Pseudocode & Flowcharts
Programming is instructing a computer to perform a task for you with the help of a programming language.
 Decision making statements Decision making statements if statement if...else statement Nested if...else statement (if...elseif....else Statement) 
Computer Science 210 Computer Organization Introduction to C.
PRINCIPLES OF PROGRAMMING Revision. A Computer  A useful tool for solving a great variety of problems.  To make a computer do anything (i.e. solve.
Introduction to Problem SolvingS1.2.1 Bina © 1998 Liran & Ofir Introduction to Problem Solving Programming in C.
CSC141 Introduction to Computer Programming
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
Repetitive Structures BBS514 Structured Programming (Yapısal Programlama)1.
Software Life Cycle What Requirements Gathering, Problem definition
How to start Visual Studio 2008 or 2010 (command-line program)
A step-by-step procedure for solving a problem in a finite number of steps.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Chapter 6: Control Structures Computer Programming Skills Second Term Department of Computer Science Foundation Year Program Umm Alqura.
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
Basic problem solving CSC 111.
Chapter 1 Pseudocode & Flowcharts
Count and add list of numbers From user input and from file.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
1 Programming a Computer Lecture Ten. 2 Outline  A quick introduction to the programming language C  Introduction to software packages: Matlab for numerical.
Structured Programming (4 Credits) HNDIT Week 2 – Learning Outcomes Design an algorithmic solution for simple problem such as computation of a factorial,
The Hashemite University Computer Engineering Department
Lecture-3 Functions and Recursion. C Preprocessor Includes header files like stdio.h Expands macros defined Handles conditional compilations PreprocessorProcessor.
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
Introduction to C programming. History of C programming Invented and Developed by Dennis Ritchie and Brian Kernighan at Bell Laboratories in 1972 Predecessor.
CPSC 233 Tutorial 5 February 2 th /3 th, Java Loop Statements A portion of a program that repeats a statement or a group of statements is called.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
Program Program is a collection of instructions that will perform some task.
Sesi 0607EKT120/4 Computer Programming Week 5 – Repetition / Loops.
Algorithm & Flow Charts Decision Making and Looping
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
The following statements are for y = -1; if ( x ) if ( x>0 ) y = 1; else y = 0; A. y= -1 x0 B. y= 0 x0 C. y= 1 x
 Problem Analysis  Coding  Debugging  Testing.
From Algorithms to Programs Both are sets of instructions on how to do a task Algorithm: –talking to humans, easy to understand –in plain (English) language.
Module 6 – Decision Control Statements Objectives  Understands Increment/Decrement operators, Conditional and special operators in C  Understands significance.
The Repetition control structure using while loop.
WHILE, DO-WHILE AND FOR LOOPS
ALGORITHMS AND FLOWCHARTS
CS1010 Programming Methodology
Basics of Computer A Computer is Electronic device that can
Type casting Algorithm & flowchart
Computer Programming Techniques Semester 1, 1998
C Programming Hardik H. Maheta.
Week 4 – Repetition Structures / Loops
PROBLEM SOLVING AND OFFICE AUTOMATION
Chapter 1 Pseudocode & Flowcharts
Computer Programming LAB 1 Tejalal Choudhary Asst. Prof, CSE Dept.
Loops in C.
Chapter 1 Pseudocode & Flowcharts
Conditionals.
POWERPOINT PRESENTATION
EECE.2160 ECE Application Programming
Chapter 1 Pseudocode & Flowcharts
Presentation transcript:

D EVELOPING P ROGRAMS USING ALGORITHMS AND FLOW CHARTS AND VICE VERSA Week 14 Mr.Mohammed Rahmath

F LOW CHART A flowchart is a type of diagram that represents an algorithm or process, showing the steps as boxes of various kinds, and their order by connecting them with arrows. This diagrammatic representation solution to a given problem. Mr.Mohammed Rahmath

S YMBOLS FOR F LOW CHART Mr.Mohammed Rahmath

AlgorithmFlow chart Mr.Mohammed Rahmath step 1 : start step 2 : input number step 3 : rem=number mod 2 step 4 : if rem=0 then print "number even“ else print "number odd" endif step 5 : stop to be done by student Q) find out number is odd or even?

AlgorithmFlow chart Mr.Mohammed Rahmath Step 1: Start Step 2: Declare variables num1, num2 and sum. Step 3: Read values num1 and num2. Step 4: Add num1 and num2 and assign the result to sum. sum←num1+num2 Step 5: Display sum Step 6 : Stop to be done by student Q) add two numbers entered by user.

AlgorithmFlow chart Mr.Mohammed Rahmath Step 1: Start Step 2: Declare variables n,i,flag. Step 3: Initialize variables flag←1 i←2 Step 4: Read n from user. Step 5: Repeat the steps until i<(n/2) 5.1 If remainder of n÷i equals 0 flag←0 Go to step i←i+1 Step 6: If flag=0 Display n is not prime else Display n is prime Step 7: Stop to be done by student Q)check whether a number entered by user is prime or not.

AlgorithmFlow chart Mr.Mohammed Rahmath Step 1 : Start Step 2: Declare variables a,b and c. Step 3: Read variables a,b and c. Step 4: If a>b If a>c Display a is the largest number. Else Display c is the largest number. Else If b>c Display b is the largest number. Else Display c is the greatest number. Step 5: Stop to be done by student Q) find the largest among three different numbers entered by user.

C L ANGUAGE The C programming language was designed by Dennis Ritchie at Bell Laboratories in the early 1970s A “C” development environment includes – System libraries and headers : a set of standard libraries and their header files. For example see /usr/include and glibc. – Application Source : application source and header files – Compiler : converts source to object code for a specific platform – Linker : resolves external references and produces the executable module Mr.Mohammed Rahmath

E XECUTION P ROCESS FOR C LANGUAGE PROGRAM Mr.Mohammed Rahmath

S TEPS TO WRITE BASIC C LANGUAGE PROGRAM AND EXECUTE USING B LOODSHED C ++ EDITOR Click start Click all programs Click bloodshed c++ editor Click file Select new Write c language code/program Save program/code compile program using ctrl + f9 key and execute using ctrl + f10 key. Mr.Mohammed Rahmath

S CREEN SHOT ( DEV C ++) Mr.Mohammed Rahmath

C PROGRAMS Q) Write a c program for addition of two numbers. #include int main() { int a, b, c; printf("Enter two numbers to add \n "); scanf("%d%d",&a,&b); c = a + b; printf("Sum of entered numbers = %d \n ",c); return 0; } Mr.Mohammed Rahmath

C PROGRAM TO CHECK ODD OR EVEN USING MODULUS OPERATOR #include main() { int n; printf("Enter an integer \n "); scanf("%d",&n); if ( n%2 == 0 ) printf("Even \n "); else printf("Odd \n "); return 0; } Mr.Mohammed Rahmath

P ALINDROME NUMBER ALGORITHM #include int main() { int n, reverse = 0, temp; printf("Enter a number to check if it is a palindrome or not \n "); scanf("%d",&n); temp = n; while( temp != 0 ) { reverse = reverse * 10; reverse = reverse + temp%10; temp = temp/10; } if ( n == reverse ) printf("%d is a palindrome number. \n ", n); Else printf("%d is not a palindrome number. \n ", n); return 0; } Mr.Mohammed Rahmath

S ESSION 14 E ND Mr.Mohammed Rahmath