from which value ur loop is going to start?
tux4life commented: Agreed +8
jephthah commented: gud answer :P +10
from which value ur loop is going to start?
but starting from 3 will add unnecessary numbers in our answer...u have to check whether ur number is not less than ur input number and should not greater than 30...and also u have to reject sum ur calculated numbers
in my each calculated number will be our answer..and we do only compare with input number...
dude, i can suggest a different approach for ur problem....
since 30 is divisible by 3 so start ur loop from 30 and subtract 3 each time and print until ur number becomes less than the input number...
this approach will print number between ur input and 30 but in decreasing order..
try it.
For finding prime numbers upto a given no, Use "The Sieve of Eratosthenes algorithm"http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
that is a gud way to find out effectively
When we use getchar() then whatever input we give it goes in a buffer and getchar function reads from that buffer.
when first time u entered ur choice it stored in buffer (say u choose a,then buffer will contain a,\n).so first time , getchar picks the choice u supplied but remember \n is still in buffer.so when getchar() is again called then say u entered ur choice 'b'.then the buffer content will be (\n,b,\n). so this time getchar() picks '\n'. that's y u r getting an error.