Click here to Skip to main content
15,894,896 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: dither.c:16:9: error: too few arguments to function ‘fwrite’ ?can anyone help Pin
mybm127-Jul-14 20:59
mybm127-Jul-14 20:59 
GeneralRe: dither.c:16:9: error: too few arguments to function ‘fwrite’ ?can anyone help Pin
Jochen Arndt27-Jul-14 21:09
professionalJochen Arndt27-Jul-14 21:09 
GeneralRe: dither.c:16:9: error: too few arguments to function ‘fwrite’ ?can anyone help Pin
mybm128-Jul-14 1:14
mybm128-Jul-14 1:14 
AnswerRe: dither.c:16:9: error: too few arguments to function ‘fwrite’ ?can anyone help Pin
mybm127-Jul-14 20:57
mybm127-Jul-14 20:57 
QuestionProgram to find sum of digits of a number . Please help with logical error of program. Pin
Member 1097308626-Jul-14 6:03
Member 1097308626-Jul-14 6:03 
GeneralRe: Program to find sum of digits of a number . Please help with logical error of program. Pin
PIEBALDconsult26-Jul-14 6:35
mvePIEBALDconsult26-Jul-14 6:35 
QuestionRe: Program to find sum of digits of a number . Please help with logical error of program. Pin
David Crow26-Jul-14 11:57
David Crow26-Jul-14 11:57 
AnswerRe: Program to find sum of digits of a number . Please help with logical error of program. Pin
CPallini27-Jul-14 21:21
mveCPallini27-Jul-14 21:21 
The 'quick fix' of your bugs produce the following program:
C++
int main()
{
        long num,num1,i=0,j=0,multiplier=1,sum=0,a[100];
//      clrscr();
        cout<<"Enter the number:";
        cin>>num;
        num1=num;
        while(num1!=0)
        {
                num1=num1/10;
                i++;
        }
        num1 = num;
        for(j=i-1;j>=0;j--)
        {
                multiplier=pow(10,j);
                a[j]=num1/multiplier;
                num1=num1-(a[j]*multiplier);
        }
        for(j=0;j<i;j++)
                sum=sum+a[j];
        cout<<"The sum of the digits of the "<<i<<" digits number "<<num<<" is:"<<sum << endl;
        getchar();
}


However, I would rather write it this way:
C++
int main()
{
        long num, sum = 0;

        cout<<"Enter the number:";
        cin>>num;

        while (num)
        {
                int remainder = num % 10;
                sum += remainder;
                num /= 10;
        }

        cout <<"The sum of the digits of is:" << sum << endl;

        getchar();
}

THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite


modified 28-Jul-14 5:55am.

GeneralRe: Program to find sum of digits of a number . Please help with logical error of program. Pin
Stefan_Lang27-Jul-14 23:49
Stefan_Lang27-Jul-14 23:49 
GeneralRe: Program to find sum of digits of a number . Please help with logical error of program. Pin
CPallini27-Jul-14 23:56
mveCPallini27-Jul-14 23:56 
GeneralRe: Program to find sum of digits of a number . Please help with logical error of program. Pin
Satya Chamakuri8-Aug-14 22:52
Satya Chamakuri8-Aug-14 22:52 
QuestionCan some one please tell me how to insert items into a friggin CListCtrl Pin
Member 1095872124-Jul-14 7:57
Member 1095872124-Jul-14 7:57 
AnswerRe: Can some one please tell me how to insert items into a friggin CListCtrl Pin
tagopi24-Jul-14 19:21
tagopi24-Jul-14 19:21 
AnswerRe: Can some one please tell me how to insert items into a friggin CListCtrl Pin
Richard MacCutchan24-Jul-14 20:41
mveRichard MacCutchan24-Jul-14 20:41 
GeneralRe: Can some one please tell me how to insert items into a friggin CListCtrl Pin
Member 1095872128-Jul-14 23:55
Member 1095872128-Jul-14 23:55 
GeneralRe: Can some one please tell me how to insert items into a friggin CListCtrl Pin
Richard MacCutchan29-Jul-14 5:16
mveRichard MacCutchan29-Jul-14 5:16 
Questionhow to generate text file for a program output? Pin
mybm124-Jul-14 0:41
mybm124-Jul-14 0:41 
AnswerRe: how to generate text file for a program output? Pin
Richard MacCutchan24-Jul-14 1:07
mveRichard MacCutchan24-Jul-14 1:07 
GeneralRe: how to generate .txt file as output dynamic for this program? Pin
mybm124-Jul-14 1:47
mybm124-Jul-14 1:47 
GeneralRe: how to generate .txt file as output dynamic for this program? Pin
Richard MacCutchan24-Jul-14 2:05
mveRichard MacCutchan24-Jul-14 2:05 
GeneralRe: how to generate text file for a program output? Pin
mybm124-Jul-14 2:05
mybm124-Jul-14 2:05 
GeneralRe: how to generate text file for a program output? Pin
Richard MacCutchan24-Jul-14 2:11
mveRichard MacCutchan24-Jul-14 2:11 
GeneralRe: how to generate text file for a program output? Pin
mybm124-Jul-14 18:47
mybm124-Jul-14 18:47 
GeneralRe: how to generate text file for a program output? Pin
Richard MacCutchan24-Jul-14 20:35
mveRichard MacCutchan24-Jul-14 20:35 
AnswerRe: how to generate text file for a program output? Pin
CPallini24-Jul-14 2:46
mveCPallini24-Jul-14 2:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.