TCS_Ninja_Interview_Preparation
TCS_Ninja_Interview_Preparation
1. Python Questions
- Python uses automatic garbage collection via reference counting and cyclic garbage collection.
Python Coding:
```python
def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
num = 29
```
```python
my_list = [1, 2, 3, 4, 5]
reversed_list = my_list[::-1]
```
```python
import copy
shallow_copy = copy.copy(list1)
shallow_copy[0][0] = 99
```
```python
deep_copy = copy.deepcopy(list1)
deep_copy[0][0] = 42
```
2. C Questions
C Basics:
3. What is a pointer in C?
```c
int a = 10;
```
C Coding:
```c
#include <stdio.h>
#include <string.h>
int n = strlen(str);
str[n - i - 1] = temp;
int main() {
reverseString(str);
return 0;
```
```c
#include <stdio.h>
int factorial(int n) {
if (n <= 1) return 1;
int main() {
int num = 5;
return 0;
```