how do i write a C programm to add two figures together e.g b and h
if b = 0125 and h =2354

b = 0+1+2+5 = 8

h = 2+3+5+4 = 14

and the output to be

++++++++
* * * * * * * *
++++++++
* * * * * * * *
to 14 times.

First, you have to extract the individual digits from the original value of b so that they can be added together. Do that in a loop using the mod operator % to extract the right-most digit then divide by 10 to shift all digits right

int x = 0;
int b = 01234;

x += b % 10; // get right-most digit and save in x
b /= 10; // truncate right-most digit

once you get that working for both b and h come back and we'll work on the rest of the problem (unless of course you can do it yourself)

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

is it right like this.

>>is it right like this
No.

line 4: coded wrong -- initializers must immediately followint the variable declaration

int b = 4, h = 14;

line 5: remove the if and the space between + and = symbols. Then you need a different variable for the accumulator.

now put lines 5 and 6 inside its own loop so it will make that calculation for each digit in the number.

#include <"stdio.h">
int main()
{
int counter;
int b = 8, h = 14;
h+= b % 14;
b /= 14;
for( counter= 1; counter <= 14; counter++);
if (h <=8 && b <=14)
{
printf("++++++++%d,********%d\n"; counter)
counter++;
}
return 0;
}


how about this form.

>how about this form.
You're not even reading AD's posts, are you?

Nor appreciating that every time you see something like
" Last edited by Ancient Dragon : 39 Minutes Ago at 13:22. Reason: add code tags"
it represents time sucked away from helping people and instead wasted on doing what the poster should manage for themselves.
Read THIS

> for( counter= 1; counter <= 14; counter++)[B];[/B] Guess what the last ; on this line does.

where can i find it

that is an increament,did u have any answer to that

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.