Advertisement
dmilicev

four_functions.c

Apr 4th, 2021
564
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3.     four_functions.c
  4.  
  5.     Task:
  6.     https://www.facebook.com/photo/?fbid=873946883160845&set=gm.1860810587411116
  7.  
  8.     From Arslan Jadoon
  9.     https://www.facebook.com/groups/177292205762971/user/100016366244425/
  10.  
  11.  
  12.     You can find all my C programs at Dragan Milicev's pastebin:
  13.  
  14.     https://pastebin.com/u/dmilicev
  15.  
  16. */
  17.  
  18. #include <stdio.h>
  19. #include <string.h>
  20.  
  21. char* function1_string( char text[100], int i1, float f2, double d3 )
  22. {
  23.     sprintf(text, "\n Result is %f \n", i1 + f2 + d3 );
  24.     return text;
  25. }
  26.  
  27. int function2_int_square( int x1 )
  28. {
  29.     return (x1*x1);
  30. }
  31.  
  32. float function3_float_product( int x1, float x2 )
  33. {
  34.     return(x1*x2);
  35. }
  36.  
  37. double function4_double_division( int x1, float x2, double x3)
  38. {
  39.     return( (double)(x1+x2/x3) );
  40. }
  41.  
  42. int main(void)
  43. {
  44.     char var_string[100];
  45.     int var_int=1;
  46.     float var_float=2.0;
  47.     double var_double=3.0;
  48.  
  49.     printf("\n %s \n", function1_string( var_string,
  50.                                          function2_int_square(var_int),
  51.                                          function3_float_product(var_int, var_float),
  52.                                          function4_double_division(var_int, var_float, var_double) ) );
  53.  
  54.     return 0;
  55.  
  56. } // main()
  57.  
Advertisement
RAW Paste Data Copied
Advertisement