Answered Questions

  • Print Sum of Digits

    Write a function to print sum of the digits in a given integer n without converting it to String. For example : if n = 1234 the function should return 1+2+3+4 = 10 if n = 15 the function should return 1+5 =6 if n = 5 the function should return 5.

    sravani reddy

    • Sep 21st, 2017

    Code
    1. #include<stdio.h>
    2. int main()
    3. {
    4. int rem,sum=0,n;
    5. printf("enter the number:");
    6. scanf("%d
    7. ",&n);
    8. while(n!=0)
    9. {
    10. rem=n%10;
    11. sum=sum+rem;
    12. n=n/10;
    13. }
    14. printf("the sum of digits of a number is %d",sum);
    15. return 0;
    16. }

    Shasan

    • Mar 29th, 2016

    "c# public static int Sum() { int n = 1235678; int n1 = 0; int f = 0; while (n!= 0) { ...

  • Can we use commit or rollback command in the exception part of PL/SQL block?

    Star Read Best Answer

    Editorial / Best Answer

    Answered by: answertoyourquery

    • Nov 9th, 2005


    Yes, we can use the TCL commands(commit/rollback) in the exception block of a stored procedure/function. The code in this part of the program gets executed like those in the body without any restriction. You can include any business functionality whenever a condition in main block(body of a proc/func) fails and requires a follow-thru process to terminate the execution gracefully!

    Leena Roja

    • Jul 13th, 2015

    Correct Subhash..

    Susil Kumar Nagarajan

    • Jan 21st, 2012

    Yes. You can very well use COMMIT or ROLLBACK in exception block. But it is not a good idea to use, as it will commit the previous transactions in the same PLSQL block. Make use of creating SAVEPOINTS and commiting them when required.