小编use*_*039的帖子

在c ++中显示为"表达式必须具有整数或枚举类型"的错误消息

我有以下代码,我在这个等式中得到错误:

v=p*(1+r)^n.
Run Code Online (Sandbox Code Playgroud)

请帮我找出这个错误的原因.

# include <iostream>
# include <limits>

using namespace std;

int main()
{
    float v,p,r;
    int n;

    cout<<"Enter value of p:";
    cin>>p;
    cout<<"Enter value of r:";
    cin>>r;
    cout<<"Enter value of n:";
    cin>>n;

    v=(p)*(1+r)^n; // here i am getting error message as "expression must have integral or enum type"

    cout<<"V="<<v;

    std::cin.ignore();
    std::cin.get(); 
}
Run Code Online (Sandbox Code Playgroud)

c++

4
推荐指数
2
解决办法
2万
查看次数

在Visual Studio2010中,显示"警告C4028:与声明不同的形式参数1"

嗨,我有以下代码

我收到警告"警告C4028:正式参数1与声明不同"

我不知道我哪里出错了.我认为我的参数声明是正确的,但请帮助我.

# include <stdio.h>
# include <conio.h>
# include <math.h>

main()
{
    int x,y(),z,sqrt(int),cube(int);
    printf("Enter any number:");
    scanf("%d",&x);
    z=(x>y() ? sqrt(x):cube(x));
    printf("%d",z);
    getche();
    return 0;
}
int sqrt(int a)
{
    printf("Square:");
    return(a*a);
}
int cube(int b)
{
    printf("Cube:");
    return(b*b*b);
}
int y()
{
    return(10);
}
Run Code Online (Sandbox Code Playgroud)

c visual-studio-2010

1
推荐指数
1
解决办法
1571
查看次数

标签 统计

c ×1

c++ ×1

visual-studio-2010 ×1