iasteele

 

Radhika

Page history last edited by Anonymous 2 yrs ago

C++ 

 C++ is a type of programming language.

Variable Types

  • char- characters or small integers
  • int- integer, any whole number.
  • float-floating point

Inorder to use a variable, it has to be specify it by telling the computer which data the variable should be in.  

Ex. For example, if you were carrying out arithematic functions, you could use the int variable to assign numerals for the functions.

 

Print f

Print f is written for the standard output. Print f starts out with a parameter, then a quotation, whatever function you want to be in the middle and then a closing parameter.

  

Scan f

 A code if you want user to be able to type something on the page. If you were to ask a question using the printf function, scanf would be used to allow the user to type in the answer.

 

Loops

Codes used to make a certain action repeat over and over. If for example you were making a game, you could allow the player to play over and over until they win.

 

example: while and for  

 

The 'while' loop makes a bracketed section of code run as long as a condition is true.

The 'for' loop is used to loop a section of code until the counter is reached.

 

Arrays

The numbers of variables of a  certain type. Arrays are used as parameters to certain variables that define the quantity of that certain variable.

Example: int numbers [20]. This means that the computer edited 20 of the characters from 0-19.

 

Functions 

You can use functions to carry out math operations. By using functions you could plug in numbers and get numbers.

Ex.   int subtract(int a, int b)

        {

         return a-b;

        }

 

if/else: If and else functions are used to set up conditions. The if function is used to make a proposition. If the proposition is true, the functions under the if function will be carried out. Otherwise, the else function will be carried out.

 

 

/else: 'if' blank is true, the program does something.  The most obvious example was in the Pick A Number game.  The 'if' function let the user know whether to guess higher or lower.  'Else' function makes the program perform something if the input is false.

 

While Uses

The "while" loop makes a bracketed section of code run as long as a certain condition is true.

 

Comments (0)

You don't have permission to comment on this page.