當前位置:編程學習大全網 - 編程軟體 - c語言中怎麽調用自己定義的函數?

c語言中怎麽調用自己定義的函數?

在使用壹個函數之前必須先對他進行聲明:

//void B();聲明B函數的存在。void A(){B();//非法,程序執行到此時並不知道B函數的存在。}void B(){}

或者

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

int fa(int n)

{

int a;

for(a=2;a<=sqrt(n*1.0),n%a!=0;a++);

if(a>sqrt(n*1.0))

return(1);

else

return(0);

}

void main( )

{

int n,q;

scanf("%d",&n);

擴展資料

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

int fa(int n)

{

int a;

for(a=2;a<=sqrt(n*1.0),n%a!=0;a++);

if(a>sqrt(n*1.0))

return(1);

else

return(0);

}

void main( )

{

int n,q;

scanf("%d",&n);

if(fa(n)==1)

printf("n");

else

printf("y");

system("pause");

exit(0);

}

參考資料:

百度百科 - C語言函數

  • 上一篇:重慶科技學院有哪些院系,重慶科技學院院系設置,部門
  • 下一篇:風行編程
  • copyright 2024編程學習大全網