It's been a couple year since I took a programming class and all I can tell is that the programs are reading I/O maybe from keyboard and doing something with numbers and then outputting the numbers. This is pretty important!
The first gets a number from input and then loops around setting the number to itself devided by 8 and adds the modulus of 8 and previous result times 8 and at the end of the loop prints the result. It will only make sense to the person who wrote it. The second prints out the number 90 (122 - 32). Does'nt look very impressive or important?
i think in the first one he tried to convert from base 10 to 8 but didn't quite get it.
the program should be like this:
1 2 3 4 5 6 7 8 9 10 11 12 13
#include<stdio.h>
main(){
long m,d,n=0;
scanf("%d",&m);
while(m>0){
d=m%8;
m=m/8;
n=10*n+d;}//*10 because the computer displays a decimal... we just want it to look like octal
while(n>0){//now we reverse it
d=n%10;
n=n/10;
m=10*m+d;}
printf("0%d",m);}
Thanks guys. It's important because of who wrote it and where and what this person was using computers for. I won't go into details because it would sound ridiculous but thanks!
But the code is screwed up. Strange assignment.
The second one should be something like this:
1 2 3 4 5 6 7 8 9
#include<stdio.h>
int main() {
char k, i;
for( i = 97; i <= 122; ++i ) {
k = i - 32;
printf( "%c", k ); // CHANGED %d TO %c
} // INCLUDED printf IN THE for BLOCK
}
It's a typical assignment -- give the student a piece of code and see if they can figure out what it does. It doesn't have to do anything useful; it just has to be deterministic given fixed input.
It's also a typical exam question. (The first code block might be a bit much for an exam, but I could easily see the second one, given its brevity, being fair game).
Thanks that might make sense that it is a homework assignment I suppose. This guy is suspected of writing programs that use something like a garage door laser, thin tube full of water, pressure plates or crush wire to count vehicles driving by and send the output to a cellphone dtmf board to target specific vehicles in a military convoy. This isn't exactly top secret so there is no harm in anybody knowing but I'm not saying who, where or how I know. Told you it would sound ridiculous but an honest question deserves an honest answer. Thanks a bunch!