ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Select output for the following set of code?

   static void Main(string[] args)

        {

            int a =5;

            int b =5;

            int c;

            Console.WriteLine(c = a-- - ++b);

            Console.WriteLine(b);

            Console.ReadLine();

 

        }

 

a) -7,b) -5,c) -6,d),

user-image
تم إضافة السؤال من قبل Mohannad Bakbouk , Full Stack Web Developer , Almohtaseb
تاريخ النشر: 2016/10/19

The above code will return -1 on one line and 6 on the other line.

The expression c = a-- - ++b means we use the value of 'a' before decrementing thus '5' and subtract from b after incrementing by 1 thus '6'. So, c = 5 - 6 = -1

The next line we display the value of b

Muhammad Omar Farooq
من قبل Muhammad Omar Farooq , Software Developer , Werner Machinenbau GmbH

the answer will be printed  -1 in first line and 6 in second line

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