473,659 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help from u friends...

Hi ...i am new to programing....p ls help to overcome this program..

The Program is..:

if a = 557..using for loop or while or dowhile ..we have to get the
answer for 5+5+7..that is what ever numbers we entered to a..that
should be added..
for eg if a = 34 the answe should be 7 that is 3+4
using % and / we can solve this problem..pls help me to get the
problems

Feb 15 '07 #1
8 1910
SanjaiGandhi said:
Hi ...i am new to programing....p ls help to overcome this program..

The Program is..:

if a = 557..using for loop or while or dowhile ..we have to get the
answer for 5+5+7..that is what ever numbers we entered to a..that
should be added..
for eg if a = 34 the answe should be 7 that is 3+4
using % and / we can solve this problem..pls help me to get the
problems
What have you tried so far? Show us your best-effort code, and we'll
help you fix it.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Feb 15 '07 #2
On Feb 15, 12:10 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
SanjaiGandhi said:
Hi ...i am new to programing....p ls help to overcome this program..
The Program is..:
if a = 557..using for loop or while or dowhile ..we have to get the
answer for 5+5+7..that is what ever numbers we entered to a..that
should be added..
for eg if a = 34 the answe should be 7 that is 3+4
using % and / we can solve this problem..pls help me to get the
problems

What have you tried so far? Show us your best-effort code, and we'll
help you fix it.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999http://www.cpax.org.uk
email: rjh at the above domain, - www.
sir as i said above i am very very new to this programing worrld...i
am going for the c class for the last one week...so i am very very
ignorant ...pls guide me to solve this program...

