473,398 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

addition in c

29
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.
Oct 16 '07 #1
8 5268
Meetee
931 Expert Mod 512MB
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.
Hi,

You will have to try this problem step by step. What have you done so far? Take input from user and then add digits of b and h by division and modulo method. Then take two loops: one for b and another for h. I am not allowed to write full code as per posting guidelines.

Hope this logical flow helps.

Regards
Oct 16 '07 #2
locy
29
Hi,

You will have to try this problem step by step. What have you done so far? Take input from user and then add digits of b and h by division and modulo method. Then take two loops: one for b and another for h. I am not allowed to write full code as per posting guidelines.

Hope this logical flow helps.

Regards

#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;
}


can the programm look like this.
Oct 16 '07 #3
Meetee
931 Expert Mod 512MB
#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;
}


can the programm look like this.
You have put directly ++++++++%d,********%d. I think it would be again in loop of b values as + and * are 8 in numbers. So you need to take one more loop. Also if required take input from user.

Try running this code. And if problem, post it here.

Please use code tags while pasting your code.

Regards
Oct 16 '07 #4
locy
29
You have put directly ++++++++%d,********%d. I think it would be again in loop of b values as + and * are 8 in numbers. So you need to take one more loop. Also if required take input from user.

Try running this code. And if problem, post it here.

Please use code tags while pasting your code.

Regards

did u mean in this way.

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

counter++;
}
return 0;
}


sorry i m have problem in compiling the program.i hard save it and try to run it in my compiler but it shows me no input file useing (gcc -o -wall file name.c)
Oct 16 '07 #5
Meetee
931 Expert Mod 512MB
did u mean in this way.

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

counter++;
}
return 0;
}


sorry i m have problem in compiling the program.i hard save it and try to run it in my compiler but it shows me no input file useing (gcc -o -wall file name.c)
First of all Use CODE tags around your code:
[ CODE=C ]..code goes here..[ /CODE ] (without space between [ and CODE )

You can do something like this:
Expand|Select|Wrap|Line Numbers
  1. for( counter = 1; counter <= 14; counter++);
  2. {
  3. for( i = 1; i <= b; i++);
  4.  
  5.    printf("+\n");
  6. for( j = 1; j <= b; j++);
  7.   printf(" * ");
  8.  
  9. counter++;
  10. printf(" \n ");
  11. }
  12.  
Regards
Oct 16 '07 #6
locy
29
[quote=zodilla58]First of all Use CODE tags around your code:
[ CODE=C ]..code goes here..[ /CODE ] (without space between [ and CODE )

You can do something like this:
[code=C]
for( counter = 1; counter <= 14; counter++);
{
for( i = 1; i <= b; i++);

printf("+\n");
for( j = 1; j <= b; j++);
printf(" * ");

counter++;
printf(" \n ");
}



thanks,but
i and j is not declared.or schould i replace i and j with b
Oct 16 '07 #7
weaknessforcats
9,208 Expert Mod 8TB
locy: When you use a quote tag you have to use a /quote tag.
When you use a code tag, do not put spaces in it. And you have to use a /code tag at the end.
Oct 16 '07 #8
locy
29
the programm the not run,where can the problem be
/CODE]
Oct 17 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mark Dickinson | last post by:
Can anyone either reproduce or explain the following apparently inconsistent behaviours of __add__ and __mul__? The class Gaussian provides a sub-bare-bones implementation of Gaussian integers (a...
7
by: jeffbernstein | last post by:
Greetings. I'm reading "How to think like a computer scientist: Learning with Python" and there's a question regarding string operations. The question is, "Can you think of a property that...
3
by: Jay | last post by:
I have two strings that instead of adding them together to get the sum the are concatenating together. Does anyone know how I can get these two to add. while not rstemp4.eof vservdate =...
2
by: akickdoe22 | last post by:
i could really use help finishing this addition program. I'm stuck on the part that allows you to add any two large integers,up to 100 digits,(pos+pos, neg+neg, and pos+neg). could use hints ideas...
24
by: Alex Vinokur | last post by:
Consider the following statement: n+i, where i = 1 or 0. Is there more fast method for computing n+i than direct computing that sum? -- Alex Vinokur email: alex DOT vinokur AT gmail DOT...
34
by: Andy | last post by:
Hi, Are 1 through 4 defined behaviors in C? unsigned short i; unsigned long li; /* 32-bit wide */ 1. i = 65535 + 3; 2. i = 1 - 3; 3. li = (unsigned long)0xFFFFFFFF + 3; 4. li = 1...
3
by: snow.carriers | last post by:
Let me first state that I'm using Borland Turbo C++, it's relatively old so the new string methods won't work. Anyways, first I'm trying to collect a line of a string (with numbers, letters,...
5
by: Mike | last post by:
Hello All, Please, if anyone can point me to the problem, I'd sure appreciate it! I am very new to VB programming and not a programmer to begin with. This is part of a Visual Basic 2005 Express...
5
by: Paul | last post by:
Why is the addition here adding the number as a string but the subtraction works fine? function boxchange(box) { iv= dbform.ut.value if (box.checked == true) { iv = iv - box.value } else {...
3
by: srinivas33034 | last post by:
Hi there, my problem is i have to perform addition dyamically My req is i have 3 txt boxes.. and another text box to display total additon.. as i am entering the values in TextBox1 i want...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.