「C言語」引数ありの関数を呼び出すサンプル

構文
void 関数名(型 引数1,型 引数2);

サンプルコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#include <stdio.h>
void testfunc(int x, int y){
/* 変数の宣言 */
int res;
res = x - y;
/* 結果 */
printf("result=%d\n", res);
}
int main(void){
int a = 22;
int b = 10;
/* 関数の呼び出し */
testfunc(a, b);
return 0;
}
#include <stdio.h> void testfunc(int x, int y){ /* 変数の宣言 */ int res; res = x - y; /* 結果 */ printf("result=%d\n", res); } int main(void){ int a = 22; int b = 10; /* 関数の呼び出し */ testfunc(a, b); return 0; }
#include <stdio.h>

void testfunc(int x, int y){

  /* 変数の宣言 */
  int res;
   res = x - y;

  /* 結果 */
  printf("result=%d\n", res);
}

int main(void){


  int a = 22;
  int b = 10;

  /* 関数の呼び出し */
  testfunc(a, b);

  return 0;
}

実行結果
result=12

C言語

Posted by arkgame