1. Final Requirement
To be passed to: Prof. Erwin M.
Globio
Rubferd Eric F. Medina
Bm10203
http://eglobiotraining.com.
2. PROGRAMING
A Programing language is used to write computer
programs such as application and utilities.
Programing allows a programmer or end user to
develop the sets of instructions that constitute a computer
program or software. The role of a programing language can be
described in two ways:
Technical: It is a means for instructing a Computer to perform
Tasks
Conceptual: It is a framework within which we organize our
ideas about things and processes.
http://eglobiotraining.com
3. As an individual, I have learned that programming is a
very broad because it composes many scripts, applications and
can be used to run a program that has been part of the
programming language.
A programming language should both provide means to
describe primitive data and procedures and means to combine
and abstract those into more complex ones.
The distinction between data and procedures is not that
clear cut. In many programming languages, procedures can be
passed as data (to be applied to ``real'' data) and sometimes
processed like ``ordinary'' data. Conversely ``ordinary'' data can
be turned into procedures by an evaluation mechanism.
http://eglobiotraining.com
4. At first, programming is confusing because you have so
much to understand about codes that will enable to run a
program. Programming has applications and program
development, the best example for this is the Internet bowser…
Programming is a creative process done by programmers
to instruct a computer on how to do a task. Fundamentally
programs manipulate numbers and text. These are the building
blocks of all programs.
Programming languages let you use them in different ways, e.g
adding numbers, etc… or storing data on disk for later retrieval.
http://eglobiotraining.com
5. You have to consider languages to run or write your own
program, 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 the
world. Also known as "C with Classes".
New to programming or thinking about it? It might surprise you to
know that there are many programmers who program just for fun
and it can lead to a job.
http://eglobiotraining.com
7. Switch case statements are a substitute for long if
statements that compare a variable to several
"integral" values ("integral" values are simply values
that can be expressed as an integer, such as the value
of a char). The value of the variable given into switch is
compared to the value following each of the cases, and
when one value matches the value of the variable, the
computer continues executing the program from that
point.
http://eglobiotraining.com
8. The default case is optional, but it is wise to include it
as it handles any unexpected cases. Switch
statements serves as a simple way to write long if
statements when the requirements are met. Often it
can be used to process input from a user.
http://eglobiotraining.com
10. This program will compile, but cannot be run until the
undefined functions are given bodies, but it serves as
a model (albeit simple) for processing input. If you do
not understand this then try mentally putting in if
statements for the case statements. Default simply
skips out of the switch case construction and allows
the program to terminate naturally. If you do not like
that, then you can make a loop around the whole
thing to have it wait for valid input. You could easily
make a few small functions if you wish to test the
code.
http://eglobiotraining.com
11. The switch-case statement is a multi-way decision statement.
Unlike the multiple decision statement that can be created
using if-else, the switch statement evaluates the
conditional expression and tests it against numerous
constant values. The branch corresponding to the value that the
expression matches is taken during execution.
The value of the expressions in a switch-case statement
must be an ordinal type i.e. integer, char, short, long etc. Float
and double are not allowed.
The syntax is :
http://eglobiotraining.com
12. The case statements and the default statement can occur in
any order in the switch statement. The default clause is an
optional clause that is matched if none of the constants in
the 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, execution
continues on into the next case clause if it is not explicitly
specified 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, after
the last clause) is not necessary, it is good programming
practice to put it in anyway.
An example where it is better to allow the execution to
continue into the next case statement:
http://eglobiotraining.com
17. while ( expression )
statement
In a while loop, the expression is evaluated. If nonzero, the statement executes, and the
expression is evaluated again. This happens over and over until the expression's value is
zero. If the expression is zero the first time it is evaluated, statement is not executed at
all.do
statement
while ( expression);
A do while loop is just like a plain while loop, except the statement executes before the
expression is evaluated. Thus, the statement will always be evaluated at least once.
for ( expression1; expression2; expression3 )
statement
In a for loop, first expression1 is evaluated. Then expression2 is evaluated, and if it is zero
EEL leaves the loop and begins executing instructions after statement. Otherwise the
statement 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 is
like expression2 is nonzero. while (expression) is the same as for (; expression; ). The
syntax for (;;) creates an endless loop that must be exited using the break statement (or
one of the other statements described below).
http://eglobiotraining.com
18. Types of Looping
That 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 Break
in Programing
The break keyword is used to terminate a
loop, intermediately bypassing any conditions. The
control will be transferred to the first statement following
the loop block. The break statement can be used to
terminate an infinite loop or to force a loop to end before
its normal termination.
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 number
2, the computer will answer “fair” and last is number 3,
the computer will answer “good” just like in the
previous 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 the
computer were about to answer “correct” but if your
answer is incorrect the computer were program to
answer “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 “what
is the tittle of the Philippine national anthem?” the
choices are a)Bayang magiliw, b)lupang hinirang or
c)Ang bayan ko. The correct answer is letter “B” if you
choose the correct letter the computer will answer
“Correct” but if you choose a wrong answer the
computer will answer “wrong” just like in the previous
slide.
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 the
student will think of what is the correct answer. “40” is
the correct answer if they got it right the computer will
print “CORRECT” but if it is incorrect the computer will
print “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 answer
the right area of a given shape. Just like in the previous
slide if you choose circle the computer will answer
“3.1416(r)(r)” so as if you choose other shape.
http://eglobiotraining.com
34. The value of ctr is 5 if the ctr is less than or equal to 50
then the value of ctr that is 5 will become 10 because
the program will add another 5 and again and again
and again.
http://eglobiotraining.com
36. The value of n is 2 if the n is less than or equal to 100
then the value of n that is 2 will become 4 because the
program is to be multiplied by 2.
http://eglobiotraining.com
38. The value of n is 4 if the n is less than or equal to 13
then the value of n that is 4 will become 5. the
computer 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 then
the value of a that is 1 add 1. it will be repeated and the
next is the other number. Just like in the previous slide.
This file is to be submitted by:
Prof. Erwin M. Globio
http://eglobiotraining.com/
http://eglobiotraining.com