+ 3

Hi friends I have a small doubt "Can we use two variables in one equation?" Please explain

This is code Console.WriteLine("enter a number") int a; int b; a = Convert.ToInt32(console.ReadLine()); b=a/2; If (b>o) Console.WriteLine("hi"); But visual studio show b is wrong

14th Jun 2020, 1:35 PM
Mohamed Waseem
Mohamed Waseem - avatar
11 Réponses
+ 2
Mohamed Waseem Ok, this can be solved e.g. as follows. int a=Convert.ToInt32(Console.ReadLine()); a = a/2; if(a>0) Console.WriteLine("hi"); else Console.WriteLine("by");
14th Jun 2020, 4:40 PM
JaScript
JaScript - avatar
+ 1
First of all the first two statements aren‘t allowed. Right will be e.g.: int a; int b = 8; The left hand must be a vaisble or property - that means you could code: a = b; You can see more examples in my codes.
14th Jun 2020, 2:01 PM
JaScript
JaScript - avatar
+ 1
It will be needed to read the errors as follows. That means you have forgoten character ; after the statements in row 14 and 19. ./Playground/file0.cs(14,36): error CS1002: ; expected ./Playground/file0.cs(19,9): error CS1002: ; expected Here after the first row and after if(b>0);
14th Jun 2020, 2:43 PM
JaScript
JaScript - avatar
+ 1
Rithea Sreng aah ok I typed wrong letter in laptop but here it's right I was so much confused that time Thanks a lot
14th Jun 2020, 4:07 PM
Mohamed Waseem
Mohamed Waseem - avatar
+ 1
Yeah we can use For example Average =sum/N
16th Jun 2020, 3:05 AM
Baskaran Aathithyan
Baskaran Aathithyan - avatar
0
Hi i was changed the code look again
14th Jun 2020, 2:22 PM
Mohamed Waseem
Mohamed Waseem - avatar
0
Rithea Sreng Ja Play Sorry I'm not understand My idea is First ask any number from user Second if user entered number can be divided by 2 say hi
14th Jun 2020, 3:29 PM
Mohamed Waseem
Mohamed Waseem - avatar
0
Why not.
16th Jun 2020, 1:44 AM
Bishal Shrestha