Computer Science Flashcards
What is a program made up?
Variable, keyword, operator, punctuation, Data Types,
What is a Variable?
Variable names are just the symbolic representation of a memory location.
What is a keyword?
Keywords are the reserved words used in programming. Each keywords has fixed meaning and that cannot be changed by user.
What is a Arithmetic operator?
Operators are the symbol which operates on value or a variable. For example: + is a operator to perform addition.
What is a data type?
Data types are the keywords, which are used for assigning a type to a variable.
Integer types
Floating Type
Character types
What are the three primary activities of a program?
Input, processing and output
What is a input?
Input is information a program collects from the outside world
what is processing?
Performing process on information gathered from input.
What is a output?
Output is information a program shows the outside world.
The Programming process?
Steps, which include design, testing, and debugging activities.
what is Procedural and Object-Oriented Programming?
Two ways of thinking about software development and program design.
what is Procedural Programming?
Programmer constructs functions
what is Object-Oriented Programming?
Programming element that contains data and the procedures that operate on the data
what are The Parts of a C++ Program
Comments, #preprocessor directives, namespace, function, { , strings,
return 0,
what is cout object?
This object will display information on the computers screen.
what is a #include Directive?
causes the contents of another file to be inserted into the program.
what are Literals?
constant value assigned to variable
what are Identifiers?
identifiers are names given to variables, functions.
Integer data types?
Keyword int is used for declaring the variable with integer type.
either 2 bytes(In older PC’s) or 4 bytes.
The char Data Type?
The size of char is 1 byte. Keyword char is used for declaring the variable of character type.
Floating-Point Data Types ?
Floating types can hold real values (numbers)
size of float ?
precision of float 6 digits
size of double?
precision of double is 14 digits.
what happens if assign float to int
3.9999 = 3 rounded down
what is bool Data Type?
two values (usually denoted true and false)
Variable Assignments and Initialization
assign values to variables and once its in its initialized
every variable has a scope, what are scopes?
scope are rules where variable may be used.
Mathematical Expressions ordinance
negative, * , / , % , +, -
Operator Data type Ranking
long double, double, float, unsigned, long, long, unsigned int, int. lower type get converted to higher type.
Relational Operators
compare numeric value, and char values. > .< = !=
if…else statement.
if (test expression)
statements to be executed if test expression is true;
else
statements to be executed if test expression is false;
Flags
a boolean flag is a variable that get the value of either true or false
Logical Operators
The logical operators, logical AND (&&) and logical OR (||), are used to combine multiple conditions formed using relational or equality expressions.
Menus
showChoices(); cin >> choice; switch (choice) { case 1: cout << "Enter two numbers: "; cin >> x >> y; cout << "Sum " << add(x,y) <<< "Enter two numbers: "; cin >> x >> y; cout << "Difference " << subtract(x,y) <<endl; break;
Validating User Input
are the options for user real?
The while Loop
Loops causes program to execute the certain block of code repeatedly until some conditions are satisfied, i.e., loops are used in performing repetitive work in programming.
while (test expression)
{
statements to be executed.
}