CAN ANYONE HELP ME PLEASE! THUMBS UP WILL BE GIVEN!! THANKS
/* I think you want to change the provided code so that it prints only one math operation per switch statement, if this isn't the case do let me know in the comment section. */
#include <stdio.h>
int main() {
char ch = '+';
int a = 10, b = 20;
double f;
switch (ch) {
case '+': f = a + b;
printf("f = %f ", (float)f); break;
case '-': f = a - b; printf("f = %f
", (float)f); break;
case '*': f = a * b; printf("f = %f
", (float)f); break;
case '/': f = a / b; printf("f = %f
", (float)f); break;
default: printf("invalid operator
");
}
ch = '-';
printf("ch = %c ", ch);
switch (ch) {
case '+': f = a + b; printf("f = %f
", (float)f); break;
case '-': f = a - b; printf("f = %f
", (float)f); break;
case '*': f = a * b; printf("f = %f
", (float)f); break;
case '/': f = a / b; printf("f = %f
", (float)f); break;
default: printf("invalid operator
");
}
ch = '*';
printf("ch = %c ", ch);
switch (ch) {
case '+': f = a + b; printf("f = %f
", (float)f); break;
case '-': f = a - b; printf("f = %f
", (float)f); break;
case '*': f = a * b; printf("f = %f
", (float)f); break;
case '/': f = a / b; printf("f = %f
", (float)f); break;
default: printf("invalid operator
");
}
ch = '/';
printf("ch = %c ", ch);
switch (ch) {
case '+': f = a + b; printf("f = %f
", (float)f); break;
case '-': f = a - b; printf("f = %f
", (float)f); break;
case '*': f = a * b; printf("f = %f
", (float)f); break;
case '/': f = a / b; printf("f = %f
", (float)f); break;
default: printf("invalid operator
");
}
ch = '%';
printf("ch = %c ", ch);
switch (ch) {
case '+': f = a + b; printf("f = %f
", (float)f); break;
case '-': f = a - b; printf("f = %f
", (float)f); break;
case '*': f = a * b; printf("f = %f
", (float)f); break;
case '/': f = a / b; printf("f = %f
", (float)f); break;
default: printf("invalid operator
");
}
return 0;
}
OUTPUT
CAN ANYONE HELP ME PLEASE! THUMBS UP WILL BE GIVEN!! THANKS 2.1 Use a text editor...
#include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { /* Type your code here. */ int GetNumOfNonWSCharacters(const char usrStr[]) { int length; int i; int count = 0; char c; length=strlen(usrStr); for (i = 0; i < length; i++) { c=usrStr[i]; if ( c!=' ' ) { count++; } } return count; } int GetNumOfWords(const char usrStr[]) { int counted = 0; // result // state: const char* it = usrStr; int inword = 0; do switch(*it)...
I need help solving this assignment, you are given a full piece of code that does not run correctly. Some of the bugs can be found at compile time, while others are found at run time. Access the UserMenu.cpp code file (in the zip file in Start Here) and use debugging practices and the debugger in Visual Studio to find each bug. Fix the bug and write a comment in the code giving a description of how you found the...
6-1 Test and debug the Invoice Application i need help with this please.. all help is appreciated Source code Java: import java.util.Scanner; import java.text.NumberFormat; public class InvoiceApp { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String choice = "y"; while (!choice.equalsIgnoreCase("n")) { // get the input from the user System.out.print("Enter customer type (r/c): "); String customerType = sc.next(); System.out.print("Enter subtotal: "); double subtotal = sc.nextDouble(); // get the discount percent double discountPercent = 0.0; switch(customerType) {...
please help me write function definition of this code ..thanks /* Test change_case function. */ #include "nodep.h" //suppress deprecation warnings #include <stdio.h> //printf(), scanf() #include <conio.h> //getch() #define _CRT_SECURE_NO_DEPRECATE 1 #define _CRT_NONSTDC_NO_DEPRECATE 1 #define ESC 27 #define LETTER_a 97 #define LETTER_z 122 #define LETTER_A 65 #define LETTER_Z 90 //function prototype: char change_case(char cIn); int main(void) { char cInput, cOutput; printf("Test change_case function...\n\n"); printf("(Press ESC to exit, any other key to keep testing)\n"); do { printf("\n\nEnter letter: "); cInput = _getche(); ...
int main() { int a, Band3 = 0, Band1, Band2, b, c = 1; float t; while (c) { Band3 = 0; printf(" Enter Resistance Value: "); scanf_s("%d", &a); printf("\n Enter Tolerance Value: "); scanf_s("%f", &t); b = t * 100; while (a % 10 == 0) { Band3++; a = a / 10; } Band2 = a % 10; a = a / 10; Band1 = a % 10; printf("\n Band1 = %d, Band2 = %d, Band3 = %d...
Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...
Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...
please help me fix this. I'm getting it all mixed up in user defined functions. here's the question. This week we'll write a C program that lets the user play the game of Rock, Paper, Scissors against the computer. Your program will call a user-defined function named display_rules that displays the rules of the game. It then proceeds to play the game. To determine the winner, your program will call another user- defined function called determine_winner that takes two integer...
Could use some help with this, Instructions: You will need to add an input statement for the grade variable to this code. Also add a for loop so that you can enter more than one grade. Code the for loop so that at least 7 grades can be entered. #include <iostream> #include <string> using namespace std; void main() { char grade; for (int x = 0; x < 7; x++) { cout << "Enter a...
The first project involves modifying the attached lexical analyzer and the compilation listing generator code. You need to make the following modifications to the lexical analyzer, scanner.l: 1. A second type of comment should be added that begins with // and ends with the end of line. As with the existing comment, no token should be returned. 2. The definition for the identifiers should be modified so that underscores can be included, however, consecutive underscores, leading and trailing underscores should...