Introduction to Functions

Introduction to Functions

Ram, has learned and experienced what are primitive datatypes and what are user defined datatypes. Now he tries to understand what are functions in programming and why are they used.

Reading about functions from various sources, he has read this particular line from almost all sources which says that a function consists of few lines of code which are written once and used whenever needed. Now, this line has gone above his head and he’s confused that why I can’t write those lines whenever needed. This function creation and passing parameters are a huge mess and complex.

No alt text provided for this image
Ram is confused

Ram was so upset and he wanted to change his mood. He was watching some reels until he received a call from one of his pals inviting him to a party. Ram, who was upset, got ready for the party right away in order to change his mood. Ram danced like his favorite hero Chiranjeevi at the celebration, which drew the attention of all the partygoers.

No alt text provided for this image
Ram Dancing like Chiranjeevi

Ram was exhausted after the party and fell into a deep sleep. The next day, every one of his friends and relatives who had heard about Ram’s dance at the party wanted to see it again. Those friends who couldn’t make it to the party yesterday, came to Ram’s house and asked him to dance again. Ram was overjoyed at the first time that people liked his dance, but his joy faded quickly when this was repeated several times. Every time a friend or family visits him, he gets asked to dance first, and this keeps happening.

No alt text provided for this image
Ram is pissed off

Ram, frustrated with having to dance over and over, had the idea to record his dance once, and then play the video or share the YouTube link whenever a friend or relative asks him to dance. This has given him some peace, and it benefits both of them. Ram is relieved when it’s all over and returns to his personal space, where he recalls what happened and how he handled the situation by dancing once and using the record when necessary.

No alt text provided for this image
Camera is set, Ram need to dance just once

This reminded him of the?Functions?he studied but didn’t quite understand. Now that he has solved his problem with a function, like recording his dance and showing when needed. Similarly a function is written once and can be used when needed just by calling name and passing the required parameters if necessary. This way, Ram has understood the importance of Functions in programming and the mess of rewriting the lines of code repeatedly when needed.

Function Syntax:

No alt text provided for this image
Function Syntax

Read about Functions in here:


要查看或添加评论,请登录

Putta Hemanth Kumar的更多文章

  • Merge Sort Technique

    Merge Sort Technique

    Ram is determined to conquer the formidable Merge Sort, a sorting algorithm that had always been a bit of a puzzle for…

  • Binary Search Algorithm

    Binary Search Algorithm

    Ram, who is passionate about coding had managed to learn all the fancy data structures, much to the amazement of his…

    2 条评论
  • Introduction to Stacks

    Introduction to Stacks

    Ram, had recently completed his studies on arrays and linked lists, and now he was ready to embark on a new data…

  • Introduction to Linkedlist

    Introduction to Linkedlist

    Ram has completed his learning and practice in array data structure, He understood all the pros and cons of arrays, Now…

  • Introduction to Array Datastructure

    Introduction to Array Datastructure

    Ram understands very well that in order to tackle any programming challenge, he must learn about data structures and…

  • A brief Introduction to DSA

    A brief Introduction to DSA

    Ram, who is knowledgeable about various programming datatypes and functions, wanted to learn more about data structures…

  • Introduction to Structures and Classes

    Introduction to Structures and Classes

    Ram, now has a good clarity on Primitive Datatypes, now he’s learning User defined datatypes. While doing so he…

  • Introduction to Primary Data Types

    Introduction to Primary Data Types

    Ram, a curious student who wants to learn DSA and started with primary datatypes. Ram is confused after looking at…

    3 条评论

社区洞察

其他会员也浏览了