Question

Programming in C language (not C++) Write a main function with a function call to a...

Programming in C language (not C++)

Write a main function with a function call to a function called Calculation which has two integer arguments/ parameters. The function returns a character. Declare and initialize the necessary data variables and assign balues needed to make it executable and to prevent loss of information.

//input 2 integer values
//returns the characterequivalent of the higher of the two integer values
char Calculation(int, int);

Homework Answers

Answer #1

#include <stdio.h>

//function to return a character equivalent of th higher of two number
char Calculation(int a, int b)
{
//variable declaration
int high;
char ch;
  
//find the highest number
if(a>b)
high = a;
else
high = b;
  
//convert into character equivalent
ch = high +'0';
  
//return statement
return ch;
}

int main()
{
//function calling and display result
printf("%c", Calculation(5, 17));

return 0;
}

OUTPUT:

A

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
FOR C PROGRAMMING LANGUAGE Write a recursive C PROGRAMMING LANGUAGE function int sumStrlens(const char* str1, const...
FOR C PROGRAMMING LANGUAGE Write a recursive C PROGRAMMING LANGUAGE function int sumStrlens(const char* str1, const char* str2) which returns the sum of strlen(str1) and strlen(str2). You can assume that strlen(str2) is always strictly greater than strlen(str1) (strlen(str2) > strlen(str1)). You MAY NOT use any function from string.h. You MAY NOT use any square brackets([]) or any type of loops in function.
Program: 6: Function overloading AIM: To write a C++ program to illustrate the concept of function...
Program: 6: Function overloading AIM: To write a C++ program to illustrate the concept of function overloading. PSEUDOCODE: Declare necessary variables. Create a class with add(int,int) ,add(float,float) as member functions and necessary variable. add(int,int) is used to add two integer values. add(float,float) is used to add two float values. Using object call the required function with corresponding input. Display the output.
How would I write this function in C programming language? Function header: int input(int *a, int...
How would I write this function in C programming language? Function header: int input(int *a, int *b, int *c) This function should attempt to input 3 integers from the keyboard and store them in the memory locations pointed to by a, b, and c. The input may not be successful in reading all three values. The function should return the number of values that were successfully read.
Using C programming Create a function called printMenu( ) with the following properties: Has no function...
Using C programming Create a function called printMenu( ) with the following properties: Has no function inputs or output. Prints the following menu to the screen: 1. Enter user name. 2. Enter scores. 3. Display average score. 4. Display summary. 5. Quit Create a function called printLine( ) with the following properties: Takes as input a char Takes as input an integer corresponding to the number of times to print the character Has no function output. For example, if we...
(c programming) Given the function declaration and documentation below, write the function definition. Do not use...
(c programming) Given the function declaration and documentation below, write the function definition. Do not use the standard library function fgetc. /// @brief Reads a character from specified file input stream. /// @param instream A FILE* variable for an input stream to read a character from. /// @return A character of type char from instream. /// @note This function assumes #include <stdio.h> and a working, valid FILE* variable to an input stream. char grabchar(FILE* instream);
C Programming I have this function to i want to return the cipher text, but its...
C Programming I have this function to i want to return the cipher text, but its not working, can anyone try to see what i'm doing wrong. I need it to return the cipher text. char* vigenereCipher(char *plainText, char *k) { int i; char cipher; int cipherValue; int len = strlen(k); char *cipherText = (char *)malloc(sizeof(plainText) * sizeof(char)); //Loop through the length of the plain text string for (i = 0; i < strlen(plainText); i++) { //if the character is...
How would I write the following program in C programming language? Function header: int sumsort(int *a,...
How would I write the following program in C programming language? Function header: int sumsort(int *a, int *b, int *c) This function should arrange the 3 values in the memory locations pointed to by a, b, and c in ascending order and also return the sum of the contents of the memory locations a, b, and c.
(c programming) Given the function declaration and documentation below, write the function definition. Do not use...
(c programming) Given the function declaration and documentation below, write the function definition. Do not use the the standard library function fputc. /// @brief Writes a character to a specified file output stream. /// @param outstream A FILE* variable for an output stream to write a character to. /// @param outchar The character to be written to an output stream. /// @return On success, returns the written character. /// @note This function assumes #include <stdio.h> and a working, valid FILE*...
FOR C PROGRAMMING LANGUAGE ; please provide detailed explanation with detailed diagram Draw the main memory...
FOR C PROGRAMMING LANGUAGE ; please provide detailed explanation with detailed diagram Draw the main memory diagram as captured at the end of the C program (i.e. return 0; statement). Your diagram must clearly shows where str, p1, p2, and p3 are pointing to, when the program terminates. int main(void) { char str[] = "cs111 NYU"; char* p1 = str; p1 ++; char** p2 = &p1; char* p3 = &str[4]; printf("1. str = %s\n", p1); if(p3 - p1 == 4)...
Write a function called char_counter that counts the number of a certain character in a text...
Write a function called char_counter that counts the number of a certain character in a text file. The function takes two input arguments, fname, a char vector of the filename and character, the char it counts in the file. The function returns charnum, the number of characters found. If the file is not found or character is not a valid char, the function return -1. As an example, consider the following run. The file "simple.txt" contains a single line: "This...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT