final requirement for programming-bonifacio, mary clemence

Click here to load reader

Post on 24-Dec-2014




1 download

Embed Size (px)




  • 1. Final Requirement forProgrammingSwitch Case and Looping

2. What is Programming?Programming is coding, modeling,simulating or presenting the solution to aproblem, by representing facts, data orinformation using pre-defined rules andsemantics, on a computer or any otherdevice for automation.Programming is the art and science oftranslating a set of ideas into a program - alist of instructions a computer can follow.The person writing a program is known as aprogrammer (also a coder). 3. A programming language is a stylizedcommunication technique intended to beused for controlling the behavior of machine(computer). Like human languagesprogramming languages have syntactic andsemantic rules used to define meaning. Thousands of different programminglanguages have been created and new onesare created every year. The development of programminglanguages follows closely the developmentof the physical and electronic processesused in todays computers. 4. The term programming language usuallyrefers to high-level languages, such asBASI, C, CC++, COBOL, FORTRAN, Ada, andPascal. Each language has a unique set ofkeywords (words that programmingunderstands) and a special syntax fororganizing program instructions. High-level programming languages, whilesimple compared to human languages, aremore complex than the languages thecomputer actually understands, calledmachine languages. Each different type ofCPU has its own unique machine language. 5. C Programming is a powerful systemprogramming language C++ Programming is an excellentgeneral purpose programming language Dev-C++ is a specialized programmingtool which allows to edit and compile codesof applications based on C/C++. 6. As a student, I have to learn and understandprogramming, I have to be familiar with it.Because programming is one of the subjectsthat I am currently taking this semester.At first, I find programming very difficult andconfusing. You should know first the basic rulesin programming for you to understand it better.There are lots of things that you have toconsider in programming, especially whenentering the codes, you must be very carefulwith it. 7. Switch Case Switch statement (aprogramming language) comparesthe value of an expression againsta list of integers or characterconstants. The list of constantsare listed using the "case"statement along with a "break"statement to end the execution. 8. The switch case statement is useful programming and it is a better way of writing a program when a series of if elses occurs. Thegeneral format for this is,The keyword break must be included at the end of each casestatement. The default clause is optional, and is executed ifthe cases are not met. The right brace at the end signifiesthe end of the case selections. 9. Rules for switch statements values for case must be integeror character constants the order of the casestatements is unimportant the default clause may occur first(convention places it last) you cannot use expressions orranges 10. 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 loop2. while loop 3. do while 11. Example of For Loop 12. Example of While Loop 13. Example of Do While Loop 14. The Codes and Explanations ofthe Program that I have tested and The Output Program Using Dev C++ 15. Switch Case 1 16. This is the output program of switch case 1.It says that there Enter the day of the weekbetween 1-7, if you enter a number between1-7, the day that correspond to that numberwill appear. For example, you entered number3, Wednesday will appear because it is the 3rd 17. Switch Case 2 18. This is the output program of switchcase 2.The first output shows that the numberentered is equal to n which isequivalent to 1,2,3. And the secondoutput shows that the number entered 19. Switch Case 3 20. This is the output program of switch case 3.In programming, we can create statement that willask you to choose your answer from its choicesand will tell you what you have chose, just like theoutput above. Using switch case statement I find a little bit fun. 21. Switch Case 4 22. This is the output program of switch case 4.This program shows the computation of thescores of the student. It shows there thename of the student, the total no. of scoreentered, the total score and the totalaverage score. 23. Switch Case 5 24. This is the output program of switch case 5.The program ask to enter a number between 1 to5, I entered 5 and the word five appeared. 25. Looping 1 26. This is the output program of Looping 1.Here, I used the for loop in making thisprogram. It shows there numbers startingfrom 0 to 10. 27. Looping 2 28. This is the output program of Loop 2.Programming can also createstatements like counting numbers, inthis program it ask to count from 20 to by 5. This is a for loop statement. 29. Looping 3 30. This is the output program of Loop 3.In programming, we can create statement that will not stop unlessyou enter a valid variable. The first output shows please enter aninteger between 1 and 10, if enter a valid number then theprogram will close. In the second output it shows there that in thefirst statement the number entered is invalid, the statement willkeep on repeating and it will only stop until you enter a valid This is a while loop statement. 31. Looping 4 32. This is the output program of Loop 4.There are some statements in programmingthat are easy to do, just like this one. It is awhile loop statement, this program is onlysimple you can only see there the word 33. Looping 5 34. This is the output program of loop 5.We can also use programming in solving somemathematical problems. This is a while loopstatement, as you can see there it asks you toenter number of apples ate this will show fivetimes every time you enter a number and the total 35. Submitted to:Prof. Erwin Globio by:Bonifacio, Mary Clemence A.BM10203