Here is the link on github: https:/
-
Recent Posts
Recent Comments
Archives
Categories
Meta
Here is the link on github: https:/
Comments Off on Hey gusy here is my WSQ10
Posted in Blogs, Syndicated, TC1014 Blogs
Basic output (printing) and inpur (text based) in C++
The standard library defines a handful of stream objects that can be used to access what are considered the standard sources and destinations of characters by the environment where the program runs:
stream | description |
---|---|
cin |
standard input stream |
cout |
standard output stream |
cerr |
standard error (output) stream |
clog |
standard logging (output) stream |
On most program environments, the standard output by default is the screen, and the C++ stream object defined to access it is cout
.
For formatted output operations, cout
is used together with the insertion operator, which is written as <<
(i.e., two “less than” signs).
cout << "Output sentence"; // prints Output sentence on screen
cout << 120; // prints number 120 on screen
cout << x; // prints the value of x on screen
In most program environments, the standard input by default is the keyboard, and the C++ stream object defined to access it is cin
.
For formatted input operations, cin
is used together with the extraction operator, which is written as >>
(i.e., two "greater than" signs). This operator is then followed by the variable where the extracted data is stored. For example:
int age;
cin >> age;
Comments Off on Mastery 10
Posted in Blogs, Syndicated, TC1017 Blogs
Tagged #000000, #0000b0, #007000, #600030, #f0f0f0, #Mastery10, #TC1017
Here is to Github:
https:/
Comments Off on #TC1017 #WSQ13 Babylonian Method
Posted in Blogs, Syndicated, TC1017 Blogs
Tagged #000000, #222222, #Algoritmo, #TC1017, #WSQ13
There are two approaches to writing repetitive algorithms.
1. Loops (Iteration)
2. Recursion.
Iteration: Use for loops, do..while, while loops.
Example: Factorial of a number
int factorial(int num)
{
int k=num;
while(num != 0)
{
k=k*(num-1);
num–;
}
return num;
}
—————————————————————————————————–
Recursion: Recursion is a repetitive process in which a function calls itself.
Limitations of Recursive Approach:
1. Recursive solutions may involve extensive overhead because they use function calls. Each function call requires push of return memory address, parameters, returned result,etc. and every function return requires that many pops.
2. Each time you call a function you use up some of your memory allocation may be in stack or heap. If there are large number of recursive calls – then you may run out of memory.
Example:
int factorial(int num)
{
if(num != 0)
{
num=num*factorial(num-1);
}
return num;
}
When to Use:
For large number of iterations, use loops(iterative approach).
For small number of iterations, use recursion.
Comments Off on #TC1017 #Mastery22 – When to use what type of repetition in a program
Posted in Blogs, Syndicated, TC1017 Blogs