Monday, May 24, 2010

Help with my C program. How do I ask the user whether they want to start again?

What line of code would I use to ask the user if they wanted to start over from the beginning? I want to put this line of code at the end of the program.





#include %26lt;stdio.h%26gt;





int main()


{


float e, d, a, b, c;


d=40;


e=6.25;


printf("Wage Calculater\n");


Start:


printf("\nEnter the amount of hours worked: ");


scanf("%f",%26amp;a);


if (a%26gt;d){


printf("\n\n ***INVALID***\n\n");


printf("Only 40 hours are possible in a week");


goto Start;


return 1;


}


Mid:


printf("\nNow enter your hourly rate: ");


scanf("%f",%26amp;b);


if (b%26lt;e){


printf("\n\n ***INVALID***\n\n");


printf("Entered value was less then minimum wage\n");


goto Mid;


return 1;


}


c=a*b;


printf("\nYour salary for this week is:\n");


printf(" \n ***%f***\n",c);


system ("pause");


return 0;


}

Help with my C program. How do I ask the user whether they want to start again?
do a looping statement..





do{


/* you should place your codes here that you want to be repeated*/


do{


printf("do you want to try again? Y/N");


ans = getch();


}while(toupper(ans) != 'Y' %26amp;%26amp; toupper(ans) != 'N');


}while (toupper(ans)=='Y');





//make a variable ans
Reply:C has a powerful feature called recursion. (You may know that).





In the end of the program add


printf("Continue?(Y/N) :");


fflush(stdin); /* this is required. try without this */


opt = getch(); /* you must declare char opt */


if toupper(opt) = 'Y' /* #include %26lt;ctype.h%26gt; */


main(); /* this is recursion. main() is called inside main() */





Why do you use goto statements? They cause the system to abruptly jump. Use do while instead. (This loop executes at least once. If the answer matches the criteria, control is terminated out of the loop. Otherwise it loops again)


How long has this 1099-c debt elimination reporting been in effect?

I receive a letter from the IRS stating that I did not include $10,000 in my taxes from a 1099-c debt elimination from GMAC. I never owed them $10,000.

How long has this 1099-c debt elimination reporting been in effect?
What did you owe GMAC?





Clearly they think they loaned you money and you never paid the loan...because when they finally wrote the money off as non-collectible, they issued you a 1099-C. One copy went to the IRS and one copy got mailed to you at the last address they had for you.





From the government's point of view, not paying a loan back is economic income. You are required to include it income unless you are in bankruptcy or are insolvent by more than this amount.





The rules have been so static in this area, this year is the first time they've updated the publication since 1996.
Reply:You could try to google it ,here is some direct resource might be helpful.http://debt-consolidation.featured-resou...
Reply:Income from discharge of indebtedness has been a taxable item for decades.


Program using C++?

how do i write a program for this:





a program that reads in the coordinates of three points on a two-dimensional surface (a plane). Each point has an x-coordinate and a y- coordinate. Each point is given on a line by itself.


Thus your program's input will be something like:


------------------------------------


5.0 5.0


6.0 6.0


7.0 7.0


------------------------------------


The program computes the total distance involved in traveling from the first point (in this case 5.0,5.0) to the second point (6.0,6.0)


to the third point (7.0,7.0 in this case). It displays this distance on a single line:


------------------------------------


2.82843


------------------------------------








I need this asap (C++ programming file.. like one that produces the letter G,





#include %26lt;iostream%26gt;


using namespace std;





int main() {


cout %26lt;%26lt; "G";


return 0;


}





thanks in advance)

Program using C++?
#include %26lt;iostream%26gt;


#include %26lt;math.h%26gt;


using namespace std;


int main() {float n[6];


for(int i=0;i%26lt;6;i++) cin%26gt;%26gt;n[i];


cout%26lt;%26lt;sqrt(pow(n[0]-n[2],2)+


pow(n[1]-n[3],2)) +


sqrt(pow(n[2]-n[4],2)+


pow(n[3]-n[5],2));}








happy? :-D
Reply:/** SAY HELLO TO YOUR TEACHER FROM MEEE :) , I HATE *THEM :)


*THIS PROGRAM IS A COMPLETE WORKING TESTED ONE.


*WRITTEN ON VC++ 6.0


*YOU BETTER CHOOSE ME AS THE BEST ANSWER :))


**/


