Below is your code.. This can take candidate id of very long length because I am using long long int. Let me know if you have any issues: –
#include
#include
void main() {
long long int candId, digit, sum = 0;
printf(“Enter the candidate number: “);
scanf(“%ld”, &candId);
while (candId > 0)
{
digit = candId % 10;
sum = sum + digit;
candId /= 10;
}
if (sum < 20) {
printf(“Sum to the power of 2 = %lldn”,(int)pow(sum,2));
} else {
printf(“Square root of the sum = %fn”,sqrt(sum));
if(sum == 25) {
printf(“Sum of digits = %lldn”,sum);
}
}
}
Output
