2012-08-31T08:01:19-04:00
Write program to enter a five digit no..like 12934 n to get 24045 as o/p without arrays
1
2012-09-04T10:40:31-0400
#include "stdafx.h" #include<stdio.h> #include<conio.h> int main() { int n,d1,d2,d3,d4,d5,nd1,nd2,nd3,nd4,nd5; printf("Please, enter a five digit no: "); scanf("%d",&n); d5=n;n=n/10; d4=n;n=n/10; d3=n;n=n/10; d2=n;n=n/10; d1=n; nd5=d5+1; if(nd5>=10){ nd5=0; nd4=d4+2; }else{ nd4=d4+1; } if(nd4>=10){ nd4=0; nd3=d3+2; }else{ nd3=d3+1; } if(nd3>=10){ nd3=0; nd2=d2+2; }else{ nd2=d2+1; } if(nd2>=10){ nd2=0; nd1=d1+2; }else{ nd1=d1+1; } printf("Output: %d%d%d%d%d",nd1,nd2,nd3,nd4,nd5); getch(); return 0; }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
C++
Comments