d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > 1000 Fg To Complete This C Hw The Right Way > Ty
Add Reply New Topic New Poll
Member
Posts: 16,138
Joined: Feb 6 2014
Gold: 2,985.99
Warn: 40%
Sep 14 2014 03:20pm
2. Write a program that repeatedly (until end-of-file) reads
in a character from the input stream. For all characters other
than the tab character, write the character unchanged to the
output stream. When a tab character is read in, write out N
space characters. N is an int constant declared at the top of
the program and is easily changed. (Hard-coding a particular
N is not good.)
Use getchar() for input, Use putchar() for output, and use
input redirection for connecting the input file to the program
(see page 16 of Quickstart).
C:\> lowerCase < anyOldTextFile.txt > newOutputFile.txt
You will need an if-statement nested inside a while loop for this. Of course,
the program will work with any size of text file and makes no assumptions
about line length.





3. An amicable pair of numbers consists of two different integers where the
sum of the divisors of the first integer is equal to the second integer, and the
sum of the divisors of the second integer is equal to the first integer. For
example, (220, 284) is an amicable pair because
284 is divisible by 1, 2, 4, 71, and 142 and the sum of those is 220
220 is divisible by 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110 and the sum of those is 284

Write a program that asks for a lower limit and an upper limit. The program
finds all pairs of amicable numbers between the limits. Use data type long
for the numbers. To do this sensibly, write a function
long sumDivisors( long n );
that returns the sum of all the divisors of n. The main program will look at
each number between the limits. For each number n, compute the sum s of
its divisors. Then check if the sum of the divisors of s is the original number
n. If n and s are the same number, then n is perfect. The program will write
out amicable pairs and perfect numbers that it finds, one per line. Write out
just one number if it is perfect.
Write sumDivisors()as a loop that checks each integer from 1 up to n/2
and sums the ones that divide n without leaving a remainder.


This post was edited by captaindookiefrankwest71 on Sep 14 2014 03:21pm
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Sep 14 2014 04:17pm
1000fg per project or for both together. Also when is the due date.
Member
Posts: 16,909
Joined: Aug 14 2009
Gold: 0.00
Sep 17 2014 09:00pm
is it just me or does that top one look like a keylogger?
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Sep 17 2014 09:02pm
Quote (zell1luk @ Sep 17 2014 07:00pm)
is it just me or does that top one look like a keylogger?


definitely does
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Sep 17 2014 10:45pm
Quote (zell1luk @ Sep 17 2014 11:00pm)
is it just me or does that top one look like a keylogger?


Because keyloggers read from STDIN...
Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
Sep 17 2014 11:57pm
Quote (AbDuCt @ Sep 17 2014 10:45pm)
Because keyloggers read from STDIN...


the h4ck3r got a hold of my .bash_history :'-( all my bank accounts gone
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll