|
-
January 15th, 2003, 03:42 AM
#1
small C program from a new bie
Can some one help me on these problems
a.) Write a program to input the original price of an item and of d, and
determine on what day the price drops to less than half the original
price.
b.) Write a program to input an integer in between 1-9 and print a line of
output consisting of a line of digits from 1-n followed by descending digits
from n-1.
2.Write a program to read a positive integer to determine
1)whether the integer is even or odd
2)whether the integer is prime or not
3)whether the integer is a perfect
-
January 15th, 2003, 09:55 AM
#2
And? What is your problem???
-
January 15th, 2003, 01:27 PM
#3
Martin,
I think its a college based programs.
-
January 15th, 2003, 08:18 PM
#4
2.1
int number;
cin >> number;
cout << number << (number % 2) ? " is odd" : " is even";
Whats the prize?
Last edited by mwilliamson; January 16th, 2003 at 01:44 PM.
-
January 16th, 2003, 04:46 AM
#5
I offer you beer...
Finally I know which number is odd...
-
January 16th, 2003, 12:04 PM
#6
Cool, I didn't know my computer could discover if an integer was even or odd.
WM.
What about weapons of mass construction?
-
January 16th, 2003, 02:20 PM
#7
-
January 16th, 2003, 03:02 PM
#8
for an integer to be perfect..
double d = 1.10
int i = (int) d; // 1
if ( (double ) (d - i ) == 0 )
its perfect integer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|