please answer in C code and leave comments on what the code does in the code
Answer:
Program:
#include <stdio.h>
int main()
{
// Initializing x,y values to -35
int x = -35, y = -35;
// Initializing n value to 173.
// Note: Change this n value as per given values to get x,y values
int n = 173;
// switch condition takes the remainder when n is divided by 10
switch(n%10) {
// If remainder is 1
case 1: x = n;
break;
// If remainder is 3
case 3: x = n;
y = 10;
// If remainder is 5
case 5: x = n*2;
break;
// If remainder doesn't match to any above cases then it comes into this
default: x = 0;
y = 0;
break;
}
// Printing the x and y values
printf("x = %d\ny = %d", x, y);
return 0;
}
Output: For n = 173
please answer in C code and leave comments on what the code does in the code...
should be in C language
What is the output of the following segment of C code: void CapsLetter (char* x, charl); int main() { char* text; text="This is some sample text."; CapsLetter(text, 'e'); printf("%s", text); return 0; سی void Caps Letter (char* x, char 1) { int i=0; while (x[i]!='\0') { if (x[i]==1) x[i]=1-32; } 1. This is som sample text. 2. THIS IS SOME SAMPLE TEXT. 3. This is some sample text. 4. this is some sample text. What...
MIPS (MARS CODE) Please covert this C++ code to MIPS code and leave comments on each line to what it does! int fib( int n ) { if ( n <= 1 ) return n; else return fib(n - 1 ) + fib( n - 2 ); }
How to code up the postfixEval function using the instructions in the comments of the function? // postfixEvalTest.cpp #include "Token.h" #include <iostream> #include <vector> #include <stack> using namespace std; // postfix evaluate function prototype double postfixEval(vector<Token> &expr); int main() { vector<Token> postfix; postfix.push_back(Token(VALUE,4.0)); postfix.push_back(Token(VALUE,3.0)); postfix.push_back(Token(VALUE,2.0)); postfix.push_back(Token(OPERATOR,'*')); postfix.push_back(Token(OPERATOR,'+')); postfix.push_back(Token(VALUE,18.0)); postfix.push_back(Token(VALUE,6.0)); postfix.push_back(Token(OPERATOR,'/')); postfix.push_back(Token(OPERATOR,'-')); double result = 0.0; //result = postfixEval(postfix); cout << "The result of 4 3 2 * + 18 6 / - .... is " << result << endl; vector<Token>...
20) What is the output of the following segment of C code: int avg(int n, int* a); int main () { int array[4]={1,0,6,9}; printf("%d", avg(4, array)+ 1); system("pause"); return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...
NEED HELP BEING SOLVED IN C++! USE ORIGINAL CODE TO ADD TO AS
WELL!
#include<iostream>
using namespace std;
int main(){
for (int i = 0; i < 7; i++)
{
int x,y;
char opr;
cin>>x>>y>>opr;
switch(opr)
{
case '+':
cout<<x<<" + "<<y<<" = "<<x+y;
break;
case '-':
cout<<x<<" - "<<y<<" = "<<x-y;
break;
case '*':
cout<<x<<" * "<<y<<" = "<<x*y;
break;
case '/':
if(y == 0)
cout<<x<<" / "<<y<<" =
"<<"ERROR";
else cout<<x<<" / "<<y<<" =
"<<x/y<<"R"<<x%y;
break;...
java question, my questions are in the following codes with comments, just answer next or under it thanks! theres only few, so no worry. import java.security.SecureRandom; public class clsTestRand { public static void main(String[] args) { // TODO Auto-generated method stub //int num1, num2, num3, num4, num5, num6; int num1 = 0; int num2 = 0; int num3 = 0; int num4 = 0; int...
in c# 1- What is the output for total after the following segment of code executes? int num = 3, total = 0; switch (num) { case 1: case 2: total = 5; break; case 3: total = 10; break; case 4: total = total + 3; break; case 8: total = total + 6; break; default: total = total + 4; break; } WriteLine("The value of total is " + total); The value displayed for total would be ....
C LANGUAGE. PLEASE INCLUDE COMMENTS :)
>>>>TheCafe V2.c<<<<
#include <stdio.h>
int main()
{
int fries; // A flag denoting whether they want fries or not.
char bacon; // A character for storing their bacon preference.
double cost = 0.0; // The total cost of their meal, initialized to start at 0.0
int choice; // A variable new to version 2, choice is an int that will store the
// user's menu choice. It will also serve as our loop control...
Convert the below C code to basic MIPS. Please leave comments for explanation #include <stdio.h> int main(void) { printf("Insert two numbers\n"); int a,b; scanf("%d",&a); scanf("%d",&b); a=a<<2; b=b<<2; printf("%d&%d\n",a,b); return 0; }
Convert the below C code to basic MIPS. Leave comments for explanation please #include <stdio.h> int main(void) { printf("Insert two numbers\n"); int a,b,c; scanf("%d",&a); scanf("%d",&b); c=a|b; printf("%d|%d=%d\n",a,b,c); return 0; }