In the main ab() is called ,when ab() is called ,as in ab() a is local variable(lifetime and scope is local) and s is static variable and here s is assigned value 5 ,then a=++s so a will have value 6 and s will have value equal to 6 so 66 will be printed then condition will be check a<=7 (6<=7 true) so ab() will be called again without reaching the last line ,now a will be created again and s will not be created as it is static and a=++s will executed and now a and s will have 7 and 7 so 77 will be printed now again condition will be checked a<=7(7<=7 true) ,now ab() will be called one more time ,once again a will be created and a=++s will be executed so a and s will have value 8 and 8 so 88 will be printed ,then condition will be checked a<=7(8<=7 false) so execution will go to the last line ,now 887868 will be printed as i described in image so finally 667788887868 will be printed.