This document discusses programming concepts such as variables, constants, data types, and program structure. It defines key terms like:
- Variables which store changing data in memory and are assigned a data type. Constants store fixed values.
- Data types include integers, reals, Booleans, strings, characters which determine how data is stored and processed.
- Programs use statements, selection (if/else), and repetition (loops). Procedures and functions are subroutines that can optionally return values.
- Parameters pass values to subroutines to influence their behavior. Variables can be global or local in scope, influencing where they are accessible.
This document discusses algorithm design and problem solving. It covers topics like top-down modular design, structure diagrams, stepwise refinement, pseudocode, flowcharts, and validation checks. An example flowchart is provided that squares the first 5 numbers. Pseudocode is also demonstrated for an ATM algorithm. Key aspects of algorithm evaluation like efficiency, correctness, and appropriateness are defined. Various programming constructs like assignment statements, arithmetic and relational operators, and Boolean logic are also explained.
This book's author is Zafar Ali Khan .
It consists of all the topics of As Level Computer Science topics that are required to be covered.
All credits goes to Zafar Ali Khan .
This document provides an introduction and overview for a Visual Logic programming project. It discusses key concepts like variables, input and output statements, and arithmetic expressions. It also presents a sample weekly paycheck program to demonstrate these concepts. The program uses input statements to get employee work hours and pay rate. It then uses an assignment statement to calculate the pay amount as hours times rate. The goal is to teach basic programming logic and syntax.
The document discusses programming constructs and converting algorithms into computer programs. It covers:
1) The basic constructs of sequence, selection, and iteration that are necessary to write any computer program according to Edsger Dijkstra's theorem. Sequence involves steps executed in order, selection allows choosing between alternatives, and iteration repeats steps.
2) Pseudocode as a way to represent algorithms independently of any programming language using basic commands like input, output, and assignment.
3) Variables as named storage locations for values in a program. When converting pseudocode to an actual programming language, the variable type must be specified.
4) Two approaches for how a computer executes a program - compiling converts the entire source
The document discusses problem solving using computers. It explains that programming languages allow problems to be solved repeatedly by telling the computer the logic or algorithm to follow. An algorithm is a series of steps, like pseudocode or a flowchart, that represent the procedure for solving a problem. It then provides examples of algorithms for calculating the factorial of a number in different formats, including English steps, flowcharts, and pseudocode. Programming implements the algorithm by translating it line-by-line into source code.
The document discusses algorithms and their building blocks. It defines an algorithm as a collection of well-defined, unambiguous and effectively computable instructions that return a proper output. The three building blocks of algorithms are identified as sequence, selection, and iteration. Sequence refers to a series of actions performed in order. Selection allows a program to choose between different actions or conditions. Iteration allows a block of code to be repeated while a condition is true. Pseudocode and flowcharts are introduced as common ways to express algorithms and illustrate the control flow and logic of a program.
Unit 1 introduction to visual basic programmingAbha Damani
This document provides an introduction to visual basic programming, covering topics such as variables, data types, operators, flow control, procedures, arrays, strings, and exception handling. It discusses the visual studio integrated development environment and its key components. It defines variables and data types, and covers implicit and explicit type conversions. Control flow structures like conditional statements, selection statements, and iteration statements are explained. Procedures such as subroutines and functions are defined. Finally, it provides examples of arrays and strings.
This document discusses algorithm design and problem solving. It covers topics like top-down modular design, structure diagrams, stepwise refinement, pseudocode, flowcharts, and validation checks. An example flowchart is provided that squares the first 5 numbers. Pseudocode is also demonstrated for an ATM algorithm. Key aspects of algorithm evaluation like efficiency, correctness, and appropriateness are defined. Various programming constructs like assignment statements, arithmetic and relational operators, and Boolean logic are also explained.
This book's author is Zafar Ali Khan .
It consists of all the topics of As Level Computer Science topics that are required to be covered.
All credits goes to Zafar Ali Khan .
This document provides an introduction and overview for a Visual Logic programming project. It discusses key concepts like variables, input and output statements, and arithmetic expressions. It also presents a sample weekly paycheck program to demonstrate these concepts. The program uses input statements to get employee work hours and pay rate. It then uses an assignment statement to calculate the pay amount as hours times rate. The goal is to teach basic programming logic and syntax.
The document discusses programming constructs and converting algorithms into computer programs. It covers:
1) The basic constructs of sequence, selection, and iteration that are necessary to write any computer program according to Edsger Dijkstra's theorem. Sequence involves steps executed in order, selection allows choosing between alternatives, and iteration repeats steps.
2) Pseudocode as a way to represent algorithms independently of any programming language using basic commands like input, output, and assignment.
3) Variables as named storage locations for values in a program. When converting pseudocode to an actual programming language, the variable type must be specified.
4) Two approaches for how a computer executes a program - compiling converts the entire source
The document discusses problem solving using computers. It explains that programming languages allow problems to be solved repeatedly by telling the computer the logic or algorithm to follow. An algorithm is a series of steps, like pseudocode or a flowchart, that represent the procedure for solving a problem. It then provides examples of algorithms for calculating the factorial of a number in different formats, including English steps, flowcharts, and pseudocode. Programming implements the algorithm by translating it line-by-line into source code.
The document discusses algorithms and their building blocks. It defines an algorithm as a collection of well-defined, unambiguous and effectively computable instructions that return a proper output. The three building blocks of algorithms are identified as sequence, selection, and iteration. Sequence refers to a series of actions performed in order. Selection allows a program to choose between different actions or conditions. Iteration allows a block of code to be repeated while a condition is true. Pseudocode and flowcharts are introduced as common ways to express algorithms and illustrate the control flow and logic of a program.
Unit 1 introduction to visual basic programmingAbha Damani
This document provides an introduction to visual basic programming, covering topics such as variables, data types, operators, flow control, procedures, arrays, strings, and exception handling. It discusses the visual studio integrated development environment and its key components. It defines variables and data types, and covers implicit and explicit type conversions. Control flow structures like conditional statements, selection statements, and iteration statements are explained. Procedures such as subroutines and functions are defined. Finally, it provides examples of arrays and strings.
This document provides an introduction to algorithms and imperative programming in C language. It defines an algorithm as a set of instructions to perform a task and discusses the differences between algorithms and programs. It also describes flowcharts for representing algorithms and discusses various programming elements in C like variables, data types, operators, functions, and comments. The document concludes with an example of a simple "Hello World" C program.
Visual Logic is a software tool for creating interactive flowcharts and programs. It allows users to graphically design programs using symbols like inputs, outputs, and assignments. The document provides instructions on how to install Visual Logic and create sample programs that get user input, perform calculations, and display output using both dialog boxes and the console window. It emphasizes best practices like enclosing text in quotes and using variables to store and concatenate input values for customized output.
This document outlines the course requirements for PRG 211 Algorithms and Logic for Computer Programming over 5 weeks. It includes individual assignments involving visual logic, arrays, and algorithms. The learning team assignment is to develop an algorithm and program for either calorie management or home maintenance tracking, including writing pseudocode, flowcharts, and a presentation.
C is a general-purpose programming language developed in the 1970s. The lecture discusses C's history and uses, and outlines the typical program development cycle of requirement analysis, design, implementation, testing, and documentation. It also introduces common programming tools like algorithms, pseudocode, flowcharts, and hierarchy charts to plan and design programs before coding.
The document discusses algorithms, providing definitions and examples of algorithms including Euclid's algorithm for computing the greatest common divisor. It also outlines properties that algorithms must have including finiteness, absence of ambiguity, defined sequence and inputs/outputs. Pseudocode is introduced as a way to express algorithms at a high level for human reading using basic logic structures like sequence, selection, and iteration.
The document discusses the six main steps in the programming process: 1) understanding the problem, 2) planning the logic, 3) coding the program, 4) translating to machine language, 5) testing the program, and 6) putting the program into production. It then provides more details about planning the logic using flowcharts and pseudocode to represent the logical steps of a program before coding it. The document also covers translating the program to machine language using compilers or interpreters, testing programs for logical errors, and implementing programs for actual use.
For most programming/scripting languages the concepts are all the same. The only thing that changes is the syntax in which it is written. Some languages may be easier to remember than others, but if you follow the basic guide line, it will make learning any programming language easier. This is in no way supposed to teach you everything about programming, just a general knowledge so when you do program you will understand what you are doing a little bit better.
This document provides an overview of problem solving and Python programming. It discusses computational thinking and problem solving, including identifying computational problems, algorithms, building blocks of algorithms, and illustrative problems. It also discusses algorithmic problem solving techniques like iteration and recursion. Finally, it briefly introduces the course titled "GE8151-PROBLEM SOLVING AND PYTHON PROGRAMMING".
This document discusses algorithms including:
- An algorithm is a set of instructions to accomplish a task, with inputs and outputs.
- Characteristics of algorithms include being definite, finite, unambiguous, and efficient.
- The design process involves understanding the problem, capabilities of the device, choosing exact or approximate solutions, selecting a data structure, and techniques like divide-and-conquer.
- Algorithms can be specified through languages, pseudocode, or flowcharts and must be proven correct. Their analysis considers time and space complexity.
The document discusses various techniques used during the design stage of developing algorithms and computer programs, including process modelling, data flow diagrams, process specifications, flow charts, pseudocode, and structure diagrams. It provides examples of how each technique can be used to logically design a computer algorithm by clarifying the steps and flow involved. Pseudocode in particular is described as a way to translate user requirements into a sequence of unambiguous logical steps using structured English.
This document discusses various programming techniques. It begins by explaining why programming techniques are important for generalizing and reusing code. Some key techniques discussed include complexity factors, using bitwise operators, and the differences between iteration and recursion. The document then covers arrays, including their definition and advantages. It provides examples of reversing an array using different methods. Next, it delves into bitwise operators and provides examples of how they work. Finally, the document discusses design patterns and provides examples of common patterns like factory and singleton.
Pseudocode is a detailed description of an algorithm or program expressed in plain language rather than a programming language. It allows programmers to design programs at a high level before writing code. The document provides examples of pseudocode for control structures like conditionals and loops, and calculating sales tax and weekly wages. It also defines flowcharts as diagrams that show the sequence of operations to solve a problem and lists common flowchart symbols like rectangles, diamonds, and circles. Guidelines are given for drawing flowcharts and examples are provided of flowcharts to find the largest of three numbers and sum the first 50 natural numbers.
2.2 Demonstrate the understanding of Programming Life CycleFrankie Jones
The document discusses the 7 phases of the programming life cycle: (1) specify the problem, (2) analyze the problem, (3) design the algorithm, (4) implement the algorithm, (5) test and verify, (6) maintain and update, and (7) documentation. Each phase is explained in detail with examples provided. The first phase involves understanding the problem requirements. The second phase identifies inputs, outputs, and potential solutions. The third phase develops the step-by-step logic to solve the problem. The fourth phase writes the code. The fifth phase tests for bugs. The sixth phase modifies code for improvements or changes. And the seventh phase provides documentation for users and other programmers.
This document introduces algorithms and the process of program development. It defines an algorithm as a precise list of instructions that terminates after a finite number of steps to solve a problem. It discusses methods of specifying algorithms like pseudocode and flowcharts. Properties of algorithms include being finite, unambiguous, and having a defined sequence of execution and input/output. The steps of program development are stated as understanding the problem, planning instructions, coding the program, running and debugging it. Flowcharting guidelines and common symbols are provided. Sample exercises demonstrate writing programs to calculate simple formulas.
Problem Solving Techniques and Introduction to CPrabu U
This document provides an overview of problem solving techniques, programs, and the program development cycle. It discusses:
1. The steps of problem solving techniques include defining the problem, formulating a mathematical model, developing an algorithm using a flowchart or pseudocode, writing code, and testing the program.
2. A program consists of a series of instructions and fixed data to perform required operations. The program development cycle involves problem analysis, design, coding, compilation and execution, debugging and testing, and documentation.
3. An algorithm is a finite sequence of steps to solve a problem. Flowcharts use graphical symbols to represent the steps of an algorithm and show the program logic through connections between these symbols.
Introduction to programming by MUFIX Commnitymazenet
Programming involves breaking problems down into simple steps that a computer can understand through instructions. It requires defining problems clearly and solving them by describing actions, modeling data, and refining solutions iteratively. Effective programming tools include action lists, flow charts, and data modeling to design solutions before writing code. Statements, blocks, variables, loops, functions, conditionals, and input/output allow computers to repeat tasks, store and manipulate data, and make decisions.
The document provides information on pseudocode, including:
1. Pseudocode avoids specifying a particular programming language and uses generic terms to describe programming concepts like loops, branching, and input/output.
2. Common pseudocode terms are described, like counting, totaling, and input/output.
3. Examples of writing algorithms in pseudocode are given, such as calculating property taxes based on property value or repeatedly calculating a formula until a condition is met.
The document provides an introduction to algorithms and key concepts related to algorithms such as definition, features, examples, flowcharts, pseudocode. It also discusses different types of programming languages from first to fifth generation. Key points of structured programming approach and introduction to C programming language are explained including data types, variables, constants, input/output functions, operators, type conversion etc.
Introduction to Programming Fundamentals 3.pdfAbrehamKassa
The document discusses various programming constructs in C++ including IDEs, writing source code, saving and compiling source files, and dealing with errors. It also covers C++ statements, expressions, variables, data types, literals, symbolic constants, and identifiers. Key points include how to write, save, compile and run a C++ program, declare variables, and use constants. Symbolic constants are preferable to literal values as they allow easy program modification.
This document provides an introduction to algorithms and imperative programming in C language. It defines an algorithm as a set of instructions to perform a task and discusses the differences between algorithms and programs. It also describes flowcharts for representing algorithms and discusses various programming elements in C like variables, data types, operators, functions, and comments. The document concludes with an example of a simple "Hello World" C program.
Visual Logic is a software tool for creating interactive flowcharts and programs. It allows users to graphically design programs using symbols like inputs, outputs, and assignments. The document provides instructions on how to install Visual Logic and create sample programs that get user input, perform calculations, and display output using both dialog boxes and the console window. It emphasizes best practices like enclosing text in quotes and using variables to store and concatenate input values for customized output.
This document outlines the course requirements for PRG 211 Algorithms and Logic for Computer Programming over 5 weeks. It includes individual assignments involving visual logic, arrays, and algorithms. The learning team assignment is to develop an algorithm and program for either calorie management or home maintenance tracking, including writing pseudocode, flowcharts, and a presentation.
C is a general-purpose programming language developed in the 1970s. The lecture discusses C's history and uses, and outlines the typical program development cycle of requirement analysis, design, implementation, testing, and documentation. It also introduces common programming tools like algorithms, pseudocode, flowcharts, and hierarchy charts to plan and design programs before coding.
The document discusses algorithms, providing definitions and examples of algorithms including Euclid's algorithm for computing the greatest common divisor. It also outlines properties that algorithms must have including finiteness, absence of ambiguity, defined sequence and inputs/outputs. Pseudocode is introduced as a way to express algorithms at a high level for human reading using basic logic structures like sequence, selection, and iteration.
The document discusses the six main steps in the programming process: 1) understanding the problem, 2) planning the logic, 3) coding the program, 4) translating to machine language, 5) testing the program, and 6) putting the program into production. It then provides more details about planning the logic using flowcharts and pseudocode to represent the logical steps of a program before coding it. The document also covers translating the program to machine language using compilers or interpreters, testing programs for logical errors, and implementing programs for actual use.
For most programming/scripting languages the concepts are all the same. The only thing that changes is the syntax in which it is written. Some languages may be easier to remember than others, but if you follow the basic guide line, it will make learning any programming language easier. This is in no way supposed to teach you everything about programming, just a general knowledge so when you do program you will understand what you are doing a little bit better.
This document provides an overview of problem solving and Python programming. It discusses computational thinking and problem solving, including identifying computational problems, algorithms, building blocks of algorithms, and illustrative problems. It also discusses algorithmic problem solving techniques like iteration and recursion. Finally, it briefly introduces the course titled "GE8151-PROBLEM SOLVING AND PYTHON PROGRAMMING".
This document discusses algorithms including:
- An algorithm is a set of instructions to accomplish a task, with inputs and outputs.
- Characteristics of algorithms include being definite, finite, unambiguous, and efficient.
- The design process involves understanding the problem, capabilities of the device, choosing exact or approximate solutions, selecting a data structure, and techniques like divide-and-conquer.
- Algorithms can be specified through languages, pseudocode, or flowcharts and must be proven correct. Their analysis considers time and space complexity.
The document discusses various techniques used during the design stage of developing algorithms and computer programs, including process modelling, data flow diagrams, process specifications, flow charts, pseudocode, and structure diagrams. It provides examples of how each technique can be used to logically design a computer algorithm by clarifying the steps and flow involved. Pseudocode in particular is described as a way to translate user requirements into a sequence of unambiguous logical steps using structured English.
This document discusses various programming techniques. It begins by explaining why programming techniques are important for generalizing and reusing code. Some key techniques discussed include complexity factors, using bitwise operators, and the differences between iteration and recursion. The document then covers arrays, including their definition and advantages. It provides examples of reversing an array using different methods. Next, it delves into bitwise operators and provides examples of how they work. Finally, the document discusses design patterns and provides examples of common patterns like factory and singleton.
Pseudocode is a detailed description of an algorithm or program expressed in plain language rather than a programming language. It allows programmers to design programs at a high level before writing code. The document provides examples of pseudocode for control structures like conditionals and loops, and calculating sales tax and weekly wages. It also defines flowcharts as diagrams that show the sequence of operations to solve a problem and lists common flowchart symbols like rectangles, diamonds, and circles. Guidelines are given for drawing flowcharts and examples are provided of flowcharts to find the largest of three numbers and sum the first 50 natural numbers.
2.2 Demonstrate the understanding of Programming Life CycleFrankie Jones
The document discusses the 7 phases of the programming life cycle: (1) specify the problem, (2) analyze the problem, (3) design the algorithm, (4) implement the algorithm, (5) test and verify, (6) maintain and update, and (7) documentation. Each phase is explained in detail with examples provided. The first phase involves understanding the problem requirements. The second phase identifies inputs, outputs, and potential solutions. The third phase develops the step-by-step logic to solve the problem. The fourth phase writes the code. The fifth phase tests for bugs. The sixth phase modifies code for improvements or changes. And the seventh phase provides documentation for users and other programmers.
This document introduces algorithms and the process of program development. It defines an algorithm as a precise list of instructions that terminates after a finite number of steps to solve a problem. It discusses methods of specifying algorithms like pseudocode and flowcharts. Properties of algorithms include being finite, unambiguous, and having a defined sequence of execution and input/output. The steps of program development are stated as understanding the problem, planning instructions, coding the program, running and debugging it. Flowcharting guidelines and common symbols are provided. Sample exercises demonstrate writing programs to calculate simple formulas.
Problem Solving Techniques and Introduction to CPrabu U
This document provides an overview of problem solving techniques, programs, and the program development cycle. It discusses:
1. The steps of problem solving techniques include defining the problem, formulating a mathematical model, developing an algorithm using a flowchart or pseudocode, writing code, and testing the program.
2. A program consists of a series of instructions and fixed data to perform required operations. The program development cycle involves problem analysis, design, coding, compilation and execution, debugging and testing, and documentation.
3. An algorithm is a finite sequence of steps to solve a problem. Flowcharts use graphical symbols to represent the steps of an algorithm and show the program logic through connections between these symbols.
Introduction to programming by MUFIX Commnitymazenet
Programming involves breaking problems down into simple steps that a computer can understand through instructions. It requires defining problems clearly and solving them by describing actions, modeling data, and refining solutions iteratively. Effective programming tools include action lists, flow charts, and data modeling to design solutions before writing code. Statements, blocks, variables, loops, functions, conditionals, and input/output allow computers to repeat tasks, store and manipulate data, and make decisions.
The document provides information on pseudocode, including:
1. Pseudocode avoids specifying a particular programming language and uses generic terms to describe programming concepts like loops, branching, and input/output.
2. Common pseudocode terms are described, like counting, totaling, and input/output.
3. Examples of writing algorithms in pseudocode are given, such as calculating property taxes based on property value or repeatedly calculating a formula until a condition is met.
The document provides an introduction to algorithms and key concepts related to algorithms such as definition, features, examples, flowcharts, pseudocode. It also discusses different types of programming languages from first to fifth generation. Key points of structured programming approach and introduction to C programming language are explained including data types, variables, constants, input/output functions, operators, type conversion etc.
Introduction to Programming Fundamentals 3.pdfAbrehamKassa
The document discusses various programming constructs in C++ including IDEs, writing source code, saving and compiling source files, and dealing with errors. It also covers C++ statements, expressions, variables, data types, literals, symbolic constants, and identifiers. Key points include how to write, save, compile and run a C++ program, declare variables, and use constants. Symbolic constants are preferable to literal values as they allow easy program modification.
This document discusses variables and data types in programming. It defines variables as symbols that represent values that can change. Variables are used to store information needed during a program's execution. The document outlines different types of variables like local and global, and rules for naming variables. It also discusses data types like integer, floating point, character, string, and Boolean, and how they classify different types of information. The document concludes by explaining how variables must be declared before use and how declarations associate a type and name with a variable.
A flow chart is a graphical representation of a process using different symbols to represent each step linked by arrows. An algorithm is a step-by-step method to solve a problem or make decisions. The main differences between an algorithm and flowchart are that an algorithm is a set of rules to solve a problem while a flowchart is a diagram that visually represents an algorithm. C programming variables must be declared with a data type and can be initialized with a starting value. Variables can be declared locally inside functions or globally outside any functions.
The document discusses the C programming language. It states that C was created by Dennis Ritchie at Bell Labs in 1972 to develop the UNIX operating system. It became more widely used after Brian Kernighan and Dennis Ritchie published the first description of C in 1978. C is a general-purpose, high-level language that produces efficient, low-level code and can be compiled on many platforms. It is widely used to develop operating systems, compilers, databases and other systems programs.
unit 1 programming in c ztgdawte efhgfhj ewnfbshyufh fsfyshuGauravRawat830030
Computer systems consist of hardware and software. System software manages hardware components and includes device drivers, operating systems, servers, and utilities. Programming software provides tools to assist programmers. Application software aids tasks through business, design, databases, and other programs. There are low-level languages close to machine code like machine language and assembly language and high-level languages like C that are closer to English. Creating and running a C program involves writing code, compiling it, linking, loading, and executing the program.
This document discusses basic programming concepts including:
1) A program is a set of instructions that directs a computer to perform tasks. Programming involves writing programs using programming languages.
2) There are different generations of programming languages from low-level machine languages to high-level languages that are more abstract and portable.
3) The five basic elements in programming are: data types, variables, constants, operators, and control structures. Variables can be changed during program execution while constants remain fixed.
Google has developed the programming language called Go. Go is a freedom-respecting and open source programming language and it is designed by Robert Griesemer, Rob Pike, and Ken Thompson in the year 2007. Go language was released in 2009. The syntax of the Go language resembles the C programming language and Go language is a statically typed programming language which is often called golang. Go language is detailed understood by golang online course.
This document provides an introduction to fundamentals of programming with C#, including definitions of key concepts like algorithms, variables, data types, operators, and conditional statements. It explains that programming involves describing what you want the computer to do as a sequence of steps or algorithms. The stages of software development are outlined as gathering requirements, planning/design, implementation, testing, deployment, support, and documentation. An overview of C# programming language fundamentals is also provided, such as basic syntax structure, defining classes and methods, and using the console for input/output.
The document discusses the steps involved in program development including defining the problem, outlining the solution, developing an algorithm, testing the algorithm, coding the algorithm, running the program, and documenting the program. It also discusses different approaches to program design such as procedure-driven, event-driven, and data-driven designs. Finally, it introduces algorithms, pseudocode, program data types, and how to write pseudocode using basic computer operations like arithmetic, assignment, comparison, and repetition.
COBOL programming language.
Watch my videos on snack here: --> --> http://sck.io/x-B1f0Iy
@ Kindly Follow my Instagram Page to discuss about your mental health problems-
-----> https://instagram.com/mentality_streak?utm_medium=copy_link
@ Appreciate my work:
-----> behance.net/burhanahmed1
Thank-you !
The document provides an overview of the C programming language. It discusses that a program is a set of instructions given to a computer to perform a task. It also describes that programming involves giving instructions to a computer through a program file. C is a middle-level language that combines aspects of high-level languages and assembly language. The document then covers various C programming concepts like variables, data types, operators, input/output functions and the steps to develop a program.
C programming Training in Ambala ! Batra Computer Centrejatin batra
Batra Computer Centre is An ISO certified 9001:2008 training Centre in Ambala.
We Provide C Programming Training in Ambala. BATRA COMPUTER CENTRE provides best training in C, C++, S.E.O, Web Designing, Web Development and So many other courses are available.
Do you want to learn basic information about the c Language?
Yes!
That’s great.
This pdf is the right choice for you.
Here, I will provide you all the basic information about C language.
You can visit our blog to enjoy our original post.
The document provides an overview of the C programming language. It discusses that C was developed at Bell Labs in the 1970s and is a general purpose language closely associated with UNIX. It then covers C's character set, keywords, basic program structure including header files and library functions, data types, variables, constants, and provides a simple "Hello World" example program.
The document provides an introduction to computer programming and the C++ programming language. It discusses what a computer program is, different types of programs, and the process of computer programming. It then covers key concepts in C++ programming including data types, variables, constants, input/output, and basic program structure. The document is intended to teach programming fundamentals and provide an overview of C++ for beginners.
This document provides an introduction and overview of the C programming language. It discusses what a computer is and how programming languages work. It introduces machine language and high-level languages like C. Key aspects of C are explained, including data types, variables, operators, functions, and basic syntax. Examples of simple C programs are provided.
C is a general-purpose programming language developed at Bell Labs in the 1970s. It discusses the basics of C programming, including its history, structure, keywords, variables, data types, and provides an example "Hello World" program. The document provides an overview of the key elements of C for a beginner programmer to understand how to get started with C.
This document provides a review of key concepts in Visual Basic 6 including variables, data types, operators, functions, and formatting. It defines variables and data types, explains implicit and explicit variable declaration, and covers the scope of variables. Mathematical, relational, and logical operators are defined. Commonly used functions for strings, dates, numbers and formatting are also described. Hands-on activities are included to apply the concepts.
The document provides information on the C programming language, including its history, structure, and key concepts. It discusses how C was developed at Bell Labs in the 1970s and influenced by other languages. It also describes the basic structure of C programs, which typically include header files, main functions, and statements organized into functions. The document also covers important C concepts like data types, variables, constants, and tokens.
The document contains password and configuration information for Windows 2012 and Windows 8 systems on an internal network, including the administrator password for Windows 2012 being "Win2012 W upper case", RAM sizes of 2048 for Server 2012 and 1024 for Windows 8, and IP addresses, subnet masks, default gateways and DNS servers for Server 2012 being 192.168.1.1 and for Windows 8 being 192.168.1.2 with the default gateway and DNS server of Server 2012 being 192.168.1.1. It also provides instructions for ping testing connectivity between the server and client by disabling the Windows firewall temporarily.
How to train cortana to respond to your voiceTabsheer Hasan
Cortana can be trained to only respond to a specific user's voice by having the user say six sentences out loud to Cortana in a quiet place, which allows Cortana to learn and recognize that individual's voice so that only they can activate Cortana with voice commands and not others passing by.
This document provides instructions for turning on "Hey Cortana" on Windows 10. It instructs users to press the Windows key and S simultaneously to open Cortana, then click the Notebook button and Settings to access the On/Off switch for "Hey Cortana", which allows users to activate Cortana with voice commands like "Hey, Cortana" followed by a question.
Cortana does not always appear in the Windows 10 taskbar by default. The document provides instructions for pinning Cortana to the taskbar so it is always visible, including right-clicking the taskbar, selecting Cortana, and choosing whether to show Cortana's icon, hide it, or show its search box in the taskbar for quick access.
The document discusses the five generations of computers from 1946 to present. The first generation used vacuum tubes and were very large, expensive, and generated a lot of heat. The second generation introduced transistors, making computers smaller and more reliable. The third generation used integrated circuits to make computers even smaller and faster. The fourth generation used microchips and VLSI circuits, leading to the development of personal computers. The fifth generation continues advancing computer technology through parallel processing and artificial intelligence.
Cortana lives in the Windows taskbar and must be launched for the first time by opening the Start Menu, clicking All Apps, and then clicking Cortana. After launching, users are prompted to click the Cortana button in the taskbar and either enable speech, inking, and typing personalization to help Cortana perform tasks tailored to the user or decline personalized features.
This document is a 14-page exam for the Cambridge International Examinations Computer Science 2210/12 exam from May/June 2015. The exam covers topics such as cookies, security issues, mobile phone touch screen technologies, logic gates, sensors, and computing terms. Candidates are required to answer multiple choice and written response questions testing their knowledge of these topics in computer science.
A database allows for the structured storage and organization of large amounts of data. Data is stored in tables which contain records made up of fields. Records are uniquely identified by a primary key field. Databases make data easy to manage, access, update, search, and sort. Common database management systems include MySQL, Access, Oracle, and others which allow users to create, modify, query and generate reports from database tables.
An array is a data structure that stores a collection of data items of the same type in a contiguous block of memory. It allows efficient access of elements using an index. One-dimensional arrays represent data as a linear list using a single index. Arrays simplify processing similar data by allowing batch operations. Pseudocode is provided to input student names and marks into arrays, calculate totals and averages, find the highest scoring student, calculate the average of user-input numbers using a loop, swap the first and last elements of an array, and find the largest and smallest elements in an array.
This document discusses ethics as it relates to computer use and technology. It defines ethics and discusses areas of ethics such as meta ethics, normative ethics, and applied ethics. It then discusses computer ethics specifically and issues like copyright, plagiarism, piracy, and free versus proprietary software. Computer ethics aims to ensure technology is used without harming others or violating moral values. Copyright protects original works from being copied or distributed without permission. Plagiarism involves taking credit for another's work. Piracy and illegal downloading violate copyright laws. Free software respects users' freedom to use, copy, distribute, and modify the software.
This document discusses data security and integrity. It covers various threats to data such as system crashes, corruption, hacking, and human errors. It recommends measures to secure data like backups, antivirus software, passwords, access controls, and encryption. The importance of regular backups, firewalls, and strong passwords is emphasized to prevent data loss and unauthorized access. Biometric security methods like fingerprints and voice recognition are also introduced.
The operating system controls the computer's hardware and software, acting as an interface between applications and hardware. It loads itself into RAM during startup through a bootstrapping process. The operating system manages user accounts, runs programs, allocates memory, controls devices, and performs housekeeping tasks. It uses various interfaces like graphical user interfaces and command line interfaces. Utility programs perform important system tasks like formatting disks, managing files, compressing files, and scanning for viruses. The operating system also manages buffers for temporary data storage, uses interrupts to communicate with devices, performs handshaking for connections, and calculates checksums to check data integrity. It is responsible for file creation, deletion, directories, and mapping files to storage.
This document discusses different types of computer storage, including primary storage (e.g. RAM, ROM), secondary storage (e.g. hard drives, flash drives, optical discs), and offline storage (e.g. CDs, DVDs, external hard drives). It describes the characteristics of different storage types, such as volatility, access methods, capacity and performance. A variety of specific storage devices are also outlined, such as hard drives, solid state drives, USB flash drives, optical discs, smart cards and external storage devices.
Input devices transfer data into a computer system for processing. There are manual input devices like keyboards and mice that require user entry, and direct data entry devices like smart cards that can automatically transfer information. Scanners use charge-coupled devices to register light reflected from documents and build images pixel by pixel. Barcode readers use lasers or cameras to scan barcodes and convert the spacing patterns to identifying numbers or letters. 3D scanners use various technologies like lasers or structured light to capture dense point clouds or meshes representing physical object geometries.
1.3.2 computer architecture and the fetch execute cycle By ZAKTabsheer Hasan
The document describes the Von Neumann architecture and the fetch-execute cycle of a CPU. It explains that Von Neumann introduced the concept of storing both instructions and data in memory. This allowed programs to be changed by modifying memory rather than rewiring the computer. It then outlines the registers involved in the fetch-execute cycle, including the program counter, instruction register, and accumulator. The cycle fetches an instruction from memory, decodes it, executes it, and then resets to fetch the next instruction, repeating continuously. The cycle provides the fundamental operation of a CPU.
computer architecture and the fetch execute cycle By ZAKTabsheer Hasan
The document describes the Von Neumann architecture and the fetch-execute cycle of a CPU. It explains that Von Neumann introduced the concept of storing both instructions and data in memory. This allowed programs to be changed by modifying memory rather than rewiring the computer. It then outlines the registers involved in the fetch-execute cycle, including the program counter, instruction register, and accumulator. The cycle fetches an instruction from memory, decodes it, executes it, and then resets to fetch the next instruction, repeating continuously. The cycle provides the fundamental processing model for modern CPU design.
The document discusses logic gates and their use in digital circuits. It describes the six main logic gates - NOT, AND, OR, NAND, NOR, and XOR - and explains their functions and truth tables. Logic gates can be combined to form more complex logic networks. Truth tables listing all possible input-output combinations are used to test the functionality of logic networks. Examples are given of designing logic networks to solve problems expressed in terms of logic gate operations and testing the solutions using truth tables.
The document discusses several key topics regarding how the internet works:
1) It describes how requests are routed from a user's computer to servers and back again using TCP/IP protocols and domain name servers to direct the request to the correct target server.
2) It explains the basic functions of web browsers in translating HTML code to display web pages and content, and some common web browsers like Chrome, Firefox, and Internet Explorer.
3) It provides an overview of how internet servers work, distinguishing between servers that provide services and client computers that connect to those services. Requests from clients are directed to specific server software like web, email, or FTP servers running on the overall server machine.
Serial And Parallel Data Transmission By ZAKTabsheer Hasan
Serial transmission sends data one bit at a time over a single transmission line, making it simple but slow. Parallel transmission sends multiple bits simultaneously over multiple lines, making it faster but less reliable and requiring more complex hardware. Modern devices primarily use serial transmission due to its ability to achieve high speeds without issues like crosstalk that affect parallel transmission. Error detection methods like parity bits allow receivers to detect errors by checking for an expected ratio of 1s and 0s in transmitted data.
This document discusses different methods for storing data on computers. It describes primary storage, such as RAM, and secondary storage, such as hard disks, which can hold much more data than primary storage but is slower to access. The document then discusses how different types of data, such as text, graphics, audio, and video, are represented and stored digitally. It also covers topics like data compression, animation, and error detection techniques used for digital storage.
How to Fix the Import Error in the Odoo 17Celine George
An import error occurs when a program fails to import a module or library, disrupting its execution. In languages like Python, this issue arises when the specified module cannot be found or accessed, hindering the program's functionality. Resolving import errors is crucial for maintaining smooth software operation and uninterrupted development processes.
বাংলাদেশের অর্থনৈতিক সমীক্ষা ২০২৪ [Bangladesh Economic Review 2024 Bangla.pdf] কম্পিউটার , ট্যাব ও স্মার্ট ফোন ভার্সন সহ সম্পূর্ণ বাংলা ই-বুক বা pdf বই " সুচিপত্র ...বুকমার্ক মেনু 🔖 ও হাইপার লিংক মেনু 📝👆 যুক্ত ..
আমাদের সবার জন্য খুব খুব গুরুত্বপূর্ণ একটি বই ..বিসিএস, ব্যাংক, ইউনিভার্সিটি ভর্তি ও যে কোন প্রতিযোগিতা মূলক পরীক্ষার জন্য এর খুব ইম্পরট্যান্ট একটি বিষয় ...তাছাড়া বাংলাদেশের সাম্প্রতিক যে কোন ডাটা বা তথ্য এই বইতে পাবেন ...
তাই একজন নাগরিক হিসাবে এই তথ্য গুলো আপনার জানা প্রয়োজন ...।
বিসিএস ও ব্যাংক এর লিখিত পরীক্ষা ...+এছাড়া মাধ্যমিক ও উচ্চমাধ্যমিকের স্টুডেন্টদের জন্য অনেক কাজে আসবে ...
Walmart Business+ and Spark Good for Nonprofits.pdfTechSoup
"Learn about all the ways Walmart supports nonprofit organizations.
You will hear from Liz Willett, the Head of Nonprofits, and hear about what Walmart is doing to help nonprofits, including Walmart Business and Spark Good. Walmart Business+ is a new offer for nonprofits that offers discounts and also streamlines nonprofits order and expense tracking, saving time and money.
The webinar may also give some examples on how nonprofits can best leverage Walmart Business+.
The event will cover the following::
Walmart Business + (https://business.walmart.com/plus) is a new shopping experience for nonprofits, schools, and local business customers that connects an exclusive online shopping experience to stores. Benefits include free delivery and shipping, a 'Spend Analytics” feature, special discounts, deals and tax-exempt shopping.
Special TechSoup offer for a free 180 days membership, and up to $150 in discounts on eligible orders.
Spark Good (walmart.com/sparkgood) is a charitable platform that enables nonprofits to receive donations directly from customers and associates.
Answers about how you can do more with Walmart!"
it describes the bony anatomy including the femoral head , acetabulum, labrum . also discusses the capsule , ligaments . muscle that act on the hip joint and the range of motion are outlined. factors affecting hip joint stability and weight transmission through the joint are summarized.
हिंदी वर्णमाला पीपीटी, hindi alphabet PPT presentation, hindi varnamala PPT, Hindi Varnamala pdf, हिंदी स्वर, हिंदी व्यंजन, sikhiye hindi varnmala, dr. mulla adam ali, hindi language and literature, hindi alphabet with drawing, hindi alphabet pdf, hindi varnamala for childrens, hindi language, hindi varnamala practice for kids, https://www.drmullaadamali.com
How to Manage Your Lost Opportunities in Odoo 17 CRMCeline George
Odoo 17 CRM allows us to track why we lose sales opportunities with "Lost Reasons." This helps analyze our sales process and identify areas for improvement. Here's how to configure lost reasons in Odoo 17 CRM
How to Setup Warehouse & Location in Odoo 17 InventoryCeline George
In this slide, we'll explore how to set up warehouses and locations in Odoo 17 Inventory. This will help us manage our stock effectively, track inventory levels, and streamline warehouse operations.
How to Add Chatter in the odoo 17 ERP ModuleCeline George
In Odoo, the chatter is like a chat tool that helps you work together on records. You can leave notes and track things, making it easier to talk with your team and partners. Inside chatter, all communication history, activity, and changes will be displayed.
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
This presentation was provided by Steph Pollock of The American Psychological Association’s Journals Program, and Damita Snow, of The American Society of Civil Engineers (ASCE), for the initial session of NISO's 2024 Training Series "DEIA in the Scholarly Landscape." Session One: 'Setting Expectations: a DEIA Primer,' was held June 6, 2024.
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Programming concepts By ZAK
1. Page 1 of 16
2.2 Programming
2.2.1 Programming concepts
Declare and use variables and constants
Variable
A variable is a value that can change during the execution of a program.
Constant
A constant is a value that is set when the program initializes and does not change throughout the program’s
execution.
Declaration
A declaration is a statement in a program that gives the compiler or the interpreter information about a
variable or constant that is to be used within a program.
A declaration ensures that sufficient memory is reserved in which to store the values and also states the
variables’ data type. Reserved words/keywords cannot be used as identifier names as this generates a compiler
error and comes under the category of syntax error.
Declaration of local variables
DIM MyCounter AS Integer
DIM FirstName, LastName AS String (declares two variables)
DIM TheLength AS Single
DIM DOB AS Date
DIM OverDueFlag AS Boolean
Scope
Scope indicates whether a variable can be used by all parts of a program or only within limited sections of the
program – for example, within a subroutine.
Global variable
A global variable is one that is declared at the start of the main program and is visible (useable) everywhere in
the program and exists for the lifetime of the program.
Note that if one procedure changes the value of a global variable, then the next procedure that uses the
variable will be given this changed value – this is a common cause of errors.
Local variable
A local variable is one that is only visible inside the procedure or function in which it is declared.
Note that a local variable cannot be referenced from outside the procedure. In fact a local variable does not
exist until the procedure starts executing and it disappears when the procedure stops executing. Thus any
value that is held by a local variable is only stored temporarily.
The lifetime of a local variable is the lifetime of the procedure in which the local variable is declared.
The advantage of using local variables rather than global variables is that the same variable names can be used
in several different procedures without any chance of values being confused.
Features of variables:
2. Page 2 of 16
2.2 Programming
2.2.1 Programming concepts
Holds data in memory
Are assigned a data type
The data can change throughout the program’s operation
The data input must be the same data type as assigned to that variable
Variables are assigned a name that holds the data. That name is used to distinguish it from the other variables
in your program. The name must not start with a number or character that is not a letter. Also, the name of the
variable must not be a reserved word like PRINT, INPUT, LET, ABS, BEEP, etc.
There are two ways to declare a variable in Basic.
The first is to put a data type symbol after the name
$ String
% Integer
! Single
# Double
Examples:
MyName$
Num1%
Num2!
Answer!
3. Page 3 of 16
2.2 Programming
2.2.1 Programming concepts
Sample Code:
CLS
Header$ = "This is an example program"
Num1% = 5
Num2% = 6
Num5! = 4.5
Num6! = 6.75
Num7# = 56000.25
Num8# = 89000.34
CLS
PRINT Header$
PRINT Num1% + Num2%
PRINT Num6! / Num5!
PRINT Num8# + Num2%
The second way is the preferred way since Visual Basic uses this method. DIM is used to make variables of a
data type.
DIM [Variable Name] As Data Type
DIM [Variable Name] AS STRING
DIM [Variable Name] AS INTEGER
DIM [Variable Name] AS LONG
DIM [Variable Name] AS SINGLE
DIM [Variable Name] AS DOUBLE
Examples:
DIM MyName AS STRING
DIM Num1 AS INTEGER
DIM Num2 AS SINGLE
DIM Answer AS SINGLE
Code:
DIM Num1 AS INTEGER
DIM Num2 AS LONG
DIM Num3 AS SINGLE
DIM Num4 AS DOUBLE
DIM Header AS STRING
CLS
Header = "This is another example"
Num1 = 5
Num2 = 56000
Num3 = 45.635
Num4 = 66000.5634#
4. Page 4 of 16
2.2 Programming
2.2.1 Programming concepts
PRINT Header
PRINT Num1 + Num2 + Num3 + Num4
Remember that selecting the right data type for the variable is very important to make the program run
properly.
Using declared constants
Constants will be declared at the start of the main program. The following shows the declaration of constants
for Pi and the Value added tax rate.
CONST Pi = 3.14159
CONST VatRate = 0.175
Declaring constants at the start of a program means that maintenance is made easier for two reasons:
If the value of a constant changes, it only has to be changed in the one part of the program
where it has been declared, rather than in each part of the program in which it is used;
the code is easier to interpret:
For example:
Total=VatRate*CostPrice
Total=0.175*CostPrice
In the first statement, one can easily understand that the Total is the product of 2 variables
whereas; the VATRate was manually entered in the second statement creating ambiguity and a chance that the
VAT could be entered incorrectly
5. Page 5 of 16
2.2 Programming
2.2.1 Programming concepts
Understand and use basic data types
Define and use different data types e.g. integer, real, boolean, character and string
A data type is a method of interpreting a pattern of bits.
Data types and data structures
Intrinsic data types
Intrinsic data types are the data types that are defined within a particular programming language.
There are numerous different data types. They are used to make the storage and processing of data easier and
more efficient. Different databases and programming systems have their own set of intrinsic data types, but
the main ones are:
Integer;
Real;
Boolean;
String;
Character;
Container
Integer
An integer is a positive or negative number that does not contain a fractional part. Integers are held in pure
binary for processing and storage. Note that some programming languages differentiate between short and
long integers (more bytes being used to store long integers).
Real
A real is a number that contains a decimal point. In many systems, real numbers are referred to as singles and
doubles, depending upon the number of bytes in which they are stored.
Boolean
A Boolean is a data-type that can store one of only two values – usually these values are True or False.
Booleans are stored in one byte – True being stored as 11111111 and False as 00000000.
6. Page 6 of 16
2.2 Programming
2.2.1 Programming concepts
String
A string is a series of alphanumeric characters enclosed in quotation marks. A string is sometimes just referred
to as ‘text’. Any type of alphabetic or numeric data can be stored as a string: “Birmingham City”, “3/10/03”
and “36.85” are all examples of strings. Each character within a string will be stored in one byte using its
ASCII code; modern systems might store each character in two bytes using its Unicode. The maximum length
of a string is limited only by the available memory.
Dates
In most computer systems dates are stored as a ‘serial’ number that equates to the number of seconds since
January 1st, 1904 (thus they also contain the time). Although the serial numbers are used for processing
purposes, the results are usually presented in one of several ‘standard’ date formats – for example,
dd/mm/yyyy, or dd MonthName, yyyy. Dates usually take 8 bytes of storage.
Notes:
if dates or numbers are stored as strings then they will not be sorted correctly; they will be sorted
according to the ASCII codes of the characters – “23” will be placed before “9”;
Telephone numbers must be stored as strings or the leading zero will be lost.
Character
A character is any letter, number, punctuation mark or space, which takes up a single unit of storage (usually a
byte).
Comparison of the common data types:
7. Page 7 of 16
2.2 Programming
2.2.1 Programming concepts
Program construct in Basic:
1.1) Counting
Counting in 1s is quite simple; use of the statement count = count + 1 will enable counting to be done (e.g. in controlling
a repeat loop).
The statement literally means: the (new) count = the (old) count + 1
It is possible to count in any increments just by altering the numerical value in the statement (e.g. count = count – 1) will
counts backwards.
1.2) Totaling
To add up a series numbers the following type of statement should be used:
total = total + number
This literally means (new) total = (old) total + value of number
| 10 x = 1 |
| 20 sum = 0 |
| 30 print x |
| 40 input "enter a number";n |
| 50 sum = sum + n |
| 60 x = x + 1 |
| 70 if x < 11 then goto 30 |
| 80 print "The sum of the numbers you gave is";sum |
Sequence: Execution of the program usually following the order in which the steps are written.
Selection: A decision between alternative routes through the program that involves at least one condition.
Repetition: A step or sequence of steps repeated within the program as an iteration or loop.
8. Page 8 of 16
2.2 Programming
2.2.1 Programming concepts
The structure of procedural programs
Statement, subroutine, procedure, function, parameter, loop
Procedural programs are ones in which instructions are executed in the order defined by the programmer.
Procedural languages are often referred to as third generation languages and include FORTRAN, ALGOL,
COBOL, BASIC, and PASCAL.
Statement
A statement is a single instruction in a program, which can be converted into machine code and executed.
In most languages a statement is written on a single line, but some languages allow multiple lines for single
statements.
Examples of statements are:
DIM name As String
A=X*X
While x < 10
Procedure
A procedure is a subroutine that performs a specific task without returning a value to the part of the program
from which it was called.
Function
A function is a subroutine that performs a specific task and returns a value to the part of the program from
which it was called.
Note that a function is ‘called’ by writing it on the right hand side of an assignment statement.
9. Page 9 of 16
2.2 Programming
2.2.1 Programming concepts
Parameter
A parameter is a value that is ‘received’ in a subroutine (procedure or function).
The subroutine uses the value of the parameter within its execution. The action of the subroutine will be
different depending upon the parameters that it is passed.
Parameters are placed in parenthesis after the subroutine name. For example:
Square (5) ‘passes the parameter 5 – returns 25
Square (8) ‘passes the parameter 8 – returns 64
Square(x) ‘passes the value of the variable x
Understand, create and use subroutines (procedures and functions), including the passing of
parameters and the appropriate use of the return value of functions
Use subroutines to modularize the solution to a problem
Subroutine/sub-program
A subroutine is a self-contained section of program code which performs a specific task and is referenced by a
name.
A subroutine resembles a standard program in that it will contain its own local variables, data types, labels and
constant declarations.
There are two types of subroutine. These are procedures and functions.
Procedures are subroutines that input, output or manipulate data in some way;
Functions are subroutines that return a value to the main program.
A subroutine is executed whenever its name is encountered in the executable part of the main program. The
execution of a subroutine by referencing its name in the main program is termed ‘calling’ the subroutine.
The advantage of using procedures and functions are that:
The same lines of code are re-used whenever they are needed – they do not have to be repeated in
different sections of the program.
A procedure or function can be tested/improved/rewritten independently of other procedures or
functions.
It is easy to share procedures and functions with other programs – they can be incorporated into
library files which are then ‘linked’ to the main program;
A programmer can create their own routines that can be called in the same way as any built-in
command.
Sub Statement (Visual Basic)
Declares the name, parameters, and code that define a Sub procedure.
10. Page 10 of 16
2.2 Programming
2.2.1 Programming concepts
Sub name [ (Of typeparamlist) ] [ (parameterlist) ]
[ statements ]
[ Exit Sub ]
[ statements ]
End Sub
All executable code must be inside a procedure. Use a Sub procedure when you don't want to return a value to the calling
code. Use a Function procedure when you want to return a value.
Sample Code:
Sub computeArea(ByVal length As Double, ByVal width As Double)
' Declare local variable.
Dim area As Double
If length = 0 Or width = 0 Then
' If either argument = 0 then exit Sub immediately.
Exit Sub
End If
' Calculate area of rectangle.
area = length * width
' Print area to Immediate window.
Debug.WriteLine(area)
End Sub
Function Statement (Visual Basic)
Declares the name, parameters, and code that define a Function procedure.
Function name [ (Of typeparamlist) ] [ (parameterlist) ]
[ As returntype ]
[ statements ]
[ Exit Function ]
[ statements ]
End Function
Sample Code:
Function myFunction(ByVal j As Integer) As Double
Return 3.87 * j
End Function
11. Page 11 of 16
2.2 Programming
2.2.1 Programming concepts
Convert following pseudocode into programs using any high level language:
The following five examples use the above pseudocode terms. These are the same problems discussed in
section 3.1 using flow charts – both methods are acceptable ways of representing an algorithm.
2.1 Example 1
A town contains 5000 houses. Each house owner must pay tax based on the value of the house. Houses over
$200 000 pay 2% of their value in tax, houses over $100 000 pay 1.5% of their value in tax and houses over
$50 000 pay 1% of their value in tax. All others pay no tax.
Write an algorithm to solve the problem using pseudocode.
for count 1 to 5000
input house
if house > 50 000 then tax house * 0.01
else if house > 100 000 then tax house * 0.015
else if house > 200 000 then tax house * 0.02
else tax 0
print tax
next
For example,
count 0
while count < 5001
input house
if house > 50000 then tax house * 0.01
else if house > 100 000 then tax house * 0.015
else if house > 200 000 then tax house * 0.02
else tax 0
endif
endif
endif
print tax
count = count + 1
endwhile
EXERCISE: Re-write the above algorithm using a repeat loop and modify the if … then … else statements to include
both parts of the house price range.
(e.g. if house > 50000 and house <= 100000 then tax = house * 0.01)
12. Page 12 of 16
2.2 Programming
2.2.1 Programming concepts
2.2 Example 2
The following formula is used to calculate n: n = x * x/(1 – x)
The value x = 0 is used to stop the algorithm. The calculation is repeated using values of x until the value x =
0 is input. There is also a need to check for error conditions. The values of n and x should be output.
Write an algorithm to show this repeated calculation using pseudocode.
NOTE: It is much easier in this example to input x first and then loop round doing the calculation until
eventually x = 0. Because of this, it would be necessary to input x twice (i.e. inside the loop and outside the
loop). If input x occurred only once it would lead to a more complicated algorithm.
(Also note in the algorithm that <> is used to represent ≠ ).
A while loop is used here, but a repeat loop would work just as well.
input x
while x <> 0 do
if x = 1 then print “error”
else n = (x * x)/(1 – x)
print n, x
endif
input x
endwhile
2.3 Example 3
Write an algorithm using pseudocode which takes temperatures input over a 100 day period (once per day) and output the
number of days when the temperature was below 20C and the number of days when the temperature was 20C or above.
(NOTE: since the number of inputs is known, a for … to loop can be used. However, a while loop or a repeat loop
would work just as well).
total1 = 0 : total2 = 0
for days = 1 to 100
input temperature
if temperature < 20 then total1 = total1 + 1
else total2 = total2 + 1
endif
next
print total1, total2
This is a good example of an algorithm that could be written using the case construct rather than if … then … else. The
following section of code replaces the statements if temperature < 20 then …… endif:
case temperature of
1: total1 = total1 + 1
2: total2 = total2 + 1
endcase
2.4 Example 4
Write an algorithm using pseudocode which:
inputs the top speeds of 5000 cars
13. Page 13 of 16
2.2 Programming
2.2.1 Programming concepts
outputs the fastest speed and the slowest speed
outputs the average speed of all the 5000 cars
(NOTE: Again since the actual number of data items to be input is known any one of the three loop structures
could be used. It is necessary to set values for the fastest (usually set at zero) and the slowest (usually set at an
unusually high value) so that each input can be compared. Every time a value is input which > the value stored
in fastest then this input value replaces the existing value in fastest; and similarly for slowest).
fastest = 0: count = 0
slowest = 1000
repeat
input top_speed
total = total + top_speed
if top_speed > fastest then fastest = top_speed
if top_speed < slowest then slowest = top_speed
endif
endif
count + count + 1
until count = 5000
average = total * 100/5000
print fastest, slowest, average
14. Page 14 of 16
2.2 Programming
2.2.1 Programming concepts
2.5 Example 5
A shop sells books, maps and magazines. Each item is identified by a unique 4 – digit code. All books have a
code starting with a 1, all maps have a code starting with a 2 and all magazines have a code beginning with a
3. The code 9999 is used to end the program.
Write an algorithm using pseudocode which input the codes for all items in stock and outputs the number of
books, maps and magazine in stock. Include any validation checks necessary.
(NOTE: A 4-digit code implies all books have a code lying between 1000 and 1999, all maps have a code
lying between 2000 and 2999 and all magazines a code lying between 3000 and 3999. Anything outside this
range is an error)
books = 0: maps = 0: mags = 0
repeat
input code
if code > 999 and code < 2000 then books = books + 1
else if code > 1999 and code < 3000 then maps = maps + 1
else if code > 2999 and code < 4000 then mags = mags + 1
else print “error in input”
endif:endif:endif
until code = 9999
print books, maps, mags
(NOTE: A function called INT(X) is useful in questions like this. This returns the integer (whole number) part
of X e.g. if X = 1.657 then INT(X) = 1; if X = 6.014 then INT(X) = 6 etc. Using this function allows us to use
the case statement to answer this question:
books = 0: maps = 0: mags = 0
repeat
input code
x = INT(code/1000) * divides code by 1000 to give a
case x of * number between 0 and 9
1: books = books + 1
2: maps = maps + 1
3: mags = mags + 1
otherwise print “error”
endcase
until code = 9999
print books, maps, mags
(This is probably a more elegant but more complex solution to the problem)
15. Page 15 of 16
2.2 Programming
2.2.1 Programming concepts
Past Paper Questions:
May/June 2006 P1
a) Give two benefits of using a high-level language for writing programs. [2]
(b) State one type of program that would be written in a low-level language rather than a high-level language
and give a reason why. [2]
Oct/Nov 2007 P1
Give two differences between high level languages and low level languages.
Oct/Nov 2009 P1
Give two advantages of using high level languages when writing new computer software rather than using low
level languages
May/June 2010 P11
10 (a) Compilers and interpreters translate high-level languages. Give two differences between compilers and
interpreters.
(b) Programs can be written using high-level or low-level languages.
Give one advantage of using each method.
High-level language advantage
Low-level language advantage
(c) What is meant by top-down design when developing new software?
May/June 2011 P12
1 h = 0
2 c = 0
3 REPEAT
4 READ x
5 IF x > h THEN x = h
6 c = c + 1
7 PRINT h
8 UNTIL c < 20
The above code is an example of a high-level language.
Give TWO features of a high-level language. [2]
(c) The code is to be interpreted rather than compiled.
Give ONE difference between these two methods. [1]
16. Page 16 of 16
2.2 Programming
2.2.1 Programming concepts
May/June 2012 P12
Look at these two pieces of code:
(a) Which of these pieces of code is written in a high-level language? [1]
(b) Give one benefit of writing code in a high-level language. [1]
(c) Give one benefit of writing code in a low-level language. [1]
(d) High-level languages can be compiled or interpreted.
Give two differences between a compiler and an interpreter.