DEV Community

Cover image for Day 14: Unveiling the Magic of INTRODUCTION in Java, C++, Python, and Kotlin!
Nitin-bhatt46
Nitin-bhatt46

Posted on

1

Day 14: Unveiling the Magic of INTRODUCTION in Java, C++, Python, and Kotlin!

DAY - 14

Today’s Learning :-

For more Tech content Join us on linkedin click here

All the code snippets in this journey are available on my GitHub repository. 📂 Feel free to explore and collaborate: Git Repository

Question :-

1: Find the cube of a number using Function.

2: Reverse a number n using Function, Constraints: -5000<=n<=5000

3: There are three numbers a,b,c. Put the value of a into b, put value of b into c and put value of c into a. Do it using Function.

4: Print “Hello Coder Army” n times using Function.

In the previous class we knew what its function was. In this class we will know the type of function and different return types they have.

Java: in java we cannot define function outside the class.
Parameterized Functions: Functions that accept parameters.
void printMessage(String message) {
System.out.println(message);
}

Non-parameterized Functions: Functions that do not accept any parameters.
void greet() {
System.out.println("Hello!");
}

Return Type Functions: Functions that return a value.
int add(int a, int b) {
return a + b;
}

Void Functions: Functions that do not return any value.
void greet() {
System.out.println("Hello!");
}

Python:
Parameterized Functions: Functions that accept parameters.
def greet(name):
print("Hello,", name)

Non-parameterized Functions: Functions that do not accept any parameters.
def greet():
print("Hello!")

Return Type Functions: Functions that return a value.
def add(a, b):
return a + b

Void Functions: In Python, all functions return None by default if no explicit return statement is provided.

C++:
Parameterized Functions: Functions that accept parameters.
void printMessage(string message) {
cout << message << endl;
}

Non-parameterized Functions: Functions that do not accept any parameters.
void greet() {
cout << "Hello!" << endl;
}

Return Type Functions: Functions that return a value.
int add(int a, int b) {
return a + b;
}

Void Functions: Functions that do not return any value.
void greet() {
cout << "Hello!" << endl;
}

These are the basic types of functions commonly used in Java, Python, and C++. Depending on the requirements of your program, you can choose the appropriate type of function to use.

Feel free to reshare this post to enhance awareness and understanding of these fundamental concepts.
Code snippets are in the Git repository.

🙏 Thank you all for your time and support! 🙏
Don't forget to catch me daily at 10:30 Am (Monday to Friday) for the latest updates on my programming journey! Let's continue to learn, grow, and inspire together! 💻✨

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay