Dev C ++中的for循环(C语言)错误

时间:2018-07-25 16:01:13

标签: c dev-c++

Dev C ++ 中运行此代码时遇到问题。

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

main()
{
    /*
    Write a program to calculate overtime pay of 10 employees.
    Overtime is paid at the rate of Rs. 12.00 per hour for every hour worked above 40 hours. 
    Assume that employees do not work for fractional part of an hour.
    */

    int sal,pay,re;

    for(int i=0;i<=10;i++)
    {
        printf("Write down your over time(in hours):    ");
        scanf("%d",&sal);
        re = sal - 40;
        pay = re * 12;
        printf("Your pay is %d ",pay);
    }

}

我收到以下错误

  

[错误]'for'循环初始声明仅在C99或C11模式下允许

1 个答案:

答案 0 :(得分:3)

runtest(moduleIds, options, function (ko, komapping, _, pageOptions, mockjax, viewModel) { mockjax.clear(); pageOptions.setupOption('url', mockUrl); var data = { data: 'A text response from the server' } mockjax({ url: mockUrl, type: 'POST', contentType: 'application/json', responseText: data, responseTime: 0 }); komapping.fromJS(mockedAjaxResult, {}, viewModel.lines); viewModel.Download().done(function () { QUnit.test('Given download then should make request to download url', function (assert) { equal($.mockjax.mockedAjaxCalls().length, 1); equal($.mockjax.mockedAjaxCalls()[0].url, pageOptions.url); equal($.mockjax.mockedAjaxCalls()[0].data, expected); }); }); }); 循环的第一部分中声明变量是作为C99标准的一部分添加到C的功能。但是,默认情况下,大多数编译器都使用不支持此构造的旧C89标准。

您需要将for的声明移到i循环之外:

for