#include%26lt;iostream%26gt;


#include "math.h"





using namespace std;


using std::endl;





int main()


{


/**


*Read 3 inputs from standard input


*(keyboard, you can make it read


*from a file)


**/





/**


*You can define floating point variables if you want


**/


double x1=0; double y1=0;


double x2=0; double y2=0;


double x3=0; double y3=0;


double result=0;





cout%26lt;%26lt;"Please input x1 y1 x2 y2 x3 y3:"%26lt;%26lt;endl;


cout%26lt;%26lt;"Example: 2 3 5 6 3 5"%26lt;%26lt;endl%26lt;%26lt;"Input: ";


cin%26gt;%26gt;x1%26gt;%26gt;y1%26gt;%26gt;x2%26gt;%26gt;y2%26gt;%26gt;x3%26gt;%26gt;y3;





/**Calculation goes here


*double fabs (double x ),Computes absolute value of x


**/


result += sqrt(fabs(pow((x2-x1),2) + pow((y2-y1),2)));


result += sqrt(fabs(pow((x3-x2),2) + pow((y3-y2),2)));





cout%26lt;%26lt;endl%26lt;%26lt;"The result is: "%26lt;%26lt;result%26lt;%26lt;endl;





return 0;


}





MY EDIT FOR YOUR LOGICAL ERROR: The error is about you lazy, it works on my computer very well, i'm giving you a screenshot, check the code and see if you could correctly copied and pasted it. Syntax is an important thing you know right? or you don't even know how to copy it?And i assumed that you saved the file as xxx.cpp not xxx.c! one last thing if you are using a platform other than MS Visual C++, try changing #include "math.h" into #include%26lt;math%26gt; or #include%26lt;math.h%26gt;


otherwise the program is totally working here is the proof:


http://img81.imageshack.us/img81/2656/un...





EDIT FOR SMART AS S ADVISORS AND FOR THE LOSER that calls me a jerk: If a person is old enough to surf the web and ask questions,then he is old enough to know what is good and not good for himself. Take care you very wise smart-a ss advisors.
Reply:It can easily be done in one function.





have the first and second numbers as part of the function, as well as a third for the solution.





easy
Reply:you should try doing your own homework and THEN ask for help
Reply:Great. So some jerk gave you the answer. Which you will probably hand in, rather that work on it yourself. So then you realize you can't pass the exams, so you cheat on those too, if you can.





Then you take a job someplace, and you're that useless guy that can never do anything for himself. Always bugging the other engineers, asking questions, trying to get them to do your work for you.





After a while they'll get tired of you. If they're too nice to fire you, you get shuffled around to different teams, never moving upward, only sideways. Then one day the company gets acquired, and they use the reorganization as an excuse to boot you out the door.





What a depressing life you're going to have.





Why not develop some self respect? Be good to yourself, and start developing the skills that you're supposed to have when you graduate. Stop faking it and actually become someone who can do things. You'll be happy you did.


Programming using C++?

how do i write a program for this:





a program that reads in the coordinates of three points on a two-dimensional surface (a plane). Each point has an x-coordinate and a y- coordinate. Each point is given on a line by itself.


Thus your program's input will be something like:


------------------------------------


5.0 5.0


6.0 6.0


7.0 7.0


------------------------------------


The program computes the total distance involved in traveling from the first point (in this case 5.0,5.0) to the second point (6.0,6.0)


to the third point (7.0,7.0 in this case). It displays this distance on a single line:


------------------------------------


2.82843


------------------------------------








I need this asap (C++ programming file.. like one that produces the letter G,





#include %26lt;iostream%26gt;


using namespace std;





int main() {


cout %26lt;%26lt; "G";


return 0;


}





thanks in advance)

Programming using C++?
Okay, so currently the sum total of your programming abilities is to print a single letter to standard output. Frankly, the market for this skill is pretty thin.





I'd suggest doing this assignment yourself, and working on your problem solving skills. I'll give you one tip, though. The distance between two points in the plane is computed as





sqrt( (x0 - x1)^2 + (y0 - y1)^2 )





You'll have to turn that into valid C++, but once you get that working, the rest of the program should be very easy.





If you can't solve it, you may want to reconsider your choice of careers.
Reply:How much will you pay me for this?

flowering plum

C++ little problem?

I'm having problem with this piece of code:





