/**
*Program Name : cis6Fall2017CarterJHw3Ex1.c
*Discussion : Hw3Ex1
*Written By : Jonathan Carter
*Date : 2017 / 10 / 24
*/
#include <stdio.h>
void displayClassInfoJonathanC(void);
void runMenuHw4Version4(void);
int extractDigitCountVersion4(int);
int extractDigitCountVersion2(int);
int extractDigitVersion1(int);
int main() {
displayClassInfoJonathanC();
runMenuHw4Version4();
return 0;
}
void displayClassInfoJonathanC() {
printf(
"\nCIS 6 - Introduction to (C) Programming"
"\nLaney College"
"\nJonathan Carter"
"\n"
"\nAssignment Information --"
"\n Assignment Number : Homework 4,"
"\n Coding Assignment -- Exercise #1"
"\n Written by: Jonathan Carter"
"\n Submitted Date: 2017/11/09"
"\n");
}
int extractDigitCountVersion2(int arg) {
int digitCount;
int quotient;
if (arg != 0) {
digitCount = 0;
quotient = arg;
while (quotient != 0){
digitCount++;
quotient /= 10;
}
} else {
digitCount = 1;
}
return digitCount;
}
int extractDigitCountVersion4(int arg) {
int digitCount;
int tmp;
tmp = arg;
digitCount=0;
do {
digitCount++;
tmp /= 10;
} while (tmp != 0);
return digitCount;
}
int extractDigitVersion1(int arg) {
do {
printf("\n %d",
((arg < 0) ? -arg : arg) % 10);
arg /= 10;
} while (arg != 0);
printf("\n %d");
}
void runMenuHw4Version4() {
int option;
int usrValue;
do {
printf(
"\n*****************************************"
"\n* MENU - HW #4 *"
"\n*(1) Calling displayAllDigitJonathanC() *"
"\n* 2. Quit *"
"\n*****************************************");
printf("\nEnter an integer for option + ENTER: ");
scanf("%d", &option);
switch (option) {
case 1:
printf("\nEnter an intteger: ");
scanf("%d", &usrValue);
if (usrValue < 0) {
printf("\nCalling displayAllDigitJonathanC()--"
"\nThis is a negative number."
"\nThere is/are %d digit(s)"
"\nThe digit(s) would be\n"
"\n%d" , extractDigitCountVersion2(usrValue),usrValue);
}
else if (usrValue > 0) {
printf("\nCalling displayAllDigitJonathanC()--"
"\nThis is a postive number."
"\nThere is/are %d digit(s)"
"\nThe digit(s) would be"
"\n%d\n", extractDigitCountVersion2(usrValue))(((extractDigitVersion1)));
}
else {
printf("\nThe given value is ZERO!\n");
}
break;
case 2:
printf("\nHave fun!\n");
break;
default:
printf("\nWrong Option!\n");
}
} while (option != 2);
}
/*OUTPUT*/
/*YOUR_Logic Issues_Code Issues,
none*/
Enter an intteger: 123456
6
5
4
3
2
1
0
Calling displayAllDigitJona
This is a postive number.
There is/are 6 digit(s)
The digit(s) would be
4
^
what the code looks like now
Calling displayAllDigitJona
This is a postive number.
There is/are 6 digit(s)
The digit(s) would be
6
5
4
3
2
1
i need my code to look like this