C
C#•10mo ago
Need_More_Sleep

Need Help With These 2 HW Questions.

// Question 2: Design a C# program that prompts the result (ans) of the following expression. double v1 = 45.7; double v2 = 10.5; int v3 = 5; // v1 += v1++; // --v2; double ans1; ans1 = (int)v1 + v2 / (double)v3; Console.WriteLine(ans1); // Question 3.1: Design a C# program that prompts the result (ans) of the following expression. double v1 = 45.7; double v2 = 10.5; int v3 = 5; // v1 += v1++; int ans2; ans2 = (int)v1 + --v2 / (double)v3++; Console.WriteLine(ans2);
No description
No description
15 Replies
lycian
lycian•10mo ago
$code
MODiX
MODiX•10mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
lycian
lycian•10mo ago
to make it easier to read What are you having trouble with?
Need_More_Sleep
Need_More_SleepOP•10mo ago
First, I'm confused about my HW premise, like not sure if they want to find the result using C# and in general how to create a code for this? Don't know what to do with v1 += v1++; --v2;
lycian
lycian•10mo ago
I won't interpret your hw assignment for you, and I agree with the question phrasing being vague on what they want. That's between you and your teacher. If you need help getting started with C# here's a basic instruction on how to create and run code https://learn.microsoft.com/en-us/training/modules/install-configure-visual-studio-code/7-exercise-create-build-run-app
Exercise - Create, build, and run your application - Training
Exercise - Create, build, and run your application
lycian
lycian•10mo ago
there's also later steps on how to create variables etc, which could help you if you have trouble with any of those steps I'm happy to help you create an application or write code 🙂
Need_More_Sleep
Need_More_SleepOP•10mo ago
Do you have any advise for me on how to do the 2 Questions, I think they want me to find the result using C#?
lycian
lycian•10mo ago
Yup. The content given is not valid C#, so I think they want you to create an application that displays the answer to the console. That is my interpretation of the assignment I would verify with your teacher if that's correct
Need_More_Sleep
Need_More_SleepOP•10mo ago
It's due tonight soon and I haven't gotten a reply back from my Profressor.
lycian
lycian•10mo ago
then I'd say run with that. Make a C# application that outputs the answer
Mango
Mango•10mo ago
This has to be one of the weirdest formats of a hw question I have seen
Need_More_Sleep
Need_More_SleepOP•10mo ago
double v1 = 45.7; double v2 = 10.5; int v3 = 5; // v1 += v1++; // --v2; double ans1; ans1 = (int)v1 + v2 / (double)v3; Console.WriteLine(ans1); // Question 3.1: Design a C# program that prompts the result (ans) of the following expression. double v1 = 45.7; double v2 = 10.5; int v3 = 5; // v1 += v1++; int ans2; ans2 = (int)v1 + --v2 / (double)v3++; Console.WriteLine(ans2); is this correct? I'm not sure what to do with ans2 = (int)v1 + --v2 / (double)v3++;
lycian
lycian•10mo ago
if you want to see for yourself not sure what you mean. It just looks like you have the type of ans2 wrong. It would be a double instead of int if you want an int it would be
int ans2;
ans2 = (int)(v1 + --v2 / (double)v3++);
Console.WriteLine(ans2);
int ans2;
ans2 = (int)(v1 + --v2 / (double)v3++);
Console.WriteLine(ans2);
Need_More_Sleep
Need_More_SleepOP•10mo ago
Thanks.
Want results from more Discord servers?
Add your server