WebSep 6, 2014 · int newNum = x % (10 ^ (count)); ^ is bitwise xor, it is not a power operator. Instead, you can try something like this: int newNum; if (y < 10) newNum = 0; // or what should it be? else { int denominator = 1; while (y >= 10) { y /= 10; denominator *= 10; } newNum = x % denominator; } P.S. WebJun 19, 2015 · To find last digit of given number we modulo divide the given number by 10. Which is lastDigit = num % 10. To find first digit we divide the given number by 10 …
Sum of the first and last digit of a number in PL/SQL
WebAug 2, 2024 · first_digit = int(number [0]) last_digit = int(number [-1]) addition = first_digit + last_digit print('Addition of first and last digit of the number is', addition) Output: Addition of first and last digit of the number is 8 Time complexity: O (1) since performing constant operations Auxiliary Space: O (1) since using constant space for … WebJul 16, 2024 · The line num/10; doesn't change num, so the loop never terminates.You need num /= 10;.It seems like a long-winded way to do it. You should check that scanf() got a number, that the number is in the range 1000..9999 (otherwise it isn't a 4-digit number under the normal rules of English language), and then you could use num / 1000 + num … c.s. st-jerome
Interchanging the first and last digits of a number in C
WebIn this C Program, we will find sum of first and last digits of a number. To get the last digit of a number we will use '%' modulus operator. Number%10 will give the last digit of the number. Then we will remove one digit at a time form number using below mentioned algorithm and then store the most significant digit in firstDigit variable. Sum ... WebJul 4, 2024 · A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. WebDec 10, 2024 · To find last digit of a number, we use modulo operator %. When modulo divided by 10 returns its last digit. Suppose if n = 1234 … افضل زيت لاندكروزر 6 سلندر 2006