text stringlengths 2 1.05k |
|---|
11
|
#include <stdio.h>
int main() {
int age;
// double height;
printf("Enter the age: ");
scanf("%d", &age);
// printf("Enter the height: ");
// scanf("%lf", &height);
printf("Age = %d", age);
// printf("\nHeight = %.1lf", height);
return 0;
}
|
#include <stdio.h>
enum Size {
Small = 27,
Medium = 31,
Large = 35,
ExtraLarge = 40
};
int main() {
enum Size shoeSize1 = Small;
enum Size shoeSize2 = Medium;
enum Size shoeSize3 = Large;
enum Size shoeSize4 = ExtraLarge;
printf("%d\n", shoeSize1);
printf("%d\n", shoeSize2);
printf("%d\n", sh... |
#include <stdio.h>
int main() {
int x = 12;
int result = x / 8;
printf("%d", result);
return 0;
}
|
#include <stdio.h>
#include <stdbool.h>
int main() {
bool value = (9 != 6);
printf("%d ", value);
return 0;
}
|
#include <stdio.h>
int main() {
char str[] = "Programiz";
printf("%c\n", str[0]);
printf("%c\n", str[1]);
printf("%c\n", str[2]);
printf("%c", str[3]);
return 0;
}
|
#include <stdio.h>
#include <stdbool.h>
int main() {
int num1 = 9;
bool value = num1 > 6;
printf("%d ", value);
return 0;
}
|
#include <stdio.h>
int main() {
double a = 5.67;
int b = 9;
int result = (int)a + b;
printf("%d", result);
return 0;
}
|
#include <stdio.h>
int main() {
double salary;
printf("Enter your salary: ");
scanf("%lf", &salary);
double* ptr = &salary;
printf("Your Salary: %.2lf\n", *ptr);
double new_salary = *ptr * 2;
printf("Your double salary: %.2lf", new_salary);
}
|
#include <stdio.h>
#include <stdbool.h>
int main() {
int age = 16;
bool value = !(age <= 18);
printf("%d ", value);
return 0;
}
|
with open('javascript.txt', 'w') as f:
lines = ['JS is also awesome', '\nJS is my second programming language.']
f.writelines(lines)
|
#include <stdio.h>
int main() {
int x = 12;
int result = x % 8;
printf("%d", result);
return 0;
}
|
#include <stdio.h>
double discount = 33.3;
int computeFee(int time) {
double discountAmount;
double fee = 33600.0;
}
|
numbers = [1, 4, 9, 16]
print(type(numbers))
n1 = 5
print(type(n1))
flag = True
print(type(True))
def my_function():
pass
print(type(my_function)
|
for item in range(1, 6):
print(item)
break
|
#include <stdio.h>
int main() {
int a = 5;
if (!(a % 2 == 0)) {
printf("Inside If");
}
else {
printf("Inside else");
}
return 0;
}
|
0
|
for (initializationExpression; testExpression; updateExpression) {
// code inside the for loop
}
|
text = "Python"
print(text)
|
person1 = {"name": "Linus", "age": 21}
print(person1.get("namr"))
print(person1.get("hobbies"))
|
#include <stdio.h>
void calculateSquare(int number) {
int square = number * number;
printf("Square of %d is %d \n", number, square);
}
int main() {
calculateSquare(5);
return 0;
}
|
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
|
#include <stdio.h>
int main() {
char str[20];
printf("Enter your name: ");
scanf("%s", str);
printf("%s", str);
return 0;
}
|
#include <stdio.h>
int addNumbers(int number1, int number2) {
int sum = number1 + number2;
return sum;
}
int main() {
int result = addNumbers(8, 9);
printf("Result = %d", result);
return 0;
}
|
x = 5
x += 10 # x = x + 10
x -= 10 # x = x - 10
|
import math
number = 25
result = math.sqrt(number)
print(result)
print(math.pi)
|
#include <stdio.h>
int main() {
char operator = '+';
int num1 = 8;
int num2 = 7;
int result = (operator == '+') ? (num1 + num2) : (num1 - num2);
printf("%d", result);
return 0;
}
|
def smart_divide(func):
def inner(a, b):
print("Dividing", a, "by", b)
if b == 0:
print("Cannot divide by 0!")
return
return func(a, b)
return inner
@smart_divide
def divide(a, b):
return a/b
value1 = divide(15, 3)
print(value1)
value2 = divide(5, 0)
prin... |
#include <stdio.h>
int main() {
int firstNumber = 33;
printf("first Number = %d ", firstNumber);
int secondNumber = firstNumber;
printf("\nsecond Number = %d", secondNumber);
return 0;
}
|
def even_generator(max):
n = 2
while n <= max:
yield n
n += 2
numbers = even_generator(4)
print(next(numbers))
print(next(numbers))
print(next(numbers))
|
#include <stdio.h>
int main() {
int* ages;
int n = 4;
ages = (int*)malloc(n * sizeof(int));
if(ages == NULL) {
printf("Memory cannot be allocated");
return 0;
}
printf("Enter input values:\n");
for (int i = 0; i < n; ++i) {
scanf("%d", ages+i);
... |
#include <stdio.h>
int* multiplication (int* a, int* b, int* c) {
*c = *a * *b;
return c;
}
int main() {
int num1 = 13;
int num2 = 9;
int multiple;
int* result = multiplication(&num1, &num2, &multiple);
printf("The multiplication is: %d", *result);
return 0;
}
|
#include <stdio.h>
#include <stdbool.h>
int main() {
bool value = (9 >= 6);
printf("%d ", value);
return 0;
}
|
class Even:
def __init__(self, max):
self.n = 2
self.max = max
def __iter__(self):
return self
def __next__(self):
if self.n <= self.max:
result = self.n
self.n += 2
return result
else:
raise StopIteration
numbers = E... |
// This program takes age input from the user
// It stores it in the age variable
// And, print the value using printf()
#include <stdio.h>
int main() {
int age;
printf("Enter the age: ");
scanf("%d", &age);
printf("Age = %d", age);
return 0;
}
|
number = int(input("Enter a number: "))
count = 10
while count >= 1:
product = number * count
print(number, "x", count, "=", product)
count = count - 1
|
#include <stdio.h>
int main() {
int number;
printf("Enter a number between 1 to 7: ");
scanf("%d", &number);
switch(number) {
case 2:
case 3:
case 4:
case 5:
case 6:
printf("Weekday");
break;
case 1:
case 7:
printf("Weekend");
break;
default:
... |
text = "I like Python 3"
result = text.find("Python")
print(result)
|
text = "Python"
# last character
print(text[-1])
# third to last character
print(text[-3])
|
from math import sqrt
num = sqrt(64)
print(num)
|
animals = {"dog", "cat", "tiger", "elephant", "dog"}
print(animals)
|
#include <stdio.h>
int main() {
int i;
double marks[5];
printf("Enter marks:\n");
for(i = 0; i < 5; i++) {
scanf("%lf", &marks[i]);
}
double sum = 0;
for(i = 0; i < 5; i++) {
sum = marks[i] + sum;
}
double avg_marks = sum/5;
printf("The average mar... |
#include <stdio.h>
int main() {
double number = 12.45;
float number1 = 10.9f;
printf("%.2lf", number);
printf("\n%.1f", number1);
return 0;
}
|
#include <stdio.h>
void findValue(int* num) {
*num = 39;
}
int main() {
int number = 21;
findValue(&number);
printf("Number: %d", number);
return 0;
}
|
#include <stdio.h>
int main() {
char a = '5';
int b = 9;
int result = a + b;
printf("%d", result);
return 0;
}
|
# Solution 1
number = float(input("Enter a number: "))
if number > 0:
print("The number is positive")
elif number == 0:
print("The number is 0")
else:
print("The number is negative")
|
#include <stdio.h>
#include <ctype.h>
int main() {
char alph = 'e';
char upper = toupper(alph);
printf("%c", upper);
char lower = tolower(upper);
printf("\n%c", lower);
return 0;
}
|
#include <stdio.h>
#include <stdbool.h>
int main() {
bool value1 = true;
bool value2 = false;
printf("%d ", value1);
printf(" %d", value2);
return 0;
}
|
count = 1
while count <= 5:
print(count)
count = count + 1
|
def even_generator():
n = 0
n += 2
yield n
n += 2
yield n
n += 2
yield n
numbers = even_generator()
print(next(numbers))
print(next(numbers))
print(next(numbers))
|
#include <stdio.h>
int main() {
int x = 12;
printf("%d", ++x);
return 0;
}
|
int num[5] = {2, 3, 5};
|
1
|
#include <stdio.h>
int main() {
int variable1, variable2 = 25;
return 0;
}
|
#include <stdio.h>
int main() {
double number = 12.45;
printf("%.2lf", number);
return 0;
}
|
#include <stdio.h>
int addNumbers(int number1, int number2) {
int result = number1 + number2;
return result;
}
int main() {
int sum = addNumbers(5, 6);
printf("Result = %d", sum);
return 0;
}
|
name = "Punit"
print(name) # Punit
|
#include <stdio.h>
enum Size {
Small,
Medium,
Large,
ExtraLarge
};
int main() {
enum Size shoeSize;
shoeSize = Small;
printf("%d", shoeSize);
return 0;
}
|
#include <stdio.h>
int main() {
FILE* fptr;
fptr = fopen("newFile.txt", "w");
fputs("New message 1\n", fptr);
fputs("New message 2", fptr);
fclose(fptr);
return 0;
}
|
person1 = {"name": "Linus", "age": 21}
print(person1.pop("name"))
print(person1)
|
languages = ["Python", "JavaScript", "C++", "Kotlin"]
# modifying the second item
languages[1] = "Ruby"
print(languages)
|
14.000000
|
# Displaying prompt message before taking input
name = input("Enter name: ")
print(name)
|
person1 = {"name": "Linus", "age": 21}
# changing existing keys
person1["name"] = "Dennis"
print(person1)
# adding new keys
person1["hobbies"] = ["dancing", "fishing"]
print(person1)
|
from game.characters import player
from game.characters.boss import get_boss_info
player.get_player_info()
get_boss_info()
|
numbers = [1, 4, 9]
print(dir(numbers))
|
numbers = (1, 5, 6, 3)
for number in numbers:
print(number)
|
number = 5
print(number < 10) # True
number = 15
print(number < 10) # False
|
domestic_animals = {"dog", "cat", "elephant"}
wild_animals = {"lion", "tiger", "elephant"}
animals = domestic_animals.union(wild_animals)
animals1 = animals = domestic_animals | wild_animals
print(animals)
print(animals1)
|
class Student:
pass
student1 = Student()
student1.name = "Harry"
student1.marks = 85
print(student1.name)
print(student1.marks)
|
#include <stdio.h>
int main() {
char character = 'z';
printf("%c", character);
return 0;
}
|
f = open('message.txt', 'r')
content = f.read(6)
print(content)
f.close()
|
class Student:
def __init__(self, name, marks):
self.name = name
self.marks = marks
def check_pass_fail(self):
if self.marks >= 40:
return True
else:
return False
student1 = Student("Harry", 85)
did_pass = student1.check_pass_fail()
print(di... |
#include <stdio.h>
int main() {
for (int i = 1; i <= 5; i++) {
if (i == 3) {
continue;
}
printf("%d \n", i);
}
return 0;
}
|
import game.characters.player
game.character.player.get_player_info()
|
'''This program takes an integer input from the user
and prints it'''
number = int(input("Enter an integer: "))
print("You entered:", number)
|
languages = ["Python", "JavaScript", "C++", "Kotlin"]
# modifying the second item to third item
languages[1:3] = ["Ruby", "Dart"]
print(languages)
|
#include <stdio.h>
#include <stdbool.h>
int main() {
bool value = (5 > 9);
printf("%d ", value);
return 0;
}
|
# Arithmetic operators in action
x = 5
result = x + 10 # addition
print(result) # 15
result = x - 10 # subtraction
print(result) # -5
result = x * 10 # multiplication
print(result) # 50
result = x / 10 # division
print(result) # 0.5
result = x ** 2 # exponent
print(result) # 25
quotient = x // 2 ... |
numbers = [1, 4, 9]
value = iter(numbers)
item1 = next(value)
print(item1)
item2 = next(value)
print(item2)
item3 = next(value)
print(item3)
item4 = next(value)
print(item4)
|
#include <stdio.h>
int main() {
char str[] = "Programiz";
printf("%s", str);
return 0;
}
|
#include <stdio.h>
struct Person {
double salary;
int age;
};
int main() {
struct Person person1;
person1.age = 25;
person1.salary = 4321.78;
printf("Age of person1: %d\n", person1.age);
printf("Salary of person1: %.2lf", person1.salary);
return 0;
}
|
Syntax:
if (test_condition) {
// statements inside if body
}
else {
// statements inside else body
}
|
1
|
for value in range(5):
print(value)
|
class Animal:
def eat():
print("I can eat")
class Dog(Animal):
def bark(self):
print("I can bark")
class Cat(Animal):
def get_grumpy(self):
print("I am getting grumpy.")
dog1 = Dog()
dog1.bark()
dog1.eat()
cat1 = Cat()
cat1.eat()
|
#include <stdio.h>
#include <stdbool.h>
int main() {
int age = 16;
double height = 6.3;
bool value = (age >= 18) || (height > 6.0);
printf("%d ", value);
return 0;
}
|
#include <stdio.h>
int main() {
int count = 1;
while (count < 5) {
printf("while loop in C \n");
printf("Count = %d \n", count);
count = count + 1;
}
return 0;
}
|
import datetime as dt
date1 = dt.date(2021, 1, 21)
print(date1)
print("Year:", date1.year)
print("Month:", date1.month)
print("Day:", date1.day)
|
class Complex:
def __init__(self, real, imag):
self.real = real
self.imag = imag
def add(self, number):
real = self.real + number.real
imag = self.imag + number.imag
result = Complex(real, imag)
return result
n1 = Complex(5, 6)
n2 = Complex(-4, 2)
result... |
class Student:
def check_pass_fail(self):
if self.marks >= 40:
return True
else:
return False
student1 = Student()
student1.name = "Harry"
student1.marks = 85
did_pass = student1.check_pass_fail()
print(did_pass)
student2 = Student()
student2.name = "Janet"
student2.marks ... |
#include <stdio.h>
int main() {
char operator;
printf("Choose an operator ['+', '-', '*', '/']: ");
scanf("%c", &operator);
double num1, num2;
printf("Enter first number: ");
scanf("%lf", &num1);
printf("Enter second number: ");
scanf("%lf", &num2);
double result;
switch(operator) {
... |
class Student:
def __init__(self, name, marks):
self.name = name
self.marks = marks
def check_pass_fail(self):
if self.marks >= 40:
return True
else:
return False
student1 = Student("Harry", 85)
print(student1.name)
print(student1.marks)
st... |
try:
f = open('message.txt', 'r')
content = f.read(6)
print(content)
more_content = f.read(12)
print(more_content)
finally:
f.close()
|
numbers = [1, 4, 9, 16]
print(type(numbers))
|
text = "Python"
# first to fourth characters
print(text[:4])
# from third to last character
print(text[2:])
|
a = [1, 2, 3]
b = a
|
#include <stdio.h>
int main() {
int a = 5;
int b = 9;
int result = a + b;
printf("%d", result);
return 0;
}
|
#include <stdio.h>
int main() {
int age = 24;
(age >= 18) ? printf("You can vote") : printf("You cannot vote");
return 0;
}
|
#include <stdio.h>
int main() {
double x = 12.57;
int y = 8;
double result = x + y;
printf("%.2lf", result);
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.