Computer Programming I
Computer Programming I
Implement a solution
– The instructions in a programming language
collectively called code.
– Your code should be a translation of your algorithm
developed into the programming language.
• In this class we use C++, but there are many other
programming languages: C, C++, C#, Ruby, Python, Visual
Basic, etc.
Testing and Debugging
Locate and remove any errors in the program
– Testing is the process of finding errors in a
program
– Debugging is the process of removing errors in a
program.
• An error in a program is called a bug.
Complete All Documentation and Organize
Examples…
Conditional Operator (?:)
The conditional operator takes three operands. It has the general
form:
Syntax:
operand1 ? operand2 : operand3
• First operand1 is a relational expression and will be evaluated.
• If the result of the evaluation is non zero (which means TRUE),
then operand2 will be the final result. Otherwise, operand3 is
the final result.
Examples
• E.g.: General Example
• Z=(X<Y)? X : Y
This expression means that if X is less than Y the value
of X will be assigned to Z otherwise (if X>=Y) the
value of Y will be assigned to Z.
• E.g.:
• int m=2,n=1,min;
• min = (m < n )? m : n;
• The value stored in min is 1.
Some Easy Questions
• T/F Every c++ program must have main
function.
• // describe single comment line.
• /* */ refers double comment line
• Float refers decimal numbers data type.
• A given problem can have many solution and
all solution may not be efficient.