answersLogoWhite

0

Void methods in programming are designed to perform a task or operation without returning a value. This is because the purpose of a void method is to execute a set of instructions or actions, rather than to produce a specific result that needs to be returned. Therefore, void methods do not have a return type and cannot return a value.

User Avatar

AnswerBot

4mo ago

What else can I help you with?

Continue Learning about Computer Science

How can you handle a situation where you cannot return a value from a method with a void result type?

In a situation where you cannot return a value from a method with a void result type, you can use other methods such as setting a global variable or using output parameters to pass the value back to the calling code.


Can a recursive method be void, or does it always need to return a value?

Yes, a recursive method can be void, meaning it does not need to return a value.


What is the use of void pointer?

Void Pointer is a General purpose pointer ,that does not have any data type associated with it and can store address of any type of variable. Declaration: void * pointer_name;


Difference between void pointer and null pointer?

A Null pointer has the value 0. void pointer is a generic pointer introduced by ANSI. Before ANSI, char pointers are used as generic pointer. Generic pointer can hold the address of any data type. Pointers point to a memory address, and data can be stored at that address.


Give an example of lack of orthogonality in designing of c language?

The design of C language may be examined from the perspective of orthogonality. C language is somewhat inconsistent in its treatment of concepts and language structure, making it difficult for the user to learn (and use) the language. Examples of exceptions follow:Structures (but not arrays) may be returned from a function.An array can be returned if it is inside a structure.A member of a structure can be any data type (except void), or the structure of the same type.An array element can be any data type (except void).Everything is passed by value (except arrays).Void can be used as a type in a structure, but a variable of this type cannot be declared in a function.DisadvantagesToo much orthogonality is also troublesome. This concept may be examined in C language:All statements (including assignment, if and while) return some value, and can be used in expressions.Logic and arithmetic expressions can be intermixed.This can cause side effects and cryptic code.Since languages need large number of components, too much orthogonality can cause problems. From a language designer's point of view, the most difficult task (and an important one) is to strike a balance.(wiki - by Buddhila Ashen Pitigala)

Related Questions

How can you handle a situation where you cannot return a value from a method with a void result type?

In a situation where you cannot return a value from a method with a void result type, you can use other methods such as setting a global variable or using output parameters to pass the value back to the calling code.


How can you prevent delegate to return any value from all referenced methods?

the return type is void


Why use void in main of java?

No. void is not a data type. It is mandatory for all java methods to return something and if it is not going to return anything, we have to mark the method with a "void" return type to let the JVM know that it must not expect anything from the method.


How do you create methods that does not return a value?

That depends on the programming language. In C, and languages derived from C (including Java), you usually declare the return value as "void", for example: void MyMethod(int par1, int par2) { // Some commands here }


Can a recursive method be void, or does it always need to return a value?

Yes, a recursive method can be void, meaning it does not need to return a value.


Can you please explain void return type with example briefly?

It means no return value. Example: void Hello (void) { puts ("Helloí");}


Is function always return a value?

no, every function can not return a value. for example void name() { cout<<"Hello world"; } this function does not return any value due to the key word void that tells the compiler that the function does not returns a value.


The keyword indicates that a method does not return a value?

void


Difference in using a method that return value and method that does not return value in object orinted programming?

A method that return a value should have a return statement. The method signature should indicate the type of return value. While in the case of a method that does not return a value should not have a return statement and in the signature, the return type is void. When using a method that doesn't return a value, a programmer can not get a value from that function, but instead, it can only change variable values and run other methods.


What does a void method do?

In Java, this keyword is used to specify that the method has no return value.


Why void is used in c language?

void as function return-type means no return value void as function parameter means no parameter void * as pointer type means generic pointer


Can a void function return a value?

No.. It is not possible at any point