c program return statement returns more than one value

>> Wednesday, November 2, 2011

This program makes a contrasting concept that how a return statement
can return more than one value. Usually in C programming we make a call by value.
This means that in general you cannot alter the actual arguments. But if
desired, it can always be achieved through a call by reference.
Using a call by reference intelligently we can make a function
return more than one value at a time, which is not possible
ordinarily. This is shown in the program given below.


#include<stdio.h> #include<conio.h> int areaperi ( int r, float *a, float *p ) { *a = 3.14 * r * r ; *p = 2 * 3.14 * r ; return (0); } int main( ) { int radius ; float area, perimeter ; printf ( "\nEnter radius of a circle " ) ; scanf ( "%d", &radius ) ; areaperi ( radius, &area, &perimeter ) ; printf ( "Area = %f", area ) ; printf ( "\nPerimeter = %f", perimeter ) ; getch(); }

Output :

C program to return more than one value
C porgram to return more than one value.

0 comments:

Post a Comment

About This Blog

This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.

Share and Save