Expressions and Conditional Statements (Identification Number) ID-3455

Validity of Identification Number (Id-3455)
Given a three digit identification number, the identification number is said to be valid if sum of square of the digits is divisible by 10. Given an identification number, develop an algorithm and write the C code to print ‘Valid’ or ‘Invalid’. For example, 505, 608 are valid and number 444 is invalid.



Input Format



First line contains a three digit identification number



Output Format
Print either Valid or Invalid
sol:- 
 C-CODE: 
#include<stdio.h>
int main()
    {int n,a,r=0;
    scanf("%d",&n);
    while(n!=0){
        a=n%10;
        r=r+a*a;
        n=n/10;}
if(r%10==0)
    {printf("Valid");}
else{printf("Invalid");}}

Post a Comment

0 Comments