Write a C program as follows:
Submit your program source code file to this assignment.
Sample Output
Enter first integer number: 15 Enter second integer number: 10 Enter Choice: 0 for add, 1 for subtract and 2 for multiply 2 Multiplication is 150
PLEASE INCLUDE LOTS OF COMMENTS. These comments help me to learn the assignment so that I can replicate the results on a test in the future. Thank you!
ANSWER:
#include<stdio.h> void int2str(int n, char str[]){ if(n < 10){ str[0] = '0'+n; str[1] = '\0'; } else{ str[0] = '0' + (n/10); str[1] = '0' + (n%10); str[2] = '\0'; } } int add(int a, int b){ return a+b; } int subtrace(int a, int b){ return a-b; } int mul(int a, int b){ return a*b; } int main() { int a,b; int ch; printf("Enter first integer number: "); scanf("%d",&a); printf("Enter second integer number: "); scanf("%d",&b); printf("Enter Choice: 0 for add, 1 for subtract and 2 for multiply: "); scanf("%d",&ch); if(ch == 0) printf("The sum is %d\n",add(a,b)); else if(ch == 1) printf("The difference is %d\n",subtrace(a,b)); else if(ch == 2) printf("Multiplication is %d\n",mul(a,b)); else printf("Invalid operator\n"); return 0; }
Write a C program as follows: Single source code file Requests the user to input two...
Write a C program requesting the user to input two integer numbers and then requesting the user to either add, subtract, or multiply the two numbers (choose 0 to add, 1 to subtract, or 2 to multiply. Declares three separate functions for these choices to come after main(). Program needs to use a pointer to these three functions to perform the requested action. Must print to output.
Write a C program as follows: Single source code file Uses an infinite loop Requests the user to press a key Uses a nested switch statement Either prints the key pressed, or terminates using the break statement and prints Goodbye! if the user presses either the e or E key Please include lots of comments please, this is how I learn how to code. I need LOTS of comments!
Write a C program as follows: Single source code file Calls a function with an arbitrary name (i.e. you name it) that accepts two arrays of the same size The function should add each element in the arrays together and place the values in a third array Each array element, each array address, and the sum are printed to the screen in tabulated format with headersI also would like to request that LOTS of comments be included, as I need...
Linux & Unix Write a bash program to indent the code in a bash source file. Conditions: The source file will contain only printing characters, spaces, and newlines. It is not necessary to check for invalid input. The source file will not contain comments (words beginning with #). Requirements: Read from standard input, write to standard output. Code inside while statements should be indented 2 spaces. Be sure your program includes all of the following: ...
Write a multithreaded C program that outputs prime numbers. This program should work as follows: the user will run the program and will enter a number on the command line. The program will then create a separate thread that outputs all the prime numbers less than or equal to the number entered by the user. ADD "comments" to the source code please and a screenshot of the output with steps on how to compile
Write C++ Code in single source file (.cpp file) containing following user defined functions: 1. IsEven- takes an integer input (one argument of type int) and return true or false. 2. IsPositive- takes a float input (one argument of type double) and return a Boolean value. The function returns the true if its argument is positive and false if its argument is zero or negative. 3. IsPrime- takes an integer input and return true or false. 4. NumOfDigits- takes an...
Write and submit a MIPS Assembly Language program which requests an integer (year) from the user and then invokes a function to determine the beginning date and time of each season. The program must be properly documented which includes in file comments. Note: This is a Computer Science/Engineering course, not a Physics/Astronomy course. The exact time is not expected. Approximations are acceptable. Document your calculation process in the report. Basically, the intent is that you store a reference date and...
Design a calculator program that will add, subtract, multiply, or divide two numbers input by a user.Your program should contain the following:-The main menu of your program is to continue to prompt the user for an arithmetic choice until the user enters a sentinel value to quit the calculatorprogram.-When the user chooses an arithmetic operation (i.e. addition) the operation is to continue to be performed (i.e. prompting the user for each number, displayingthe result, prompting the user to add two...
In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter an integer value. Your program will then display that integer back to the user. Your program should include a function called getInteger that requests an integer value from the user and returns that value back to the caller. Your main () function will call the function getInteger and will then display the value returned by that function....
The assignment In this assignment you will take the Matrix addition and subtraction code and modify it to utilize the following 1. Looping user input with menus in an AskUserinput function a. User decides which operation to use (add, subtract) on MatrixA and MatrixB b. User decides what scalar to multiply MatrixC by c. User can complete more than one operation or cancel. Please select the matrix operation 1- Matrix Addition A+ B 2-Matrix Subtraction A-B 3Scalar Multiplication sC 4-Cancel...