A 5 digit number is input through the key board. Output is a new
number adding 1 to each of its digits in c programming
#include<stdio.h>
int add(long int);
int main(){
long int num;
int add(long int);
printf("\nEnter a 5 digit number:
");
scanf("%ld",&num);
add(num);
return 0;
}
add(long int num){
long int r;
if(num){
r=num%10;
r=r+1;
if(r==10)
r=0;
add(num/10);
printf("%d",r);
}
else
return;
}
No comments:
Post a Comment