Skip to content

Commit 56688f0

Browse files
committed
Support more languages
1 parent a41e862 commit 56688f0

File tree

37 files changed

+368
-0
lines changed

37 files changed

+368
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// child.h
2+
#include "grandparent.h"
3+
#include "parent.h"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// grandparent.h
2+
#pragma once
3+
4+
struct foo {
5+
int member;
6+
};
7+
8+
/*
9+
// grandparent.h
10+
#ifndef GRANDPARENT_H
11+
#define GRANDPARENT_H
12+
13+
struct foo {
14+
int member;
15+
};
16+
17+
#endif // GRANDPARENT_H
18+
*/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// main.cpp
2+
#include "child.h"
3+
4+
int main() {
5+
int member;
6+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// parent.h
2+
#include "grandparent.h"

03 C C++ Python R and Mojo review/03-1 C and C++ Review/optional/02.c

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import sys
2+
3+
arr = [12, 24, 36, 48, 60]
4+
5+
# Size of array
6+
size = len(arr)
7+
print("Size of arr:", size) # Output: 5
8+
9+
# Checking the size of an integer in bytes (Python dynamically sizes integers)
10+
print("Size of an integer in bytes:", sys.getsizeof(1)) # Typical output: 28 bytes on a 64-bit system
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import sys
2+
from dataclasses import dataclass
3+
4+
@dataclass
5+
class Point:
6+
x: float
7+
y: float
8+
9+
# Creating an instance of Point
10+
p = Point(1.1, 2.5)
11+
12+
# Calculating memory size of the instance
13+
size = sys.getsizeof(p.x) + sys.getsizeof(p.y)
14+
print("Size of Point:", size) # Output varies due to Python's memory overhead, usually larger than C
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Python version
2+
3+
# c-style type casting
4+
f = 69.69
5+
i = int(f) # Convert float to int
6+
print(i) # Output: 69 (decimal truncated)
7+
8+
# to char
9+
c = chr(i) # Convert int to char using ASCII value
10+
print(c) # Output: E
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
PI = 3.14159
2+
3+
# Function to calculate the area
4+
def area(r):
5+
return PI * r * r
6+
7+
# Set radius with conditional logic
8+
radius = 7 # Default value
9+
10+
if radius > 10:
11+
radius = 10
12+
elif radius < 5:
13+
radius = 5
14+
else:
15+
radius = 7
16+
17+
# Calculate and print the area
18+
print(f"Area of circle with radius {radius}: {area(radius)}")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Person:
2+
def __init__(self, age, name):
3+
self.age = age
4+
self.name = name
5+
6+
# Create person1
7+
person1 = Person(25, "elliot")
8+
print(f"age: {person1.age}\tname: {person1.name}")
9+
10+
# Create person2
11+
person2 = Person(20, "not elliot")
12+
print(f"age: {person2.age}\tname: {person2.name}")

0 commit comments

Comments
 (0)