i try to compile this programm useing pluto,it shows me error .where schould the fehler be?

#include <"stdio.h">
int main()
{
int counter;    
int even=0;
int b= 7,int h= 10;
if h+ = b % 10;
 b /= 10;
for( counter = 1; counter <= 10; counter++);
{
if (even == 1)
for( b = 1; b <= 7; b++);
 {
   printf("+\n");
   even=0;
 }  
if (even == 0)
for( b = 1; b <= 7; b++);
 {
  printf("*\n");
  even=1;
 }
  counter++;
  printf(" \n ");
}

Recommended Answers

All 15 Replies

Check line 7 if h+= b % 10; Next time post the error messages. That would help us to help you.

Oh I see you are back to your old code again ?

>>fehler
what is that? Please write in English on these boards.

Oh I see you are back to your old code again ?

here are the errors

>>fehler
line 1:"stdio.h"no such file or directory

line 6: expected identifer

line 7: expecting ( before h,

line 7: h undeclerd (first use in this function),

line 14,20,24:warning: incompatible implicit declaration of built-in function printf,

line 25:expected declaration of statement at end the input

..[/CODE ]

line 1: remove the double quotes.

line 7: I told you what the problem was in that other thread. Go back and read it again.

Correct the above and the other errors will probably disappear too.

line 1: remove the double quotes.
line 7: I told you what the problem was in that other thread. Go back and read it again.
Correct the above and the other errors will probably disappear too.

THESE IS THE COUNRENT STATE OF MY PROGRAMM

line 6: expected identifer

line 7: expecting ( before h,

line 7: h undeclerd (first use in this function),

line 7 (each undeclerd identifer is reported only once)

line 7 expected expresion before =

line 25:expected declaration of statement at end the input

Please repost your program. And did you make all the changes that we previously mentioned? If not, why not. I can't help you if you continually ignore what we post. If you don't understand the changes we have suggested then just ask for more clarification.

i have done it but i still get error.

#include <stdio.h>
int main()
{
int counter;	
int even=0;
int b=7,int h= 10;
 if (h+=b %10);
   b /= 10;
for( counter = 1; counter <= 10; counter++);
{
if (even == 1)
for( b = 1; b <= 7; b++);
 {
   printf("+\n");
   even=0;
 }  
if (even == 0)
for( b = 1; b <= 7; b++);
 {
  printf("*\n");
  even=1;
 }
  counter++;
  printf(" \n ");
}

i have done it but i still get error.

Yes I can see you did it all right -- you simply ignored all our suggestions. This will be my last post to you until you learn to read and implement our suggestions.

commented: More patience than me, but why do you keep replying ;) +11

Yes I can see you did it all right -- you simply ignored all our suggestions. This will be my last post to you until you learn to read and implement our suggestions.

the programm work but i still have one problem,
i am surpose to have

+++++++
* * * * * * *
into
10 times/places
but i only got this output
+
*

where could the problem come from.

>>the programm work but i still have one problem
Well then it is not the same as the code you posted above ^^^. Since I can't see your monitor I have no idea what is wrong with it now.

>>the programm work but i still have one problem
Well then it is not the same as the code you posted above ^^^. Since I can't see your monitor I have no idea what is wrong with it now.

#include <stdio.h>
int main()
{
 int counter;	
 int b=7;
 int h= 10;
 if (h+=b %10);
   b /= 10;
 for(counter = 1; counter <= 10; counter++);
  {
   if ((counter%2) == 1)
   for( b = 1; b <= 7; b++);
    {
     printf("+");
     counter=0;
    }  
   else
   for( b = 1; b <= 7; b++);
    {
     printf("*");
     counter=1;
    }
     counter++;
     printf(" \n ");
     return 0;
     
     //
  }   
}

i got
+
*
instead of
+++++++
* * * * * * *
into 10 places

line 7 has not been corrected yet -- and we have told you about that at least 3 times. And you have not put lines 7 and 8 in a loop either. Do you not know what a loop is ?

how dod i do that,anyway i have be able to do this.
that is
+++++++
+++++++
+++++++
+++++++
********
********
********
instead of
+++++++
*******
+++++++
*******

where did i make mistake

Pardon my C, but your for statement lines should not be followed by ; or you are basically looping nothing.

I really have to admire the patience of the experts on this C forum!

where did i make mistake

The success of your program hinges upon your ability of understandig first how to get the total addition of each digit of an integer.
I hope this will clarify for you how to do so.

/******************************************************************************
01234 is made out of
 1000 +
  200 +
   30 +
    4 = 1234
But we only want the left most digit value id est the 1, the 2, the 3 and the 4.
And we want these values added together. How can we obtain that value alone?
If we divide 01234 by 10 ( human base of counting ) we get: 123.4 or 123 with
a remainder of 4. That 4 is the same that the last digit that we want. So we
want to keep it stored in someplace.
Now we take the result, 123 and do the same 123 / 10 and we get: 12.3 or 12 with
a remainder of 3. We want that 3 alone don't we?. Let's add it up to the 4 stored
previously. Now we have 4 + 3 = 7 stored somewhere.
Let's take the result 12 and divided by 10 and we get: 1.2 Alright. We add that
2 to the previous 7, and that's 9 saved.
If we 1 / 10 one more time we have 0.1 That 1 is the last digit we need.
Added to 9 we now have the total 10, which is the addition of 1 + 2 + 3 + 4.
*****************************************************************************/

/*
 * digit.c
 * Obtain the addition of the digits of a number
 */
#include <stdio.h>

int main ( void )
{
    int number = 1234;
    int total = 0;
    
    /* obtain the single digit until we are done */
    while ( number != 0 )
    {
        printf( "In the loop number = %d\n", number );
        total = total + ( number % 10 );
        printf( "In the loop total = %d\n", total );
        number = number / 10;
    }
    printf( "After the loop number = %d\n", number );
    printf( "After the loop total = %d\n", total );
    
    getchar();
    return 0;    
}
/* Output:
    In the loop number = 1234
    In the loop total = 4
    In the loop number = 123
    In the loop total = 7
    In the loop number = 12
    In the loop total = 9
    In the loop number = 1
    In the loop total = 10
    After the loop number = 0
    After the loop total = 10 
*/

Apply the same process to each integer you want to obtain the addition of each digit.
After that you can continue developing the rest of your program.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.