الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كود بسيط و لكن هناك error

مغلق
بدأه maas في 19 مارس 2006 · 2 رد · 383 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

يا شباب عندي مشكلة في هذا الكود

using System;

namespace Question5_4c_
{

	class Class1
	{
  
  static void Main()
  {
  	int result;
  	result= Math.Pow(2,4)/3+5*2-2+10*Math.Pow(7,2);
  	Console.Write(result);
  	Console.Read();
  }
	}
}

و القسمة في هذي الكود

Math.Pow(2,4) / 3+5

هي باقي القسمة أي اللقسمة اللي ترجع العدد و هو integer

تم تعديل هذه المشاركة بواسطة maas في 19 مارس 2006 في 19:14

#2

وعليكم السلام و رحمه الله و بركاته ,

the error was ....

cannot implicitly change from double to int because the built-in function Pow return value of type double and you put the result in int type.

the explanation .....

ya3ne ma2dersh ye7ot double value in int value 3ashan el double da byt7'zen fe makan akbar men el int laken law hatena rakam int fe rakam double mesh haytala3 error.

the solution .....

fa momken change the type of the result to be double or ne3mel type casting like in the following code.

using System;

namespace h
{
	class Class1
	{
  static void Main(string[] args)
  {
  	int result;
  	result= (int)(Math.Pow(2,4)/3+5*2-2+10*Math.Pow(7,2));
                                                // or double result = Math.Pow(2,4)/3+5*2-2+10*Math.Pow(7,2);
  	Console.Write(result);
  	Console.Read();
  }
	}

}

و الله اعلي و اعلم

تم تعديل هذه المشاركة بواسطة bejo في 19 مارس 2006 في 19:51

#3

مشكور أخوي

هذا الموضوع مغلق.

مواضيع مشابهة