Your SlideShare is downloading. ×
0
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Fundamentals of prog. by rubferd medina

51

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
51
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Final Requirement To be passed to: Prof. Erwin M. GlobioRubferd Eric F. MedinaBm10203 http://eglobiotraining.com.
  • 2. PROGRAMING A Programing language is used to write computerprograms such as application and utilities. Programing allows a programmer or end user todevelop the sets of instructions that constitute a computerprogram or software. The role of a programing language can bedescribed in two ways:Technical: It is a means for instructing a Computer to performTasksConceptual: It is a framework within which we organize ourideas about things and processes. http://eglobiotraining.com
  • 3. As an individual, I have learned that programming is avery broad because it composes many scripts, applications andcan be used to run a program that has been part of theprogramming language. A programming language should both provide means todescribe primitive data and procedures and means to combineand abstract those into more complex ones. The distinction between data and procedures is not thatclear cut. In many programming languages, procedures can bepassed as data (to be applied to ``real data) and sometimesprocessed like ``ordinary data. Conversely ``ordinary data canbe turned into procedures by an evaluation mechanism. http://eglobiotraining.com
  • 4. At first, programming is confusing because you have somuch to understand about codes that will enable to run aprogram. Programming has applications and programdevelopment, the best example for this is the Internet bowser… Programming is a creative process done by programmersto instruct a computer on how to do a task. Fundamentallyprograms manipulate numbers and text. These are the buildingblocks of all programs.Programming languages let you use them in different ways, e.gadding numbers, etc… or storing data on disk for later retrieval. http://eglobiotraining.com
  • 5. You have to consider languages to run or write your ownprogram, most demanded language in programming is the DEV C++(a full-featured Integrated Development Environment (IDE)). C++ is one of the most used programming languages in theworld. Also known as "C with Classes".New to programming or thinking about it? It might surprise you toknow that there are many programmers who program just for funand it can lead to a job. http://eglobiotraining.com
  • 6. SWITCH CASE!Uses a C Programing Language http://eglobiotraining.com
  • 7. Switch case statements are a substitute for long ifstatements that compare a variable to several"integral" values ("integral" values are simply valuesthat can be expressed as an integer, such as the valueof a char). The value of the variable given into switch iscompared to the value following each of the cases, andwhen one value matches the value of the variable, thecomputer continues executing the program from thatpoint. http://eglobiotraining.com
  • 8. The default case is optional, but it is wise to include itas it handles any unexpected cases. Switchstatements serves as a simple way to write long ifstatements when the requirements are met. Often itcan be used to process input from a user. http://eglobiotraining.com
  • 9. http://eglobiotraining.com
  • 10. This program will compile, but cannot be run until theundefined functions are given bodies, but it serves asa model (albeit simple) for processing input. If you donot understand this then try mentally putting in ifstatements for the case statements. Default simplyskips out of the switch case construction and allowsthe program to terminate naturally. If you do not likethat, then you can make a loop around the wholething to have it wait for valid input. You could easilymake a few small functions if you wish to test thecode. http://eglobiotraining.com
  • 11. The switch-case statement is a multi-way decision statement.Unlike the multiple decision statement that can be createdusing if-else, the switch statement evaluates theconditional expression and tests it against numerousconstant values. The branch corresponding to the value that theexpression matches is taken during execution. The value of the expressions in a switch-case statementmust be an ordinal type i.e. integer, char, short, long etc. Floatand double are not allowed. The syntax is : http://eglobiotraining.com
  • 12. The case statements and the default statement can occur inany order in the switch statement. The default clause is anoptional clause that is matched if none of the constants inthe case statements can be matched. Consider the example shown below: http://eglobiotraining.com
  • 13. Here, if the Grade is A then the output will be: http://eglobiotraining.com
  • 14. This is because, in the C switch statement, executioncontinues on into the next case clause if it is not explicitlyspecified that the execution should exit the switch statement.The correct statement would be: http://eglobiotraining.com
  • 15. Although the break in the default clause (or in general, afterthe last clause) is not necessary, it is good programmingpractice to put it in anyway. An example where it is better to allow the execution tocontinue into the next case statement: http://eglobiotraining.com
  • 16. Looping Statement!Uses a C Programing Statement http://eglobiotraining.com
  • 17. while ( expression ) statementIn a while loop, the expression is evaluated. If nonzero, the statement executes, and theexpression is evaluated again. This happens over and over until the expressions value iszero. If the expression is zero the first time it is evaluated, statement is not executed atall.do statementwhile ( expression);A do while loop is just like a plain while loop, except the statement executes before theexpression is evaluated. Thus, the statement will always be evaluated at least once. for ( expression1; expression2; expression3 ) statementIn a for loop, first expression1 is evaluated. Then expression2 is evaluated, and if it is zeroEEL leaves the loop and begins executing instructions after statement. Otherwise thestatement is executed, expression3 is evaluated, and expression2 is evaluated again,continuing until expression2 is zero. You can omit any of the expressions. If you omit expression2, it islike expression2 is nonzero. while (expression) is the same as for (; expression; ). Thesyntax for (;;) creates an endless loop that must be exited using the break statement (orone of the other statements described below). http://eglobiotraining.com
  • 18. Types of LoopingThat can be use in Programing The for loop construct is used is used to repeat a statement or block of statements a specific number of times. The while loop construct only contains condition. The do while, the difference between do while loop and other loops is that in the do while loop the condition comes after the statement http://eglobiotraining.com
  • 19. The Breakin ProgramingThe break keyword is used to terminate aloop, intermediately bypassing any conditions. Thecontrol will be transferred to the first statement followingthe loop block. The break statement can be used toterminate an infinite loop or to force a loop to end beforeits normal termination. http://eglobiotraining.com
  • 20. My Programs that I use in Programing http://eglobiotraining.com
  • 21. #include<stdio.h>#include<conio.h>int main(void){ int n; printf("rank yourself from 1-3: "); scanf("%d",&n); switch(n) { case 1: printf("bad"); break; case 2: printf("fair"); break; case 3: printf("good"); break; default: printf("invalid"); break; } getch(); Case 1 & Output return 0; } http://eglobiotraining.com
  • 22. Here, I program that if you type and enter number 1,the computer will answer “bad” but if you use number2, the computer will answer “fair” and last is number 3,the computer will answer “good” just like in theprevious slide. http://eglobiotraining.com
  • 23. #include<stdio.h>#include<conio.h>int main(void){ int n; printf("1+1+2-3= "); scanf("%d",&n); switch(n) { case 1: printf("correct"); break; default: printf("wrong"); break; } getch(); return 0; Case 2 & Output } http://eglobiotraining.com
  • 24. Here in case two. If the answer was correct thecomputer were about to answer “correct” but if youranswer is incorrect the computer were program toanswer “wrong” http://eglobiotraining.com
  • 25. #include<stdio.h>#include<conio.h>int main(void){ char n; printf("what is the title of the philippine national anthem?na)bayang magiliwnb)lupang hinirangnc)ang bayan ko "); scanf("%c",&n); switch(n) { case a: printf("wrong"); break; case b: printf("correct"); break; case c: printf("wrong"); break; default: printf("invalid choice"); break; } getch(); return 0; Case 3 & Output } http://eglobiotraining.com
  • 26. Here in case 3, I do some choices in the question “whatis the tittle of the Philippine national anthem?” thechoices are a)Bayang magiliw, b)lupang hinirang orc)Ang bayan ko. The correct answer is letter “B” if youchoose the correct letter the computer will answer“Correct” but if you choose a wrong answer thecomputer will answer “wrong” just like in the previousslide. http://eglobiotraining.com
  • 27. #include<stdio.h>#include<conio.h>int main(void){ int n; printf("(4+4)x5= "); scanf("%d",&n); switch(n) { case 40: printf("correct"); break; default: printf("wrong"); break; } getch(); return 0; Case 4 & Output } http://eglobiotraining.com
  • 28. Here in case 4. I use some math question so that thestudent will think of what is the correct answer. “40” isthe correct answer if they got it right the computer willprint “CORRECT” but if it is incorrect the computer willprint “WRONG” http://eglobiotraining.com
  • 29. #include<stdio.h>#include<conio.h>int main(void){ char n; printf("choose a shape:ncirclenrectanglentriangle "); scanf("%c",&n); switch(n) { case c: printf("Area=(3.1416)(r)(r)"); break; case r: printf("Area=(length)(width)"); break; case t: printf("Area=1/2(b)(h)"); break; default: printf("invalid"); break; } getch(); return 0; Case 5 & Output } http://eglobiotraining.com
  • 30. In the last case, 5. I program the computer to answerthe right area of a given shape. Just like in the previousslide if you choose circle the computer will answer“3.1416(r)(r)” so as if you choose other shape. http://eglobiotraining.com
  • 31. #include<stdio.h>#include<conio.h>int main(void){ int ctr; for(ctr=-10;ctr<=10;ctr++) { printf(" %d",ctr); } getch(); return 0; } Loop 1 & Output http://eglobiotraining.com
  • 32. The value of ctr is equal to -10 if the ctr is less than orequal to 10. the computer will print so on and so forth http://eglobiotraining.com
  • 33. #include<stdio.h>#include<conio.h>int main(void){ int ctr; for(ctr=5;ctr<=50;ctr=ctr+5) { printf(" %d",ctr); } getch(); return 0; } Loop 2 & Output http://eglobiotraining.com
  • 34. The value of ctr is 5 if the ctr is less than or equal to 50then the value of ctr that is 5 will become 10 becausethe program will add another 5 and again and againand again. http://eglobiotraining.com
  • 35. #include<stdio.h>#include<conio.h>int main(void){ int n=2; while(n<=100) { printf(" %d",n); n=n*2; } getch(); return 0;} Loop 3 & Output http://eglobiotraining.com
  • 36. The value of n is 2 if the n is less than or equal to 100then the value of n that is 2 will become 4 because theprogram is to be multiplied by 2. http://eglobiotraining.com
  • 37. #include<stdio.h>#include<conio.h>int main(void){ int n; n=4; do { printf(" %dth",n); n++; }while(n<=13); getch(); return 0; } Loop 4 & Output http://eglobiotraining.com
  • 38. The value of n is 4 if the n is less than or equal to 13then the value of n that is 4 will become 5. thecomputer will just add 1 to n which is 4. http://eglobiotraining.com
  • 39. #include<stdio.h>#include<conio.h>int main(void){ int a; a=1; do { printf(" %d %d",a,a); a++; Loop 5 & Output }while(a<=9); getch(); return 0; http://www.slideshare.net/rurumedina/funda } mentals-of-prog-by-rubferd-medina- 14685584 http://eglobiotraining.com
  • 40. The value of a is 1 if the a is less than or equal to 9 thenthe value of a that is 1 add 1. it will be repeated and thenext is the other number. Just like in the previous slide.This file is to be submitted by:Prof. Erwin M. Globiohttp://eglobiotraining.com/ http://eglobiotraining.com

×