0
I am a beginner, and I am having problems with making algorithms for a problem. What do I do?
I learned C language, but i can't solve a single problem. The problem is not the understand the problem itself, but devising an algorithm for it. I just can't think what to do. For e.g., a program that adds the digits of number input by the user. So, 45 would be the input, and the output should be 4+5=9. But the problem is i can't make an algorithm to solve the problem; despite knowing all the basics of C that is needed to solve the problem. What should i do about it?
1 Odpowiedź
+ 3
hey Sanidhya
Don't take much pressure , we all are gone from this situation , these problem solving skills comes very slow when we are begging , just stick with some basics and practice easy question thst motivates you ! IT TAKE TIME .
see what happens :
1.we have number e.g. in your situation 45
2.first we have to think that how can i get one digit from that number .( by doing modules " % " of 10 we get remainder i.e.last digit)
3.but now when we apply modules the actual number be same , we just got remainder (last digit) , now think about how can i reduce it to one digit (by dividing " / " ) .
4. we got 4 , just add it !
num=1234;
remainder=num%10; //gets last digit
num=num/10; //reduces the number
sum=sum+remainder; //adding all the remainders
//do until number gets to zero
print sum;
HOPE THIS WILL HELP YOU !
(if you code this , drop link here , we fill you understand)