Programming Exercise 3.4 from Modern C Programming Methods, 2nd Edition
Programming Exercise 3.4
#include
int main()
{
printf(“Enter phone number[(xxx) xxx-xxxx]:”);
int num1,num2,num3;
/* Use num+number to represent the three segments of the phone number */
scanf(“(%d) %d-%d”,&num1,&num2,&num3);
printf(“You entered %.3d.%.3d.%.4d\n”,num1,num2,num3);
/* %.3d,%.4d indicates the integer with a specified width, and leading zeros will be displayed without spaces */
return 0;
}
#include
int main()
{
printf(“Enter phone number[(xxx) xxx-xxxx]:”);
int num1,num2,num3;
scanf(“(%d) %d-%d”,&num1,&num2,&num3);
printf(“You entered %.3d.%.3d.%.4d\n”,num1,num2,num3);
return 0;
}