Can someone help me with a simple C programming problem?
How do I make some code like this into its own function?
Currently it's pat of the main function, but I want to be able to
call it.
If you could help me with the prototype, function call, and
definition, I'd really appreciate it.
Thanks!
if(some_input=='r'){
someone = 0;
}
else if(some_input=='p'){
someone = 1;
}
else if(some_input=='s'){
someone = 2;
}
else if(some_input=='q' || some_input=='Q'){
break; // Breaks infinite loop and ends the program if user inputs q or Q
}
else {
printf("INPUT ERROR! Please try again.\n\n");
continue;
}
#include <stdio.h>
int func();
int main(){
int result = func();
printf("Return value = %d
",result);
return 0;
}
int func(){
char some_input, temp;
int someone;
while(1){
printf("Enter a character: ");
scanf("%c",&some_input);
scanf("%c",&temp);
if(some_input=='r'){
someone = 0;
}
else if(some_input=='p'){
someone = 1;
}
else if(some_input=='s'){
someone = 2;
}
else if(some_input=='q' || some_input=='Q'){
break; // Breaks infinite loop and ends the program if user inputs q or Q
}
else {
printf("INPUT ERROR! Please try again.
");
continue;
}
}
return someone;
}

Can someone help me with a simple C programming problem? How do I make some code...
Can someone let me know what to do for this? In C
Programming.
HERE ARE INSTRUCTIONS:
This is my code for that specific section:
void displayScoreCard(int scoreCard[CATEGORIES][COLS])
{
printf("\n\n\t\tYAHTZEE SCORECARD\n");
displayUpperSection(scoreCard);
displayLowerSection(scoreCard);
printf("\t\t+-------------+-------------+\n\n");
printf("+-----------------|-----------|\n");
printf("+ TOTAL (Upper) | %d |\n", ZERO);
printf("+-----------------|-----------|\n");
printf("+ GRAND TOTAL | %d |\n", ZERO);
printf("+-----------------|-----------|\n\n\n");
}
Update function displayScoreCard to do the following a. Declare local variable total set equal to the result from function call sumUpper and checkBonus b. Declare local variable grandTotal set...
Can someone help me fix my C code. I am getting segmentation fault along with missing termination " /* These are the included libraries. */ #include #include #include #include void printTriangle(char *str); int main() { char sentence[81]; int done = 0; while(done != 1) { printf("Please enter the sentence or quit: "); fgets(sentence, 80, stdin); if(strcmp(sentence, "quit") == 0) done = 1; else printTriangle(sentence); } } void printTriangle(char *str) { int index = 0; int line = 1; int i;...
Hello can someone help me figure this out for my revision using C Programming. thanks! Given the following function prototype: void trimPositive(int* *arr, int *size) ; write the corresponding function definition such that: given any (dynamically allocated) array of ints and its size via the arr and size parameters, the result of your function is that: a) the int* array argument points to a new (dynamically allocated) array that is completely full, and whose values are exactly the positive values...
Can someone let me know what to do for this? In C
Programming.
HERE ARE INSTRUCTIONS:
Here is my code I have that needs to be edited with
instructions. :
void displayUpperSection(int
scoreCard[CATEGORIES][COLS]){
printf("+-----------------|-----------|\n");
printf("+ UPPER SECTION | SCORE |\n");
printf("+-----------------|-----------|\n");
printf("+ ONEs | %d |\n", scoreCard[one][COL]);
printf("+-----------------|-----------|\n");
printf("+ TWOS | %d |\n", scoreCard[two][COL]);
printf("+-----------------|-----------|\n");
printf("+ THREES | %d |\n", scoreCard[three][COL]);
printf("+-----------------|-----------|\n");
printf("+ FOURS | %d |\n", scoreCard[four][COL]);
printf("+-----------------|-----------|\n");
printf("+ FIVES | %d |\n", scoreCard[five][COL]);
printf("+-----------------|-----------|\n");
printf("+ SIXES | %d...
C++ Can someone please help me with this problem- commenting each line of code so I can understand how to solve this problem using the C++ programming language? I really need help understanding how to create a file for the program to read. Do I create the file in Visual basic or create a text file? I have the code, just need to know how to create the file for it to read. #include<fstream> #include<iostream> using namespace std; int main()...
C Programming Can someone please explain me while the following (c) code prints out 6? for (i=1; x<=5; i++); printf ("%d",i); i=1 initializes the the loop, it is being tested whether it is <= 5 or not. This statement is true, so it goes into the loop and prints 1. After that, i++, means 1+1=2, i=2. This statement is being tested and it is true, we go into the loop and print 2. Then i=3, true, loop prints 3 -->...
Hi, I need help with this question to my coding assignment. I
completed letter A in the remaining program I just need help with
letter "B" and by the way this is C programming. If you can't do
it, just explain to me in very simple terms what I would do.
void updateScores(int scoreCard[CATEGORIES][COLS], int
category,int dice [5])
{
switch(category)
{
case ONE:
printf("Scoring Ones...\n");
break;
case TWO:
printf("Scoring Twos...\n");
break;
case THREE:
printf("Scoring Threes...\n");
break;
case FOUR:
printf("Scoring Fours...\n");...
Hi can someone please help me with this chemistry problem? I really appreciate it. The following data was collected for the volume of the O2 produced in the decomposition of H2O2 Calculate the average rate of reactoion for each of the given time interval. Time mL O2 0.0 0.0 45.0 2.0 88.0 3.9 175.0 6.8 I would really appreciate steps on how to solve this, so I can finish the rest of the similar problems. Thank you!
Can someone help me write a retirement calculator program in c code. I want to write a program that the user can enter their age, amount they wish to save each month, the interest rate, and the age they wish to retire. I would like to use a switch loop, if else loop or do while loop. the output should show them how much they should have in a retirement savings account at the age they wish to retire at....
Please I need help in C language, I am trying to modify the code per the below instructions, but I am getting errors. Can't fgure it out. The attempted code modification and data file is privided below, after the instructions. Thank you. Instructions: 1. First, add a function named printMsg that displays a message, a greeting, or an introduction to the program for the user. Add a statement that calls that function from the main function when your program starts....