#include %26lt;stdio.h%26gt;





#include %26lt;conio,h%26gt;











void main( )





{





int y=0, r=0, c=8;





do{





clrscr( );





printf(“value:”); scanf(“%d ”, %26amp;y);





if (y = = 0)





r = r+1;





}while(y%26lt;=100);





printf(“ r = %d”, r);





}





****


ok, now my question is:


does this determine:


a) counts the number of zeros entered in n numbers that are lower than 101


b) counts the number of zeros entered in n numbers that are lower than 100





really having trouble with this, already did many tests but can't get to a conclusion, any help would be greatly appreciated.

C++ little problem?
Look at this from your program:





while(y%26lt;=100);





What this means is that the code in the loop will execute when the condition is true. In this case, the condition is that y is less than or equal to 100. So, when y is 100 the loop will still execute. But that is it. It will not work past 100. That means that it will count the numbers until it gets to 100 -100 will be counted.





So a) is the correct answer.
Reply:Choice a is the answer.
Reply:Entering in 100 would not get counted but the loop continues.





Entering 101 would not get counted and the loop would stop.





I would say both answers are correct. But, to stop the loop A would be the answer.





bad question though...if they are trying to teach while loop condition stops. Bad bad....


Why is there an error in C?

#include "stdafx.h





int main(int argc, char* argv[])


{


int c;





c = getchar();


while (c != EOF) {


putchar(c);


c = getchar();


}


}








That is my code. when I run it, it shows an error. I use Microsoft Visual C++, Windows XP, and I am making a Console Application. A little help please...

Why is there an error in C?
you are missing a closing quote on the include





#include "stdafx.h"
Reply:getchar(); is an undeclared identifier. What do you want to do with getchar(); ? What will getchar be? A number, a letter, a string, what? Identify it. Just like int c; you need to indentify getchar(); - Without quotations it becomes a variable, but the variable is undeclared. When in doubt, find out what type of program you are making and look for it on the internet. You can find alot of C++ programming examples. Just type around. You'll find the answer. In C++, one error leads to another. Tip: Build your application after each line of code so that you may find your errors as you go along. Instead you are writing a program with errors from the start. When you fix one error, another will pop up. Start over and build from beginning. Don't just code away.
Reply:You are missing a closing speech mark (") on your first line, so C thinks your whole file is part of the filename to include! (You are probably getting an EOF error).





Maybe this is more what you want (I'm assuming your header file stdafx.h contains the standard input/output library stdio.h):





---





#include %26lt;stdio.h%26gt;





int main(int argc, char* argv[])


{


int c;





while ( (c=getchar()) != EOF) {


putchar(c);


}





return 0;


}





---





You might also find this website useful (I do):


http://www.cppreference.com/index.html
Reply:lets see my answer is....................... get a life
Reply:I think you selected the wrong options while creating your project.





Why don't you try creating a new project and then copy and paste your main into the new project, and then try running it. ( and add the header )





The steps for creating a project are:


-New Project


-select C++ , win 32 on left side and Win 32 Console project on the right side


-select location where to create , give name


-select Application Settings, click on Console and Empty,


-Finish











Oh, and another thing is that you don't have a return statement in your main. You always need to have a return statement in your main function!!!! Since, you said int main, your main should return an integer and so you could put something like a return 0; as the last statement in your main.





Hope this fixes your problem.
Reply:! = i think





see what happens...





if not take the damn P.C. back to the shop and tell them you are to thick to own a p.c.!





LoL! I wish you luck... i have not got a clue... cheers!





I guess you got Cods Heads there! hope these kind people help!


Anyone have friends that they don't include in....?

Let's say your just friends with someone who you get along with. You've introduced this person to your group of friends. you and your friends like this person yet you never include them in your plans. Why??? Is it b/c you assume they already have friends to hang with (if so, did you ever bother to ask) Anyone ever done this???

Anyone have friends that they don't include in....?
People do that sort of thing because they are not open to having new friends since they got so close to other people. They feel like they have enough and they don't want to talk to other people, which is wrong, but that is the way it is. I can tell you are going through something like this, and you should ask to hang out, wether they like it or not.
Reply:Thank you!!! Hopefully you have made some friends! Report It

Reply:i have friends like that. i consider them accquaintences and i enjoy hanging out at school with them. i have about 4 main friends and the rest i usually just hang with at school