Write a function to convert a letter to a number.
Write a function to convert a number to a letter.
Run your input through your function of choice.
Quzah.
Write a function to convert a letter to a number.
Write a function to convert a number to a letter.
Run your input through your function of choice.
Quzah.
Hope is the first step on the road to disappointment.
ok
just while im in the middle of trying stuff then....
I noticed that when I have
temp = pow(array1[i],3);
it calculates the right number,
but if I have
temp = pow(array1[i],7);
it doesnt calculate the number to the power of 7 correctly. Does the pow() function not allow past a certain number?
Is there anyway I could make this work....
ok wait i have to use something larger than an int dont i?
ok i donno
}Code:int i; double temp2; double cseven[30]; printf("\n Decryption: \t"); for (i=0; i<length; i++) { temp2 = pow(array1[i],7); cseven[i] = temp2%33; printf(" %f ", cseven[i]);
when I try longints, it doesnt work, when I try floats or doubles I know it works because if I print out temp2 afterwords it is correct. But if I then do: cseven[i] = temp2%33; etc... as above when compiling I get the error:
illegal use of floating point in function
temp2 is assigned a value that is never used...
please help
Perhaps you should convert the double into an int and then do it Not sure it'll work but it's just an idea.
nope now im gettin the wrong answer again
It seems you cant modulus a float or double,
and when i do this....
It seems to only work to an extent, if array1[i] is like over a certain number, it won't work. It works if array1[i] is 21, but not 26.Code:int i; double temp2; int cseven[30]; long temp3; printf("\n Decryption: \n"); for (i=0; i<length; i++) { temp2 = pow(array1[i],7); temp3 = temp2; printf(" %ld \n ", temp3); printf(" %ld \n ", temp3%33); }
so stuck.....
26^7 is what number? Big. Too big in fact to fit in a 32 bit number. You can't hold infinity in 32 bits.
Quzah.
Hope is the first step on the road to disappointment.
Yea i figured size was the problem, The answer for 26^7 is 8031810176. I just wanted to know was there a way to get around it.
ok figured out how to get the right answer,
after using alot of temps!
It prints the correct answers as would using %. Thanks for all help given.Code:printf("\n Decryption: \n"); for (i=0; i<length; i++) { temp2 = (double)pow(ciphertext[i],7); temp3 = temp2/33; temp5 = temp3; temp6 = temp5; temp4 = temp6*33; printf(" temp 5 is %ld \n\n ", temp5); printf(" temp 4 is %f \n ", temp4); temp7 = temp2-temp4; cseven[i] = temp7; printf(" temp 7 is %d \n ", cseven[i]); }