final requirement for programming-bonifacio, mary clemence

35
Final Requirement for Programming Switch Case and Looping http://eglobiotraining.c om/

Upload: clemencebonifacio

Post on 24-Dec-2014

196 views

Category:

Documents


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Final requirement for programming-Bonifacio, Mary Clemence

Final Requirement for Programming

Switch Case and Looping

http://eglobiotraining.com/

Page 2: Final requirement for programming-Bonifacio, Mary Clemence

What is Programming?Programming is coding, modeling,

simulating or presenting the solution to a problem, by representing facts, data or information using pre-defined rules and semantics, on a computer or any other device for automation.

Programming is the art and science of translating a set of ideas into a program - a list of instructions a computer can follow. The person writing a program is known as a programmer (also a coder).

http://eglobiotraining.com/

Page 3: Final requirement for programming-Bonifacio, Mary Clemence

A programming language is a stylized communication technique intended to be used for controlling the behavior of machine (computer). Like human languages programming languages have syntactic and semantic rules used to define meaning.

Thousands of different programming languages have been created and new ones are created every year.

The development of programming languages follows closely the development of the physical and electronic processes used in today’s computers.

http://eglobiotraining.com/

Page 4: Final requirement for programming-Bonifacio, Mary Clemence

The term programming language usually refers to high-level languages, such as BASI, C, CC++, COBOL, FORTRAN, Ada, and Pascal. Each language has a unique set of keywords (words that programming understands) and a special syntax for organizing program instructions.

High-level programming languages, while simple compared to human languages, are more complex than the languages the computer actually understands, called machine languages. Each different type of CPU has its own unique machine language.

http://eglobiotraining.com/

Page 5: Final requirement for programming-Bonifacio, Mary Clemence

C Programming is a powerful system programming language

C++ Programming is an excellent general purpose programming language

Dev-C++ is a specialized programming tool which allows to edit and compile codes of applications based on C/C++.

http://eglobiotraining.com/

Page 6: Final requirement for programming-Bonifacio, Mary Clemence

As a student, I have to learn and understand programming, I have to be familiar with it. Because programming is one of the subjects that I’ am currently taking this semester.

At first, I find programming very difficult and confusing. You should know first the basic rules in programming for you to understand it better. There are lots of things that you have to consider in programming, especially when entering the codes, you must be very careful with it.

http://eglobiotraining.com/

Page 7: Final requirement for programming-Bonifacio, Mary Clemence

Switch Case

Switch statement (a programming language) compares the value of an expression against a list of integers or character constants. The list of constants are listed using the "case" statement along with a "break" statement to end the execution.

http://eglobiotraining.com/

Page 8: Final requirement for programming-Bonifacio, Mary Clemence

The switch case statement is useful programming and it is a better way of writing a program when a series of if elses occurs. The general format for this is,

The keyword break must be included at the end of each case statement. The default clause is optional, and is executed if the cases are not met. The right brace at the end signifies the end of the case selections.

http://eglobiotraining.com/

Page 9: Final requirement for programming-Bonifacio, Mary Clemence

Rules for switch statements

• values for 'case' must be integer or character

• constants the order of the 'case' statements is unimportant

• the default clause may occur first (convention places it last)

• you cannot use expressions or ranges

http://eglobiotraining.com/

Page 10: Final requirement for programming-Bonifacio, Mary Clemence

LoopsA loop is a programming

language, it is a way of repeating a statement a number of times until some way of ending the loop occurs.

These include following categories:1. for loop

2. while loop3. do while

http://eglobiotraining.com/

Page 11: Final requirement for programming-Bonifacio, Mary Clemence

Example of For Loop

http://eglobiotraining.com/

Page 12: Final requirement for programming-Bonifacio, Mary Clemence

Example of While Loop

http://eglobiotraining.com/

Page 13: Final requirement for programming-Bonifacio, Mary Clemence

Example of Do While Loop

http://eglobiotraining.com/

Page 14: Final requirement for programming-Bonifacio, Mary Clemence

The Codes and Explanations of the Program that I have tested

andThe Output

Program Using Dev C++

http://eglobiotraining.com/

Page 15: Final requirement for programming-Bonifacio, Mary Clemence

Switch Case 1

http://eglobiotraining.com/

