Problem Statement
Write a program to replace X by digits to make the integer divisible by 4
Note: we have to replace x by numbers digit from 0 to 9, so that it will be divisible by 4.
Solution
#include<stdio.h> //For input/output standard function in c program
#include<stdlib.h>
#include<string.h>
int main()
{
int i;
char s[100];
scanf("%s",s);
for(i='0';i<'9';i++)
{
s[strlen(s)-1]=i;
if(atoi(s)%4==0) //atoi function used to convert string into integer
printf("%s ",s);
}
}
Input
246X
Output
2460 2464 2468
Input
64474X
Output
644740 644744 644748