עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

בעיית תחביר בC++

Featured Replies

פורסם

שלום לכולם,

אני מנסה לבנות פונקציה לדיסקרמיננטה שאני מריץ את הדיבגינג אני כל הזמן מקבל את השגיאה:

error C2440: '=' : cannot convert from 'float (__cdecl *)(int,int,int)' to 'float'

1> There is no context in which this conversion is possible

הקוד שכתבתי:

#include <iostream>

#include <math.h>

using namespace std;

float discriminant(int a, int b, int c);

void main()

{

int x,y,z;

float disc;

cout<<"please enter 3 values for x, y and z\n";

cin>>x>>y>>z;

disc=discriminant;

cout<<"your result is...\n"<<discriminant;

}

float discriminant (int a, int b, int c)

{

float x;

x = sqrt((float)b*b-4*a*c);

return x;

}

אני רוצה פונקציה שתקבל 3 מספרים שלמים ותחזיר תוצאה עשרונית. מישהו יכול להסביר איפה טעיתי בתחביר?

תודה מראש

פורסם

שלום וברוך הבא לפורום.

תערוך בבקשה את ההודעה (לחץ על כפתור עריכה משמאל למעלה ואז על מצב מתקדם) ושים את הקוד בתוך טג קוד (כפתור עם ציור #) כדי שיהיה יותר קריא.

הבעיה נובעת מהעובדה שלא הפעלת את הפונקציה discriminant איך שאמורים להפעיל פונקציה (עם סוגריים).

חוץ מזה, שתי הערות:

א. אל תשתמש ב-float, תשתמש במקומו ב-double. אין שום סיבה כיום להשתמש ב-float.

ב. צריך לכתוב int main ולא void main, ובסוף הפונקציה main צריך לבוא return 0.

אני מניח שאתה לומד מאיזשהו ספר לימוד ישן?

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.