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 spark map function?

1066


Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1039


What are header files in c programming?

1085


Explain the properties of union.

1027


the portion of a computer program within which the definition of the variable remains unchanged a) mode b) module c) scope d) none

1007


Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?

1210


What are register variables? What are the advantage of using register variables?

1138


Can you add pointers together? Why would you?

1079


what are # pragma staments?

2004


State two uses of pointers in C?

1013


how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

1028


write a c program to calculate sum of digits till it reduces to a single digit using recursion

3255


Explain how can you restore a redirected standard stream?

1045


write a c program to find the sum of five entered numbers using an array named number

2085


What is a 'null pointer assignment' error?

1172