BCA

C LAB :PART A

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

C LAB : PART B

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

Write a C Program to read a number, find the sum of the digits, reverse the number and check it for palindrome

 

 /* Write a C Program to read a number, find the sum of the digits, reverse the number and check
it for palindrome */


#include < stdio.h>

 

void main()

{

    int num1 ,m,n,remainder ,rev=0,reversed=0,sum=0,original;

 
    printf("Enter the values :\n");

    scanf(" %d", &num1 );

        n=num1;
        while(n>0)    
        {    
                m=n%10;    
                sum=sum+m;    
                n=n/10;    
        }    
        printf("\n  Sum is=%d",sum);    

        original=num1;
        n=original;
        
/// REVERSE NUMBER
        while (n != 0) {
                remainder = n % 10;
                rev = rev * 10 + remainder;
                n /= 10;
            }
            printf("\n Reversed number = %d", rev);

    
        reversed=rev;

 // palindrome if orignal and reversed are equal
    if (original == reversed)
        printf(" \n %d is a palindrome.", original);
    else
        printf(" \n %d is not a palindrome.", original);

}