Python Data Science Jobs & Interviews
20.3K subscribers
188 photos
4 videos
25 files
326 links
Your go-to hub for Python and Data Science—featuring questions, answers, quizzes, and interview tips to sharpen your skills and boost your career in the data-driven world.

Admin: @Hussein_Sheikho
Download Telegram
Top 50 C++ Keywords & Functions

#CPP #Basics #IO

#1. #include <iostream>
A preprocessor directive that includes the input/output stream library.

#include <iostream>

int main() {
std::cout << "This requires iostream!";
return 0;
}

This requires iostream!


#2. int main()
The main function where program execution begins.

#include <iostream>

int main() {
std::cout << "Program starts here.";
return 0;
}

Program starts here.


#3. std::cout
Used to output data (print to the console).

#include <iostream>

int main() {
std::cout << "Hello, C++!";
return 0;
}

Hello, C++!


#4. std::cin
Used to get input from the user.

#include <iostream>
#include <string>

int main() {
int age;
std::cout << "Enter your age: ";
std::cin >> age;
std::cout << "You are " << age << " years old.";
return 0;
}

Enter your age: 25
You are 25 years old.


#5. using namespace std;
Tells the compiler to use the std (standard) namespace. Avoids prefixing std:: to every standard function.

#include <iostream>
using namespace std;

int main() {
cout << "No std:: prefix needed.";
return 0;
}

No std:: prefix needed.

---
#CPP #DataTypes #Variables

#6. int
Declares an integer variable.

#include <iostream>

int main() {
int number = 100;
std::cout << "The number is: " << number;
return 0;
}

The number is: 100


#7. double
Declares a floating-point number variable (can hold decimals).

#include <iostream>

int main() {
double price = 19.99;
std::cout << "The price is: " << price;
return 0;
}

The price is: 19.99


#8. char
Declares a character variable.

#include <iostream>

int main() {
char grade = 'A';
std::cout << "Your grade is: " << grade;
return 0;
}

Your grade is: A


#9. bool
Declares a boolean variable, which can only have the value true or false.

#include <iostream>

int main() {
bool isRaining = false;
std::cout << "Is it raining? " << isRaining; // Outputs 0 for false
return 0;
}

Is it raining? 0


#10. std::string
Declares a variable that can hold a sequence of characters. Requires #include <string>.

#include <iostream>
#include <string>

int main() {
std::string greeting = "Hello, World!";
std::cout << greeting;
return 0;
}

Hello, World!

---
#CPP #Keywords #Operators

#11. const
Declares a variable as a constant, meaning its value cannot be changed.

#include <iostream>

int main() {
const double PI = 3.14159;
std::cout << "The value of PI is: " << PI;
// PI = 4; // This would cause a compile error
return 0;
}

The value of PI is: 3.14159


#12. sizeof()
An operator that returns the size (in bytes) of a data type or variable.

#include <iostream>

int main() {
int myInt;
std::cout << "Size of int is: " << sizeof(myInt) << " bytes.";
return 0;
}

Size of int is: 4 bytes.