Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Can u return two values using return keyword? If yes, how?
If no, why?

Answer Posted / vikas shakya

Using the return statement u can only return one value at a
time.
So you can either return the value of a variable like you
can return an integer, or you can return pointer (which may
contain more than one values), which is pointing to
dynamically allocated location, Like in given below example:
//Returning two values from a function.

#include "stdio.h"
#include "malloc.h"

int *values()
{
int *ptr;
ptr = (int*)malloc(2);
*ptr = 10;
*(ptr+1) = 20;
return ptr;
}

int main()
{
int *ptr = values();
printf("%d\n%d",*ptr,*(ptr+1));
return 0;
}

Is This Answer Correct ?    2 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the process to generate random numbers in c programming language?

1179


How is = symbol different from == symbol in c programming?

1050


What are the functions to open and close file in c language?

1205


Difference between malloc() and calloc() function?

1206


Difference between goto, long jmp() and setjmp()?

1182


What is a char c?

1043


Explain which function in c can be used to append a string to another string?

1092


Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor

3545


What is #include stdlib h?

1105


What are the types of data files?

1206


What is const and volatile in c?

1050


What is cohesion and coupling in c?

1035


Explain what header files do I need in order to define the standard library functions I use?

1173


What is static and auto variables in c?

1091


What does 2n 4c mean?

1235