Posted by **Kevin** on Friday, February 1, 2013 at 10:24pm.

I need help with c programming, i need to fill in the code and I got these (need help with question 4), I run the grader and I only got question 1 right.

grader code:

gcc worksheet.c;

./a.out 0;

if [ $? -eq 0 ]

then

echo 'Question 0 Correct';

else

echo $? 'is not correct for question 0';

fi

./a.out 1;

if [ $? -gt 1 ]

then

echo 'Question 1 Correct';

else

echo $? 'is not correct for question 1';

fi

./a.out 2 9;

if [ $? -eq 9 ]

then

./a.out 2 5;

if [ $? -eq 5 ]

then

echo 'Question 2 Correct';

else

echo 'Not Correct for Question 2';

fi

else

echo 'Not Correct for Question 2';

fi

./a.out 3 9;

if [ $? -eq 0 ]

then

./a.out 3 5;

if [ $? -eq 1 ]

then

echo 'Question 3 Correct';

else

echo 'Not Correct for Question 3';

fi

else

echo 'Not Correct for Question 3';

fi

./a.out 4 1;

if [ $? -eq 5 ]

then

./a.out 4 2;

if [ $? -eq 25 ]

then

echo 'Question 4 Correct';

else

echo 'Not Correct for Question 4';

fi

else

echo 'Not Correct for Question 4';

fi

rm a.out;

homework code:

//DO NOT ALTER THE MAIN FUNCTION, THIS IS FOR GRADING.

int main(int argc, char * argv[]){

switch(argv[1][0]){

case 0:

return question0();

case 1:

return question1();

case 2:

return question2(argv[2][0]-48);

case 3:

return question3(argv[2][0]-48);

case 4:

return question4(argv[2][0]-48);

default:

return 1;

}

}

int question0(){

//return a successful exit status.

return 0;

}

int question1(){

//return your favorite positive number greater than one.

return 2;

}

int question2(int arg){

//return your input.

return arg;

}

int question3(int arg){

//if arg is greater than 5 return 0, otherwise return 1.

if (arg > 5){

return 0;}

else {

return 1;

}

}

int question4(int arg){

//return 5 multiplied by itself arg-1 times.

for (arg = 0; arg < 1; arg++){

5 * arg;

}

}

## Answer This Question

## Related Questions

- Questions - Okay, so I'm doing this project on careers and I need pictures. Can ...
- chemistry - thanks DrB I got AgCl also Could you check this problem as well? If ...
- Computer Literary - Which of the following is Not an example of debugging A)...
- Question - Okay, so I'm doing this project on careers and I need to find out the...
- Computer Programming - can anyone give me site about programming I need a sample...
- BIO - I really need help with this question, Damon gave me an answer, but I do ...
- bcis MS Projects - I downloaded the trail version. got the free key code...the ...
- Mathematics . - I need some help with this specific question. In a computer ...
- MATH - i need to write each expression as a product of the same factor: * = ...
- math exponents - i need to write each expression as a product of the same factor...

More Related Questions