473,385 Members | 2,044 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,385 software developers and data experts.

Need Help from u friends...

Hi ...i am new to programing....pls 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 1895
SanjaiGandhi said:
Hi ...i am new to programing....pls 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.invalidwrote:
SanjaiGandhi said:
Hi ...i am new to programing....pls 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.invalidwrote:
>>
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.invalidwrote:
SanjaiGandhi said:
On Feb 15, 12:10 pm, Richard Heathfield <r...@see.sig.invalidwrote:
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...anyway thanks for ur wonderfull answers to the beginners....thanks 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.
>
>>>>>>>>>again 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

"SanjaiGandhi" <sa***********@gmail.comwrote in message
news:11**********************@p10g2000cwp.googlegr oups.com...
Hi ...i am new to programing....pls 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....pls 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
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...
0
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...
3
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
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
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...
3
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...
5
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....
19
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...
1
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...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.