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
#13. auto
A keyword that lets the compiler automatically deduce the data type of a variable at compile-time.

#include <iostream>

int main() {
auto number = 10; // Compiler deduces int
auto pi = 3.14; // Compiler deduces double
std::cout << "Type of 'number' is deduced.";
return 0;
}

Type of 'number' is deduced.


#14. & (Address-of Operator)
Returns the memory address of a variable.

#include <iostream>

int main() {
int var = 20;
std::cout << "Memory address of var: " << &var;
return 0;
}

Memory address of var: 0x61ff08 
(Note: Address will vary)


#15. * (Dereference Operator)
Accesses the value stored at a memory address held by a pointer.

#include <iostream>

int main() {
int var = 50;
int* ptr = &var; // ptr holds the address of var
std::cout << "Value at address " << ptr << " is " << *ptr;
return 0;
}

Value at address 0x61ff04 is 50
(Note: Address will vary)

---
#CPP #ControlFlow #Conditional

#16. if
Executes a block of code if a specified condition is true.

#include <iostream>

int main() {
int age = 18;
if (age >= 18) {
std::cout << "You are an adult.";
}
return 0;
}

You are an adult.


#17. else
Executes a block of code if the condition in the if statement is false.

#include <iostream>

int main() {
int age = 16;
if (age >= 18) {
std::cout << "You are an adult.";
} else {
std::cout << "You are not an adult.";
}
return 0;
}

You are not an adult.


#18. else if
Specifies a new condition to test, if the first if condition is false.

#include <iostream>

int main() {
int score = 85;
if (score >= 90) {
std::cout << "Grade: A";
} else if (score >= 80) {
std::cout << "Grade: B";
} else {
std::cout << "Grade: C";
}
return 0;
}

Grade: B


#19. switch / case
Selects one of many code blocks to be executed.

#include <iostream>

int main() {
int day = 3;
switch (day) {
case 1:
std::cout << "Monday";
break;
case 2:
std::cout << "Tuesday";
break;
case 3:
std::cout << "Wednesday";
break;
}
return 0;
}

Wednesday


#20. break
Used to exit a switch statement or a loop.

#include <iostream>

int main() {
for (int i = 0; i < 10; ++i) {
if (i == 5) {
break; // Exit the loop when i is 5
}
std::cout << i << " ";
}
return 0;
}

0 1 2 3 4

---
#CPP #Loops

#21. for
Executes a block of code a specified number of times.

#include <iostream>

int main() {
for (int i = 0; i < 5; ++i) {
std::cout << i << " ";
}
return 0;
}

0 1 2 3 4


#22. while
Loops through a block of code as long as a specified condition is true.

#include <iostream>

int main() {
int i = 0;
while (i < 5) {
std::cout << i << " ";
i++;
}
return 0;
}

0 1 2 3 4