+ 3

11. O/P? point out if there is any mistake in program?

11. O/P? point out if there is any mistake in program? char* fun1(int aNum) { int d, end =4; char decimal[5]; int begin = 0; decimal[5] = '\0'; while(begin > end) { d = aNum % 10; decimal[begin++] = d + '0'; aNum = aNum / 10; } return decimal; } int main() { int num = 12345; printf("number %d after fun1() is called is s%", num, fun1(num)); }

21st Feb 2019, 4:44 PM
Balu Ram Kumawat
Balu Ram Kumawat - avatar
1 Odpowiedź
+ 2
Make two changes 1. Make the character array decimal static 2. Change s% to %s in printf function.
23rd Feb 2019, 4:39 PM
Sinjini Das
Sinjini Das - avatar