Feb 15 '07 #3
SanjaiGandhi said:
On Feb 15, 12:10 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
>>
What have you tried so far? Show us your best-effort code, and we'll
help you fix it.
sir as i said above i am very very new to this programing worrld...i
am going for the c class for the last one week...so i am very very
ignorant ...
The best way to stop being ignorant is to start learning. Learn, first,
that nobody else will do this for you. You must make the effort
yourself. Try. If you are not prepared to try to solve this yourself,
why should anyone else be prepared to do it for you?
pls guide me to solve this program...
Step 1: capture some input in string form
Step 2: convert it to an unsigned long int (not because it's necessary
but because your teacher wants you to - this would actually be easier
to do if you didn't convert it to a number)
Step 3: do the necessary processing
Step 4: print the result
Step 5: quit

Write it in C. When it breaks, show us your C and ask us to help, and we
will. But you need to be the one who writes the program, not us.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Feb 15 '07 #4
On Feb 15, 12:34 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
SanjaiGandhi said:
On Feb 15, 12:10 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
What have you tried so far? Show us your best-effort code, and we'll
help you fix it.
sir as i said above i am very very new to this programing worrld...i
am going for the c class for the last one week...so i am very very
ignorant ...

The best way to stop being ignorant is to start learning. Learn, first,
that nobody else will do this for you. You must make the effort
yourself. Try. If you are not prepared to try to solve this yourself,
why should anyone else be prepared to do it for you?
pls guide me to solve this program...

Step 1: capture some input in string form
Step 2: convert it to an unsigned long int (not because it's necessary
but because your teacher wants you to - this would actually be easier
to do if you didn't convert it to a number)
Step 3: do the necessary processing
Step 4: print the result
Step 5: quit

Write it in C. When it breaks, show us your C and ask us to help, and we
will. But you need to be the one who writes the program, not us.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999http://www.cpax.org.uk
email: rjh at the above domain, - www.
The best way to stop being ignorant is to start learning. Learn,
first,
that nobody else will do this for you. You must make the effort
yourself. Try. If you are not prepared to try to solve this yourself,
why should anyone else be prepared to do it for you?
>>>Sir..i said i am a learner..i asked for the guidelines for solving this problem that is i asked only to guide not asked anyone else to prepared it for me...i know that i should take effort..sir there is lot of difference between guiding and to solve the problem for others...so i didnt asked for the solution of the problem..i asked only for the guiding...anywa y thanks for ur wonderfull answers to the beginners....th anks a lot...
Step 1: capture some input in string form
Step 2: convert it to an unsigned long int (not because it's necessary
but because your teacher wants you to - this would actually be easier
to do if you didn't convert it to a number)
Step 3: do the necessary processing
Step 4: print the result
Step 5: quit

Write it in C. When it breaks, show us your C and ask us to help, and we
will. But you need to be the one who writes the program, not us.
>>>>Thanks for ur guidance sir..
But you need to be the one who writes the program, not us.
>
>>>>>>>>>agai n i am saying that i didnt asked for solution of this problem...i asked only to help to solve this problem and guidance from u people..any way thanks ....

Feb 15 '07 #5
SanjaiGandhi wrote:

<snip mess of a post>

How did you manage to mess up your post's format like that?

Your C textbook should have hints on how to tackle this problem. As
you've yourself requested, no one has given you ready to use code.
You've been advised to come up with a first attempt, however bad it
is. Then we can start to help you. In programming, there's nothing
like analysing a problem yourself. It's even better than looking at
other people's solutions, though that has it's value too.

PS. In most cases, you shouldn't quote sigs.

Feb 15 '07 #6

"SanjaiGand hi" <sa***********@ gmail.comwrote in message
news:11******** **************@ p10g2000cwp.goo glegroups.com.. .
Hi ...i am new to programing....p ls help to overcome this program..

The Program is..:

if a = 557..using for loop or while or dowhile ..we have to get the
answer for 5+5+7..that is what ever numbers we entered to a..that
should be added..
for eg if a = 34 the answe should be 7 that is 3+4
using % and / we can solve this problem..pls help me to get the
problems
You've been given a good hint about what to do:
Use % and / operators. If I were you, I'd write a
simple program to experiment with them and see what
they do.

E.g.

#include <stdio.h>

int main(void)
{
unsigned int i = 12345;
printf("%u\n", i % 10);
printf("%u\n", i / 10);
/* etc */
return 0;
}

Hopefully you already know how to make a C program
add numbers together.

-Mike
Feb 18 '07 #7
SanjaiGandhi wrote:
Hi ...i am new to programing....p ls help to overcome this program..

The Program is..:

if a = 557..using for loop or while or dowhile ..we have to get the
answer for 5+5+7..that is what ever numbers we entered to a..that
should be added..
for eg if a = 34 the answe should be 7 that is 3+4
using % and / we can solve this problem..pls help me to get the
problems
OK Sanjai, study this solution if you want a challenge.

C:\>type sanjai.c

#include <stdio.h>
int main(int i, char **p)
{
for(*p = p[1]; **p; ++*p) i += **p - '0';
printf("%d\n", i - 2);
return 0;
}

C:\>gcc -ansi -pedantic -Wall -W -O2 sanjai.c

C:\>a 557
17

C:\>a 34
7

Note that it has 'undefined behaviour' and will probably crash if you
leave out the argument when you run the program. If you enter some
non-digit characters it will affect the value printed. If you enter too
many characters you may overflow the int variable. Can you fix all these
problems and make a robust solution?

Question for regulars: Is the modification of argv[0] allowed in
standard C? If not, this code needs some simple changes.

--
Simon.
Feb 19 '07 #8
Simon Biber said:

<snip>
Question for regulars: Is the modification of argv[0] allowed in
standard C? If not, this code needs some simple changes.
You can modify the string that argv[0] points to. You may not lengthen
it, however, and nor may you point argv[0] to some other location.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Feb 19 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
9561
by: Sean Don | last post by:
Hello! Is it possible to make classes friends in Python? Or is it better to just stick to "Java style" .isThis, .getThat, .setThis style functions? I understand that classes are generally grouped logically into separate files anyway. So, this isn't always necessary. But I'm a perfectionist and was wondering if friendships were possible in Python. Thank you!
0
521
by: Gary Stollman | last post by:
My Father is a Clone//ETs plotting to overthrow the human race! On August 19, 1987 a gun-carrying Gary Stollman entered the studio of Los Angeles's KNBC television, crashing consumer reporter David Horowitz's live newscast. Stollman handed Horowitz a written statement and ordered him to read it while holding a gun on him. Unbeknownst to Stollman, KNBC immediately switched to a commercial, not permitting the statement to be transmitted. ...
3
1745
by: fabio de francesco | last post by:
Hello, I have written this code that compiles without errors ( "..." stays for code that I don't post for the sake of brevity): // Person.h .... class Person { public:
102
7352
by: me | last post by:
How do I prevent the save/print/email/mypictures toolbar from popping up when IE users place their cursor over photos at my website? Thank you in advance for your help. Signed, me
11
2589
by: Micha | last post by:
Hello there, I think I've run into some classic c++ pitfall and maybe some of you guys can help me out. For my project I will need to use matrices and vectors and so I decided to implement them by myself. I know there are already tons of vector and matrix implementations, but I wanted to have one taylored for my needs and without debugging someones else code. Also is's become somewhat personal meanwhile ;-).
3
1886
by: Jeff | last post by:
Hey ASP.NET 2.0 I'm trying to extend the MembershipUser class, and have encounter a problem: << See in the middle of this post for info about why I do this >> << See below of this post for the source code of Contact class >> public class Contact : MembershipUser
5
2628
by: smileskhan | last post by:
Hay Friends... Here I started a new and interested thread. I hope you also enjoy it. I got a task to creat a Hospital Database in Java. But I donīt have any good clues abouts it. So I also try my best to do it well. But here I posted it for friends too. If you have any perfect idea or correct code about it, so Please send it. I shall wait for your nice comments and help. Here I also explain about my task..........Hospital...
19
2713
by: subramanian100in | last post by:
Stroustrup, in his book TC++PL 3rd Edition, in page 16, under the section '1.8 Advice' has mentioned the following: Don't use global data(use members) Don't use global functions Don't use public data members. Don't use friends, except to avoid or . Consider the following scenarios: Scenario 1:
1
1644
by: qrosity | last post by:
Why message var is always empty? var x:XML = new XML(); x.ignoreWhite = true; var total:Number; var clave:Array = new Array(); var friends:Array = new Array(); var birthday:Array = new Array(); var favourite:Array = new Array(); var telephone:Array = new Array();
2
2907
by: LeXave | last post by:
Hi all I've got the following problem in my database structure : I have a table "User". Each user can have one or more friends which are users too. And I have no idea about the way I must think my structure. My first idea was to create a second table "User2" which would be an exact copy of the table "User", but I can't because of the fact that an user can have several friends... The best way would be to store friends in a collection,...
0
8330
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.