+ 1
Can anybody define the key words for coding?
I'm a bit confused when reading the tutorial, I understand what I'm supposed to do. but I get lost when it's explaining what each line does because of some of the words. such as: -function, streams, headers, define (not very sure what it means), pre-processor
1 Respuesta
+ 5
Function: A block of code which can be reused for performing some task. For example:
int square(int x) {
x *= x;
return x;
}
Now you can use this as many times as you want,
int main() {
std::cout << square(4) << std::endl;
// Prints 16
std::cout << square(5); //Prints 25
return 0;
}
Headers: These contain definitions for functions and variables which you can use in your program by including the header file.
#define: This directive is used to create constants and functions. For example:
#include <iostream>
#define e 2.718
int main() {
std::cout << e; // Output: 2.718
return 0;
}
Streams: These are sequence of bytes used for input and output. For example: Standard Output Stream (cout) which is the part of the ostream class. The text needed to be displayed is passed in cout using the insertion operator "<<".
Look here for more information:
• https://www.geeksforgeeks.org/basic-input-output-c/amp/
• https://www.tutorialspoint.com/cplusplus/cpp_preprocessor.htm