🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

C भाषा में किसी फ़ंक्शन को परिभाषित करने के लिए किस कीवर्ड का उपयोग किया जाता है?

Which keyword is used to define a function in C Language?

A)
B)
C)
D)

Explanation:

In the C programming language, the keyword used to define a function is the function's return type (e.g., int, float, void, etc.). Unlike some other languages, C does not use a specific keyword like def or function to define a function.

In C programming, void is a keyword used to define a function that does not return a value. It can also be used for function parameters to indicate that the function does not take any arguments.

Key Uses of void:

  1. Void Function:
    A function that does not return a value is defined with void as the return type.

     
    void printMessage() { printf("Hello, World!\n"); }

    In this case, printMessage does not return any value, so its return type is void.

  2. Void Pointer:
    A void pointer (void *) is a special pointer type that can point to any data type. It is used when the type of data is unknown or varies.

     
    void *ptr; int num = 5; ptr = # // void pointer can point to an int
  3. Void Function Parameters:
    If a function takes no arguments, you can specify void in the parameter list.

     
    void greet(void) { printf("Welcome!\n"); }

In summary, void is used to specify that a function does not return a value or to declare pointers that can point to any data type.

Latest Updates