Function which returns int value : Function « Function « C / ANSI-C






Function which returns int value

#include <stdio.h>

int convert(void);

int main(void)
{
  printf("%d", convert());

  return 0;
}

int convert(void)
{
  int dollars;

  printf("Enter number of dollars: ");
  scanf("%d", &dollars);
  return dollars / 8;
}

           
       








Related examples in the same category

1.Define function to sum
2.Definition of the function to calculate an averageDefinition of the function to calculate an average
3.Demonstraction of function call
4.Function call
5.Check out the int value change before and after function callCheck out the int value change before and after function call
6.Define function to multiply two int
7.Uses a function prototype to enforce strong type checking
8.Serve as a prototype within this program
9.Define function and use it: square
10.Function: Print a string in uppercase
11.A program with two functions
12.This program has three functions
13.Define function and use it
14.Return statement
15.Assign function return value to a variable
16.A simple program that demonstrates sum()
17.Define function to output char
18.Function to output square
19.Define two functions and call them in main
20.Define function with void return
21.Define function to calculate the ounces and cups
22.Function declaration
23.Define function to calculate the volumn
24.Function prototype: declare getnum() prior to its first use
25.Define function and return value
26.Define function with parameter and return value
27.Function call each other
28.Define two functions and make function call
29.Global and local variable inside function
30.Function prototype