![]() |
|
|
| Subject:
Computer Science (if/then/else primitive)
Category: Computers Asked by: jtallen7-ga List Price: $2.00 |
Posted:
13 Feb 2005 15:40 PST
Expires: 15 Mar 2005 15:40 PST Question ID: 473998 |
Write an if/then.else primitive to do each of the following operations. A. Computer and display the value x divided by y if the value of y is not 0. If y does have the value 0, then display the message "unable to perform the division." B. Computer the area and circumference of a circle given the radius r if the radius is greater than or equal to 1.0; otherwise, you should compute only the circumference. |
|
| There is no answer at this time. |
|
| Subject:
Re: Computer Science (if/then/else primitive)
From: khoatran-ga on 13 Feb 2005 17:35 PST |
A.
if (y !=0)
printf ("%f", x/y)
else
printf ("unable to perform the division.");
B.
if (r >= 1.0)
printf ("area: %f\n", 2*pi*r);
printf ("circumference: %f", pi*r*r); |
| Subject:
Re: Computer Science (if/then/else primitive)
From: aquatopia-ga on 28 Feb 2005 01:49 PST |
//The following is written in C++
#include <iostream>
using namespace std;
void partA(double x, double y)
{
if(y != 0)
cout << (x / y) << endl;
else
cout << "unable to perform the division." << endl;
}
void partB(double r)
{
double results = 0.0;
double const PI = 3.14159;
if(r >= 1.0) cout << "Radius = " << (PI * r * r) << endl;
cout << "Circumference = " << (2 * r * PI) << endl;
} |
| Subject:
Re: Computer Science (if/then/else primitive)
From: inmar2002-ga on 08 Mar 2005 05:37 PST |
A.
/* This program is in 'c programming language save it with .c extension*/
#include <stdio.h>
#include <conio.h>
void main()
{
float x,y,d;
clrscr();
printf("Enter any value for x and y :");
scanf("%f %f",&x,&y);
if(y==0)
printf("unable to perform the division.");
else
{
d=x/y;
printf(" Division = %f",d);
}
getch();
}
B.
/* This program is in 'c programming language save it with .c extension*/
#include <stdio.h>
#include <conio.h>
void main()
{
float radius,area,circum;
clrscr();
printf("Enter any value for radius:");
scanf("%f",&radius);
if(radius>=1.0)
{
area=3.14*radius*radius;
circum=2*3.14*radius;
printf("area = %f and circumference = %f",area,circum);
}
else
{
circum=2*3.14*radius;
printf("circumference = %f",circum);
}
getch();
} |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
| Search Google Answers for |
| Google Home - Answers FAQ - Terms of Service - Privacy Policy |