Saturday, May 22, 2010

Study the sequence of numbers and create the C-language program (using iteration) for the proper sequence of 2

Study the sequence of numbers and create the C-language program (using iteration) for the proper sequence of 2 numbers entered by the user. If the number is zero, the user will be asked to enter again.


Sample:


Enter 2 numbers: 5, 10





5 15 24 32 39 45 50 54 57 59 60





total: 440

Study the sequence of numbers and create the C-language program (using iteration) for the proper sequence of 2
I do not have a C compiler. Still I am suggesting a pseudocode.





do


{


input two numbers i1 and i2;


if (i2 %26lt; = 0 )


{print " the second number should be greater than zero";


loop;


}


i3 =0;


while (i2-- %26gt; 0)


{


print i1;


i1 += i2;


i3 += i1;


}


}


while ( i1 %26gt; 0)


print "total : ", i3;


end;





I hope you can adapt this to C, else you can email me;


No comments:

Post a Comment