使用gets_s()函数读取输入并使用atoi()将其转换为整数值

#include <stdio.h>
#include <stdlib.h>
int getval(void);
int main()
{
   int age,weight,area;
   float iq;
   printf(Program to calculate your IQ.\n);
   printf(Enter your age:);
   age=getval();
   printf(Enter your weight:);
   weight=getval();
   printf(Enter the your area code:);
   area=getval();
   iq=(age*weight)/area;
   printf(This computer estimates your IQ to be %f.\n,iq);
   return(0);
}
int getval(void)
{
   char input[20];
   int x;
   gets_s(input);
   x=atoi(input);
   return(x);
}

相关文章

for遍历数组
。。。
声明一个计数循环
咕咕咕
#include <stdio.h> int main (void) { printf (&quo...