Sitemap
Fahnissa A

Fahnissa A

Function in C Programming

2 min readFeb 9, 2025

Simple function:

#include <stdio.h>

// Declare the Function
void Shania() {
printf("Shania likes to eat sweets.\n");
printf("But she doesn't like Dubai Chocolate.\n");
printf("Yesterday, she decided to give it a second chance.\n");
printf("In the end, she finally understood why people are obsessed with this chocolate.\n");
printf("\n");
}

int main() {

Shania(); // Call the function
Shania();

return 0;
}

Result:

Get Fahnissa A’s stories in your inbox

Join Medium for free to get updates from this writer.

Shania likes to eat sweets.
But she doesn't like Dubai Chocolate.
Yesterday, she decided to give it a second chance.
In the end, she finally understood why people are obsessed with this chocolate.

Shania likes to eat sweets.
But she doesn't like Dubai Chocolate.
Yesterday, she decided to give it a second chance.
In the end, she finally understood why people are obsessed with this chocolate.



=== Code Execution Successful ===

Function with Parameters and Arguments:

// Online C compiler to run C program online
#include <stdio.h>

// Declare the Function
void Shania(char name[], char chocoName[], int age) {
printf("%s is %d years old.\n", name, age);
printf("%s likes to eat sweets.\n", name);
printf("But she doesn't like %s Chocolate.\n", chocoName);
printf("Yesterday, she decided to give it a second chance.\n");
printf("In the end, she finally understood why people are obsessed with this chocolate.\n");
printf("\n");
}

int main() {
char name[] = "Shania";
char chocoName[] = "Madiun";
int age = 22;

Shania(name, chocoName, age); // Call the function

return 0;
}

Result:

Shania is 22 years old.
Shania likes to eat sweets.
But she doesn't like Madiun Chocolate.
Yesterday, she decided to give it a second chance.
In the end, she finally understood why people are obsessed with this chocolate.



=== Code Execution Successful ===

--

--