Return string from function by R4R Team

For return the Alphabet value from the function we need to make the return type as a char.

Syntax-

char function_name()
{
return value;
}

Example-
char f()
{
return 'A';
}
// no error

void f()
{
return 'A';
}
// Give an error


program-

#include< stdio.h>
char function() //definition
{
printf("You make the function\n");
return 'A';
}
int main()
{
char a;
printf("Inside main function\n");
a=function(); //calling
printf("%c",a);
return 0;
}


output-

Inside main function
You make the function
A

-In this program, we make a function named as function() have char return type, this means that it only return the characters value.
-So function() return the value A by return 'A'; and this value is catch by the variable 'a' in main() function.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!