×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

C programming. do you know where I make mistake?

本文发表在 rolia.net 枫下论坛#include <stdio.h>
int EvenCounter(int number)
{
static int counter =0;
if (number % 2 == 0)
counter++;
return counter;
}

int Multiply(int number)
{
static int multipl = 1;
multipl *= number;
return multipl;
}
#define MAX_INPUT 20
int main()
{
register int even = 0;
int input =0;
register long multiply = 0;
int i;
for (i=0; i < MAX_INPUT; i++)
{
printf("Please input the <%d> integer number:",i+1);
scanf("%d", &input);
even = EvenCounter(input);
multiply = Multiply(input);
}
printf("Statistics:\n\n");
printf("Even numbers:%d\n", even);
printf("Odd numbers:%d\n", MAX_INPUT - even);
printf("The percentage of even numbers: %d%\n", even*(100/MAX_INPUT));
printf("The percentage of odd numbers: %d%\n", 100- even*(100/MAX_INPUT));
printf("Multiplication:%d\n", multiply);
return 0;
}


lab1.exe': Loaded 'C:\Wendy\SENECA\PRG 255 Course\PRG255D\lab1\Debug\lab1.exe', Symbols loaded.
'lab1.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Cannot find or open the PDB file
'lab1.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Cannot find or open the PDB file
'lab1.exe': Loaded 'C:\WINDOWS\system32\msvcr100d.dll', Symbols loaded.
The program '[3136] lab1.exe: Native' has exited with code 0 (0x0).更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / 学科技术讨论 / C programming. do you know where I make mistake?
    本文发表在 rolia.net 枫下论坛#include <stdio.h>
    int EvenCounter(int number)
    {
    static int counter =0;
    if (number % 2 == 0)
    counter++;
    return counter;
    }

    int Multiply(int number)
    {
    static int multipl = 1;
    multipl *= number;
    return multipl;
    }
    #define MAX_INPUT 20
    int main()
    {
    register int even = 0;
    int input =0;
    register long multiply = 0;
    int i;
    for (i=0; i < MAX_INPUT; i++)
    {
    printf("Please input the <%d> integer number:",i+1);
    scanf("%d", &input);
    even = EvenCounter(input);
    multiply = Multiply(input);
    }
    printf("Statistics:\n\n");
    printf("Even numbers:%d\n", even);
    printf("Odd numbers:%d\n", MAX_INPUT - even);
    printf("The percentage of even numbers: %d%\n", even*(100/MAX_INPUT));
    printf("The percentage of odd numbers: %d%\n", 100- even*(100/MAX_INPUT));
    printf("Multiplication:%d\n", multiply);
    return 0;
    }


    lab1.exe': Loaded 'C:\Wendy\SENECA\PRG 255 Course\PRG255D\lab1\Debug\lab1.exe', Symbols loaded.
    'lab1.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Cannot find or open the PDB file
    'lab1.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Cannot find or open the PDB file
    'lab1.exe': Loaded 'C:\WINDOWS\system32\msvcr100d.dll', Symbols loaded.
    The program '[3136] lab1.exe: Native' has exited with code 0 (0x0).更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • if (number % 2 == 0)
      • how is it wrong?
    • 连接的windows库没有找到?
      • if press ctrl-F5 to run, it is OK
    • 一个小问题, even*100/MAX_INPUT,比even*(100/MAX_INPUT)好一些.另外,你用的坏境,编译器什么的说一下比较好.
      • MS Visual studio 2010 Express
        Thank you for your reply!
        If code need change, pls. let me know here as well.
    • 学习到深夜,佩服佩服。PDB是存debug信息的,所以你用ctrl-f5就不会有这些warning。你可能从全新的project开始做,如果从现成的template开始,应该就不会有这样的问题。
      网上有人说这样可以解决:
      Debug>Options and Settings> Symbols
      and selected the Microsoft Servers.

      Enable "cache symbols {in this directory}" and set a location. Then you only have to wait for the servers once. More importantly, your project now knows where a local copy of the pdb files is.

      你可以试试。
    • I dont know PDB, but think your "int Multiply(int number)" doesnt take effect. It only returns "number", not the resut of multiplication