【急!!!】麻烦用C语言为下面题目编程!!!!

(1)编程完成任务:输入半径,计算圆面积。
提示:
 定义两个变量存放半径和圆面积的值;
 给半径赋值;
 计算圆面积=3.14*半径*半径;
 输出圆面积的值。
(2) 编写一个简单的加法程序,随机生成两个100以内的整数,求出它们的和并输出。

#include <stdio.h>

#include<stdlib.h>

#include<time.h>

#include<math.h>

#define PI 3.1415926

int main()

{

int a,b;

double s,r;

//(1)

printf("ENTER R\n");

scanf("%lf",&r);

s=PI*r*r;

printf("Area:%lf\n",s);

//(2)

srand(unsigned(time(NULL)));

a=rand()%100;

b=rand()%100;

printf("a:%d, b:%d,a+b:%d\n",a,b,a+b);

system("pause");

return 0;

两题写在一起了

温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-02-22
第一题
#include <stdio.h>
#include <string.h>
#include<math.h>
const double PI=acos(-1.0);
int main()
{
double s,r;
scanf("%lf",&r);
s=PI*r*r;
printf("%lf\n",s);
return 0;
}

第二题

#include <stdio.h>
#include <string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
const double PI=acos(-1.0);
int main()
{
int a,b;
srand(unsigned(time(NULL)));
a=rand()%100;
b=rand()%100;
printf("%d\n",a+b);
return 0;
}

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网