Page 16: Final requirement for programming-Bonifacio, Mary Clemence

This is the output program of switch case 1.It says that there “Enter the day of the week between 1-7”, if you enter a number between 1-7, the day that correspond to that number will appear. For example, you entered number 3, Wednesday will appear because it is the 3rd day in the week.

http://eglobiotraining.com/

Page 17: Final requirement for programming-Bonifacio, Mary Clemence

Switch Case 2

http://eglobiotraining.com/

Page 18: Final requirement for programming-Bonifacio, Mary Clemence

This is the output program of switch case 2.The first output shows that the number entered is equal to n which is equivalent to 1,2,3. And the second output shows that the number entered is not equal to n. Because n is equal to 1,2 and 3 only.

http://eglobiotraining.com/

Page 19: Final requirement for programming-Bonifacio, Mary Clemence

Switch Case 3

http://eglobiotraining.com/

Page 20: Final requirement for programming-Bonifacio, Mary Clemence

This is the output program of switch case 3.In programming, we can create statement that will ask you to choose your answer from its choices and will tell you what you have chose, just like the output above. Using switch case statement I find programming a little bit fun.

http://eglobiotraining.com/

Page 21: Final requirement for programming-Bonifacio, Mary Clemence

Switch Case 4

http://eglobiotraining.com/

Page 22: Final requirement for programming-Bonifacio, Mary Clemence

This is the output program of switch case 4.This program shows the computation of the scores of the student. It shows there the name of the student, the total no. of score entered, the total score and the total average score.

http://eglobiotraining.com/

Page 23: Final requirement for programming-Bonifacio, Mary Clemence

Switch Case 5

http://eglobiotraining.com/

Page 24: Final requirement for programming-Bonifacio, Mary Clemence

This is the output program of switch case 5.The program ask to enter a number between 1 to 5, I entered 5 and the word five appeared.

http://eglobiotraining.com/

Page 25: Final requirement for programming-Bonifacio, Mary Clemence

Looping 1

http://eglobiotraining.com/

Page 26: Final requirement for programming-Bonifacio, Mary Clemence

This is the output program of Looping 1.Here, I used the for loop in making this program. It shows there numbers starting from 0 to 10. http://eglobiotraining.com/

Page 27: Final requirement for programming-Bonifacio, Mary Clemence

Looping 2

http://eglobiotraining.com/

Page 28: Final requirement for programming-Bonifacio, Mary Clemence

This is the output program of Loop 2.Programming can also create statements like counting numbers, in this program it ask to count from 20 to 45 by 5. This is a for loop statement.

http://eglobiotraining.com/

Page 29: Final requirement for programming-Bonifacio, Mary Clemence

Looping 3

http://eglobiotraining.com/

Page 30: Final requirement for programming-Bonifacio, Mary Clemence

This is the output program of Loop 3.In programming, we can create statement that will not stop unless you enter a valid variable. The first output shows “please enter an integer between 1 and 10”, if enter a valid number then the program will close. In the second output it shows there that in the first statement the number entered is invalid, the statement will keep on repeating and it will only stop until you enter a valid number. This is a while loop statement.

http://eglobiotraining.com/

Page 31: Final requirement for programming-Bonifacio, Mary Clemence

Looping 4

http://eglobiotraining.com/

Page 32: Final requirement for programming-Bonifacio, Mary Clemence

This is the output program of Loop 4.There are some statements in programming that are easy to do, just like this one. It is a while loop statement, this program is only simple you can only see there the word “Hello”.

http://eglobiotraining.com/

Page 33: Final requirement for programming-Bonifacio, Mary Clemence

Looping 5

http://eglobiotraining.com/

Page 34: Final requirement for programming-Bonifacio, Mary Clemence

This is the output program of loop 5.We can also use programming in solving some mathematical problems. This is a while loop statement, as you can see there it asks you to “enter number of apples ate” this will show five times every time you enter a number and the total of it will be divided to 2.

http://eglobiotraining.com/

Page 35: Final requirement for programming-Bonifacio, Mary Clemence

Submitted to: Prof. Erwin Globiohttp://eglobiotraining.com/

Submitted by:Bonifacio, Mary Clemence A.BM10203

http://eglobiotraining.com/