Friday, July 31, 2009

C++ programming environment - free package?

I have Dev C++.


(A)The window closes when I run a program. I know there are ways around this. I've seen no fewer than twenty solutions to this, including a download from Bloodshed. None have worked. I will persevere with different code that I can 'add'. My problem is that I don't know HOW to 'add' it.


(B) Are there any other suppliers of this kind of software? I have tried one that never worked out for me. (Why would these programs be so difficult to use - I wonder if they don't want just any beginner to have access?)

C++ programming environment - free package?
The "CDT" plugin for eclipse is free and java based. It uses the popular and powerful GNU compiler for C/C++ GCC as well as GDB for debugging (I believe you'll need to get gcc separately but I could be wrong. If you do I'd personally recommend installing cygwin). Eclipse is primarily known as a Java IDE and is perhaps the most popular Java IDE on the market with millions of users so you can be guaranteed the framework will receive a lot of support. As for the number of CDT users I don't know exactly.


If you are a beginner then the best choice is probably Visual Studio express. It's not as powerful as CDT but it's way easier to use. Also, if you are a student microsoft is now giving away their industrial grade version of visual studio for free.
Reply:depends if you wanna use windows





http://www.thefreecountry.com/compilers/...





has a list





OR you can use linux which has compilers also.





with windows stuff, you need to use the API normally.





as said b4 you can use vc express.
Reply:A search for code blocks or borland will give you some results for good ones also the microsoft express edition one is free.
Reply:Microsoft Express C++ is pretty good.


Also Eclipse has a great C++ editor which can be used in the gcc and g++ compilers.

alstroemeria

C Programming - Reading input from STDIN - need help.?

I need to write a program in pure C. Coming from a C++/Java background I am slightly confused.





I would like to read in a float value from STDIN. I see there are functions like read(), scanf().... that will let you read in char[], but nothing to read in something else.





So how can a read in a float, or how would I convert a char[] to a float.

C Programming - Reading input from STDIN - need help.?
#include %26lt;stdio.h%26gt;





int main() {


float x;


printf("Enter a float value for x: ");


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


return 0;


}





printf will put the string give to the standard output (this case the console).


scanf will read from the standard input.. Because it accepts any number of parameters (which are adresses to variables declared in the program) you must specify what to expect in the string given at the input. %f means here you must read a float.. If I added %f %d for example it meant fisrt try to read a float until you find a blank then try to read an integer...


printf also accepts any number of parameters and if you want to show variables you have to do exactly the same thing as for scanf.. So if I were to show the x value I would write


printf("The value for x is : %f",x); (instead of %f it will put the float value of x... if x was declared as an integer it will automatically convert it to float and then show it- implicit conversion)... and so on. :)


You'll find the documentation for printf fprintf, scanf fscanf and lots more on the internet... (look here : http://www.cprogramming.com/)


C++ programming help?

I am a beginner to the C++ language and I don't understand how to make a program that acts as a spell-checker. ie the person inputs a word and if the word is not found in some big dictionary list of words, then the program outputs a list of several "close" words. Could someone please give me some psuedocode to work with? I am totally lost. Thanks!

C++ programming help?
First, you'll want to load the dictionary into an array of strings in alphabetical order.





Then, run a simple binary search on the array of strings. If the binary search returns positive, the word is in the dictionary. If it returns negative, it is not. But you can take that return value (let's call it "ret") and do:





int ip = (ret + 1) * -1





This will give you the Insertion Point, or the point at where the word would be if it WERE in the array (even though it's not). Knowing the insertion point, you can print out values in the array around it like





cout %26lt;%26lt; dict[ip];


cout %26lt;%26lt; dict[ip+1];


cout %26lt;%26lt; dict[ip+2];





A binary search algorithm that will work for you can be found at:


http://www.fredosaurus.com/notes-cpp/alg...





Simply modify it so instead of searching arrays of ints, it searches arrays of strings.





Good luck!
Reply:Hello, Yahoo Member. Don't stress about this topic too much. It can worry you and may even have an outcome on the quality of your program. First, you need to know that if you are willing to take the time to make such a large program, you should find the right tools, like a C/C++ IDE, C++ User Library (may contain the a program with a list of the entire Webster's Collegeate Dictionary array), and proper tutorials. First, you should learn a lot about strings and how to utilize their editing optimization. You can a find a C++ string tutorial here:





http://www.cppreference.com/cppstring/in...


http://www.cppreference.com/cppstring/al...





And most importantly, here:





http://www.cprogramming.com/tutorial/les...





You must also know that if you do not find a proper C++ library created by other programmers, you may have to spend time creating your own C++ library, meaning you would have to copy every entry in the dictionary. If you are willing to do the aforesaid, then you should follow the following steps:





1. Create a prototype (.exe, or .bat prototype file)


2. Learn Windows-based C++ Application programming.


(http://www.codeproject.com/KB/dialog/sdi...





Thank you, and remember to BA this answer!


- Digital Enigma


C programming loop structure arrays?

I am trying to write a c program that can easily compare pizza prices. it will take in a bunch of pizza information, spit it out with the cheapest deal.





I want to use for loops to take in the different deals..because the number of deals change every night the user must enter how many deals he is inserting to the program.





then I donnt know where to go from there. how to take in the information and fill into an array? how do you take the information that is in the array and calculate and coompare the prices? I am completely lost...





could I also use strings so deal one = pizza hut and deal two = dominoes and deal three = local vendor rather than use Deal #1 and Deal #2....





the unit of comparison should be in dollar per square inch.


please help. you dont have to do all the work, I just need to know how to get started. thank you

C programming loop structure arrays?
ok here are some ideas:


first I would allocate the arrays but since this is for your example I am making it easy...





you could make a struct and then make an array of these structs use cin to get the data


so


struct PizzaDeals


{


char PizzaCompanyName[32]; // some reasonable size


float pizzaSize; // diameter in inches


float price;


};





now


PizzaDeals pizzaDeals[25]; // maybe uptp 25 deals???





and


get the data:





int i, count;


count = 0;


for(i=0; i %26lt; 25; i++)


{


printf("enter pizza name: ");


scanf("%s",pizzaDeals[i].PizzaCompanyN...


prinft("enter size: ");


scanf("%f", %26amp;pizzaDeals[i].pizzaSize);


prinft("enter price: ");


scanf("%f", %26amp;pizzaDeals[i].price);


count++;


}





now calculate the best deal





int bestIndex = 0;


float bestPrice = 99999.99; just make a number that your first cal is less than.


now loop through calculating...





for( i = 0; i %26lt;count; i++)


{


if( pizzaDeals[i].price/(pizzaDeals[i].pizza... )%26lt; bestPrice)


{


bestPrice = pizzaDeals[i].price/(pizzaDeals[i].pizza...


bestIndex = i;


}


}


printf("Best Deal = %s, at $%f",pizzaDeals[i].PizzaCompanyName,pizz...





note there is no error checking or smartness in array management...
Reply:sudo code....


struct pizzas{


char *name;


int price;


};


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


int numofdeals, i;


struct pizzas *ptr;


fgets()


numofdeals = strtol();


ptr = malloc(numofdeals * sizeof(struct pizzas);


for(i = 0; i %26lt; numofdeals; i++){


/*fill in data*/


ptr[i].name = name;


ptr[i].price = price;


}


for(i = 0; i %26lt; numofdeals; i++){


/*process data*/


ptr[i].name;


ptr[i].price;


}


free(ptr);


return 0;


}
Reply:you could also use the statements IF AND OR ETC
Reply:When you say deal it sounds like you are talking about more than just prices. Examples would be deal 1: 12 slices for $12, 16 slices for $14, $4 slices for $6, etc.





Therefore you need your deal in a struct. You get user input from stdin in a loop because you need to fill your array.





When you have all your deals in the array, you'll need to traverse it to find the best deal. So for example, you'll have a for loop that goes through your array and finds the highest number of slices per dollar.





Once you find the best deal you'll have the function return this value and that's it.
Reply:Well, you could use structures





typedef struct pizzadef


{


char[20] vendor;


long inches;


double price;


} pizza;





In c++, you could make it a class, but you can still do lots of good stuff with C.





I'd store the deals and such in a file, so you can pull them in and calculate on the fly.


Assembly or C programming?

Develop a program to swap the last element of an array with the first element, second element with the second-to-last element, and so on. Assume the array contains 20 8-bit elements.





I want to develop this program in assembly language, But If I have a pseudo code or C program, I think I can convert it to assembly language since I think the process is the same. So can anyone help me develop a code for this program?





thank you

Assembly or C programming?
Define array A[p] //p = 20








last_element = p


first_element = 0


while first_element %26lt;= p/2 //if p is odd, then the middle element


...................................... //will not need to be switched


{


temp = A[first_element]


A[first_element] = A[last_element]


A[last_element] = temp


first_element = first_element + 1


last_element = last_element - 1


}
Reply:If you have any knowledge of programming, most of this should be pretty mundane and something you've written before.





The only part that you possibly may not be familiar with is sucessfully swapping the elements without accidently overriding one or the other. You're going to need a third, temporary value.





The swap will occur as follows:





Z = A;


A = B;


B = Z;





Where A and B are elements to be swapped, and Z is the temporary storage variable.





It would probably be easiest to pass the element variables or pointers through a function that swaps them. Then, just make a loop that iterates through the array appropriately (i.e. one variable counts forward, the other counts back, and use them to pull the elements you need to send to the swap function).

primrose

C++ programming question?

how can i use C++ to write a program that will ask the user to think of a number, than the program will have a initiate guess of 100, if that is not the number, it will do some simple math until it gets the number.

C++ programming question?
should start at 50 and do a binary search (keep splitting in half)


if it's high than 50 you only concentrate on 51 up. Next guess should be 75..if it's lower than that you now only have 51-74 left to look at...next guess is center of that..62 ....and so on....


C++ programming help?

Our teacher asked us to do this...





The algorithm to find which day of the week a given date falls upon is given below:





a = INT((14 - month) / 12)





y = year - a





m = month + (12 * a) - 2





dayIndx = (day + y + INT(y / 4) - INT(y / 100) + INT(y / 400) + INT(31 * m / 12)) MOD 7





eg. Given the date 06/07/1998, day = 06, month = 07 and year = 1998 in the above formula and dayIndx is the index of the days (for eg 0 -%26gt; Sunday, 1 -%26gt; Monday …… 6-%26gt;Saturday)





Using the above algorithm, write a program which takes as input a date and writes the corresponding day of the week for that date.





The first two characters of the input file will represent the day. The fourth and fifth characters will represent the month. The seventh, eighth, ninth, and tenth characters will represent the year. (The third and sixth characters will be “/”.)





How do i write this programme in C++????

C++ programming help?
I really should not have done the whole thing for you but I trust you are going to study and improve on the program and learn from it rather than hand it in as is. Also, you probably haven;t used istringstreams so if you cheat your teacher will catch you. Figure out how to do that portion differently on your own. Put in more edits.





#include %26lt;iostream%26gt;


#include %26lt;string%26gt;


#include %26lt;sstream%26gt;


using namespace std;





bool isValidDate(string date, int %26amp;dd, int %26amp;mm, int %26amp;yyyy)


{


if ((date.length() != 10)


|| (date[2] != '/')


|| (date[5] != '/')


|| (! isdigit(date[0]))


|| (! isdigit(date[1]))


|| (! isdigit(date[3]))


|| (! isdigit(date[4]))


|| (! isdigit(date[6]))


|| (! isdigit(date[7]))


|| (! isdigit(date[8]))


|| (! isdigit(date[9])))


return(false);





date[2] = ' ';


date[5] = ' ';





istringstream stream(date);





stream %26gt;%26gt; dd %26gt;%26gt; mm %26gt;%26gt; yyyy;





if ((mm %26lt; 0)


|| (mm %26gt; 12)


|| (dd %26lt; 0)


|| (dd %26gt; 31))


{


return(false);


}





//check for leap year and Feb end date


//if you want





return(true);


}








int getIndex(int dd, int mm, int yyyy)


{


int a = (14 - mm) / 12;


int y = yyyy - a;


int m = mm + (12 * a) - 2;





int index = (dd + y + (y / 4) - (y / 100) + (y / 400) + (31 * m / 12)) % 7;





return(index);


}








int main()


{


string days[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};


string inDate;


int dd, mm, yyyy;


bool invalidDate = true;





while (invalidDate)


{


cout %26lt;%26lt; "\nEnter date (dd/mm/yyyy): ";


getline(cin, inDate);





if (isValidDate(inDate, dd, mm, yyyy))


invalidDate = false;


else


{


cout %26lt;%26lt; "\ninvalid date." %26lt;%26lt; endl;


continue;


}





cout %26lt;%26lt; inDate %26lt;%26lt; " was a " %26lt;%26lt; days[getIndex(dd, mm, yyyy)] %26lt;%26lt; endl;


}





return(0);


}


C Programming percentage?

Can someone give me a simple C program that will display the percentage of two numbers.

C Programming percentage?
just change the 400 to 400.00 and the 800 to 800.00.


Other than that, your program is correct
Reply:i can help for sure. but you have to make the problem more clear. i mean you wanna find out the average number or percentage ( like number one from another). the percentage formula is n1 / n2*100.
Reply:#include %26lt;stdio.h%26gt;





int main(void)


{


float myVar = 3.24;


float myOtherVar = 1.618;


printf("myVar = %f and myOtherVar = %f", myVar, myOtherVar);


getchar(); // So the program doesn't close immediately


return 0;


}
Reply:for integers:





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


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





int main (int argc, char **argv) {


int numerator, denominator;





if (argc != 3) {


fprintf(stderr, "%s num denom \n", argv[0]);


return 1;


}





numerator = atoi(argv[1]);


denominator = atoi(argv[2]);


printf ("%d/%d = %3.2f%%\n", numerator, denominator, 100 * ( ((float)numerator)/denominator));


C programming to control 2 dos windows?

Is it possible that a C program make a dos window to talk to another dos window?

C programming to control 2 dos windows?
AFAIK, you'll need two separate processes. You can get them communicating using your favourite IPC method.
Reply:yeah ,possible .


by socket programming.
Reply:Google "Multi-Threading in C"
Reply:multi threading

queen of the night

C programming problem?

what does it mean when i run a C program and it says Segmentation fault?





I'm trying to turn the array {0,24,13,90,457,124,47,733,346,123} into a table.

C programming problem?
It can be incredibly difficult to find these errors. Nightmare to debug. You have to comment out code to find the where the error is. Or put printf statements in your code from the top down and see how far it gets each time. If you are unsure the logic of your code is fine, you may have to look into that.
Reply:It means you stepped on memory that isn't yours, generally. Or, you called something that stepped on memory you don't own (or memory not segmented to be written on)


Programming with c?

Vectors


Vectors are very important in mathematical computing and in computer graphics .Vector graphics is economical in its use of memory, as an entire line segment is specified simply by the coordinates of its endpoints. A vector can be represented by an arrow whose length represents the magnitude and the direction represents the vector direction.








The above vector a can be represented as





a = [a1, a2]





The arithmetic operations can be performed in the following way:





o Addition





If a and b are two vectors





a = [a1, a2]





b = [b1, b2]





then the sum of a and b is





a + b = [a1+b1 , a2+b2]





o Subtraction





If a and b are two vectors





a = [a1, a2]





b = [b1, b2]





then the difference of a and b is





a - b = [a1-b1 , a2-b2]





o Multiplication





If a and b are two vectors





a = [a1, a2]





b = [b1, b2]





then dot product of a and b is





a . b = (a1 * b1 ) + ( a2 * b2)





o Length of vector





If a is a vector





a = [a1, a2]





then the length of vector a is





length =





Assignment





Write a C++ program that performs the above mentioned operations on vectors with the help of above mentioned formulae. The program should have four user defined functions for the above operations.





1) Addition


2) Subtraction


3) Multiplication


4) Length





The following menu of commands should be displayed at the start of program execution.





Press 'a' to add two vectors





Press 's' to subtract two vectors





Press 'm' to multiply two vectors





Press 'l to calculate the length of vector





Press 'q' to quit





Please enter your choice: a





After the user selects a choice, prompt the user to enter the vector components on which the selected mathematical operation is to be performed, and then display the result. For example,





if the user enters ‘a’ then your output should be:





Enter first component of vector : 2


Enter second component of vector : 7





The vector is : [ 2 , 7 ]





Enter first component of vector : 6


Enter second component of vector : 3





The vector is : [ 6 , 3 ]





The sum is [ 8 , 10 ]





if the user enters ‘s’ then your output should be :





Enter first component of vector : 2


Enter second component of vector : 7





The vector is : [ 2 , 7 ]





Enter first component of vector : 6


Enter second component of vector : 3





The vector is : [ 6 , 3 ]





The difference is [ -4 , 4]





if the user enters ‘m’ then your output should be :





Enter first component of vector : 2


Enter second component of vector : 7





The vector is : [ 2 , 7 ]





Enter first component of vector : 6


Enter second component of vector : 3





The vector is : [ 6 , 3 ]





The multiplication is 33





After the menu if the user selects ‘l’ then your output should be





Enter first component of vector : 1


Enter second component of vector : 2





The vector is : [ 1 , 2 ]





The length is 2.23607





After the menu if the user selects ‘q’ then your output should be





Press any key to continue …..





Conditions that must be checked and fulfilled:





1) If a user enters choice other then choices given in menu, then a message should be displayed “You have entered wrong choice:” and main menu should be displayed again.


2) If a used enters a ,s or m then you have to take components of two vectors then do calculation on them


3) If a user enters l then you have to take components of one vector only then do calculation on it.

Programming with c?
Do your homework yourself. Who do you think has that much time to read through your zillion words long questions and then give you a ready made answer. %26gt;.%26lt; Have some decency!





Write down your code, and then if you are stuck somewhere, ask us and we'll help you.
Reply:Seriously do your own homework. Im tired of "questions" like these. Are we allowed to report them? Btw, if you can't handle an assignment like this without asking someone else to do it for you, drop the class. THIS IS SIMPLE! A few cin's, a few cout's, can count the number of variables required with my fingers and a couple if's or switch statements. Read the material your instructor provided you with and then come back with specific questions. Those we will answer.
Reply:This questions seems professional, i would recommenced, if you cannot do it yourself, you can take professional help and ofcourse this never comes free, i know professional who do this type of homework, try contact ankurjain@excitonpublications.com they have nominal charges around $50 per answer.





try this, hope they will help





regards
Reply:Do not you think that is lot of homework ?


C programming: how would i go about this question:?

I'm trying to help my friend out with this and we cant get it working. How would you go about doing this?





1. Write a C program that opens two data files one for reading and another for


writing. The program must copy the contents of input data file to output file


with the data double line spaced. Example below. The program must work


for all data files [ and not just for the following example ]





Input file:





Earth is Solid


So is Moon.





Output File:





Earth is Solid





So is Moon.

C programming: how would i go about this question:?
If ur talkin bout c++ then its here:





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


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


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


class handle2files


{


public:


readnWrite();


};


void handle2files::readnWrite()


{


ifstream inputfile;


inputfile.open("filename.ext");


ofstream outputfile;


outputfile.open("filename.ext",ios",io...


char ch[300]; //to temporarily store each char from input file


while(inputfile)


{


inputfile.get(ch[i]);


if(ch[i]=='\n') signal=-1; //one line read


cout%26lt;%26lt;ch;


if(signal==-1)


{


ch[++i]='\n'; //this is to add one more line gap(doubled gap)


outputfile.write(ch,sizeOf(ch)); //line written into output file


signal=0; i=0;





}


}


inputfile.close();


outputfile.close();


//done!


}





void main()


{


handle2files object;


object.readnWrite();


getch();


}
Reply:Open the input file for read


Read the first record


If end-of-file


print error message


end-if


Open the output file or write





Loop until end-of-file


output = input + '\n\n'


write output file


read input file


end-loop





Close input file


Close output file





That should do it.
Reply:Computer Tutorials, Interview Question And Answer


http://freshbloger.com/


Simple C programming with Arrays.?

I don't understand how to do this, I'm a little lost on arrays and these instructions!





Write a program using a two-dimensional array to compute and print the following information from the table of data discussed below:





(a) Total value of sales by each girl.


(b) Total value of each item sold.


(c) Grand total of sales of all items by all girls.





Item 1 Item 2 Item 3


Salesgirl #1 310 275 365


Salesgirl #2 210 190 325


Salesgirl #3 405 235 240


Salesgirl #4 260 300 380





Your program needs to read the values first and finally outputs the results.

Simple C programming with Arrays.?
I really wish people would stop oosting their homework up for someone else to do. In future, if you absolutely must and really need help, at least include an attempt you've made at the problem.





Here's a link to a tutorial that deals with two dimensional arrays in C:


http://www.exforsys.com/tutorials/c-lang...





Phlox

baby breath

I know C and Visual basic programming, how do i create a DLL file that I could use in the VB programs?

I want to experiment on my visual basic program using a link to simplify my codes and that is through using DLL files. I want my DLL files to be made using C/C++ program. After creating a C program, I want to make a DLL file out of it and use this to my VB application.

I know C and Visual basic programming, how do i create a DLL file that I could use in the VB programs?
If you download VB.NET Express (Free download from Microsoft) you can use it to create DLLs
Reply:its not free Report It

Reply:Hmm strange.


Looking at Microsoft site


http://msdn.microsoft.com/vstu...





"Get it for FREE" I downloaded it for Free, installed it for Free, and have been using it for Free.





But if you say it's not free ... Shrug. Report It

Reply:The Client Application (Visual Basic)





Accessing a C++ DLL from Visual Basic is much easier than from C++. The only task that must be done is to declare the function prototype; Visual Basic will handle everything else. In order to do this, include a code module by clicking Project -%26gt; Add Module -%26gt; Open. In the new module, declare the function prototypes in the following manner:











Declare Sub TestFunc Lib "../testdll_library.dll" ()


Declare Function RetInt Lib "../testdll_library.dll" (ByVal t As Integer) As Integer

















One important note is that all parameters must be passed with the ByVal keyword. This is because Visual Basic always passes parameters ByRef by default. Since C/C++ usually passes by value, this must be specified in the Visual Basic declaration. This is all that is necessary when standard C variable types (int, long, etc.) are used, however complex data types like strings and arrays require more overhead on both the client and DLL sides.





Quote from source. Google is amazing isn't it? ;)


C++ Programming Question?

I'm having a little trouble figuring a successful program for this problem... any help would be appreciated!!





Write a C++ program that first asks the user how many numbers will be entered - let's call this positive integer n. Then the program reads n integers (not ordered) and outputs how many even values and how many odd values have been entered. The input should be restricted to only integers between 0 and 100.

C++ Programming Question?
I won't give you the code, but I will give you some pseudocode that should help alot :





- intialize a counter for evens, and one for odds


- get the # of numbers to be entered by user


- start loop based on the number entered


- for each pass of the loop, get a number from user


- use the modulus operator (%) with the number 2 to determine if the number is even (e.g. 16 % 2 = 0, 15 % 2 = 1) so if the answer is 0, number is even


- increment appropriate counter





FYI - if your instructor hasn't already told you, I will : always do some pseudocode first, especially if you are having trouble. That way, you don't worry about the syntax, and can focus on the logic. Once the logic is right, the syntax is a piece of cake. Good luck : )
Reply:First get their input and store it to variable "n"


Then use a for loop to get that many numbers


As each number is entered, do number modulus 2


Use If to detect if it is even or odd (0=even 1=odd)





#include %26lt;iostream%26gt;





int main ()


{


int n;


int i;


int x;


int odd;


int even;





cout %26lt;%26lt; "Please enter a value: ";


cin %26gt;%26gt; i;


for(i=0,i%26lt;n,i++){


cout %26lt;%26lt; "Please enter a value: ";


cin %26gt;%26gt; x;


x = x%2;


If x{


odd += 1;


Else


even += 1;


}


}


cout %26lt;%26lt; even;


cout %26lt;%26lt; " are even";


cout %26lt;%26lt; odd;


cout %26lt;%26lt; " are odd";

clear weed

Writing, running, testing C programming language?

I am a beginner in writing C/C++ and was just wondering what good program can do these things well. I've heard Microsoft Visual C++ works but I'm not sure. Any other programs? Thanks.

Writing, running, testing C programming language?
Borland C++ or turbo C++
Reply:try bloodshed dev cpp ide. it's really gud! u can download them from,


http://www.bloodshed.net/devcpp.html





Happy Coding





Let Google be with you!
Reply:Borland C++ Builder is the program my father uses. For your purposes, I would look at the Borland website thoroughly and see if you can't find a free version of a previous compiler version. I would personally learn to code in Java though, it's much more versatile.





See, with Java you can definitely download everything free from the Internet. I would start with that. Java is structurally very similar to C++. If you have an elective at school for C++ or Java, take it, you will learn crucial Object-Oriented programming concepts.





EDIT-





The best is JCreator by Xinox software. You have to download the documentation from the Java website for the compiler to work.


Help me with C programming!!!?

i have not understood C program clearly.. Is there any site or books which can help me to understand C program easily(about how to write a program,basic things of C program)...


plz plz help me....

Help me with C programming!!!?
It takes a while to learn it. Honestly I would take a class at college if you are really interested in it.
Reply:hey try out http://www.programmingtutorials.com/ it ll surely help u out....


there are around 300 diff languagt tutorials available n tat too free and are too good.... i did c++frm there
Reply:Well visit http://www.cplusplus.com This website contains the basics of C fully and elegantly covered. I think it will be helpfull for your understanding C language. It also contains many sample scripts that you can use for learning the basic format of C clearly.
Reply:check out codeproject.com


it offers small c projects and explain each statment in detail and it's free too





Good luck :)
Reply:Hey try "Let Us C" by yashwant kanitkar it is the best


else


you need any ebooks or tutorials try esnips.com


there are many books available for free there
Reply:i think for basics e balaguruswammy is the best book and y kanetkar for practices
Reply:Duh . There are tonnes of books on C . Like C for beginners .


Your answer lies in a book store .


If that doesn't work try attending a class
Reply:u should take classes at NIIT institution...thats where i learned basic C++ and basuc SQL
Reply:Hey,


To under stand c language read "Let us C" by Yashwant Kanetkar.


To know clearly about the programs and their flow go through


"Exploring C" by Yashwant Kanetkar
Reply:Third edition


C Programming in ANSI


E. Balagurusamy.
Reply:"Let Us C" by yashwant kanitkar is the best for C programming...


so u have to refferr 1st these book........
Reply:Refer to Yashwant Kanetkar's Let Us C %26amp; solve exercises given
Reply:Try to go to some classes to learn c and also study some basic c books. This makes u learn c very faster
Reply:Refer to the book Let us C by Yashwant Kanetkar


Its a damn good book n vry easy to undertand.......\





or else see this website..





www.cprogramming.com





hope it helps............
Reply:there is a book called programing in c and C++by Dietel and Dietel... and another one by name...Object oriented programing in C++ by Robert Lafore..both are god books.the second one is a little better if you want to know the concepts.
Reply:freecomputerbooks.com is better to learn many books all language which you want to learn


C programming help for beginning C class?

I'm having trouble with the equations needed. we have learned the loops so far and i think this problem wants me to use the loops, and it looks like i need if-else as well. Here is the problem.





Write a program that asks the user to supply three positive integers k, m and n, with k being greater than 1. the program should compute the sum of all the integers between m and n that are divisible by k.





I don't know how to tell C that that i only want an integer evenly divisible by another. and then, i'm not quite sure how to get the addition of those integers done.

C programming help for beginning C class?
int sum = 0;


for (int i=m; i%26lt;=n; i++)


if ((i % k) == 0) sum += i;





Use the "modulus" operator ("%"). It's the remainder of the first number, when divided by the second. When this is zero, the first number evenly divides by the second one.





So, for example,


5 % 3 = 2,


6 % 3 = 0,


7 % 3 = 1





And if you don't want to include m or n in the list, change the loop from:


for (int i=m; i%26lt;=n; i++)


... to:


for (int i=m+1; i%26lt;n; i++)





And make sure m is the smaller of the two numbers. You can swap them if not.





=====================


As an alternative, you don't have to check every single number. You could write:


for (int i=(n-(n%k)); i%26lt;=m; i+=k)


if (i %26gt;=n) sum += i;





... which starts i off as the biggest multiple of k less than or equal to n, and increments i by k in each loop iteration.





You can get rid of the if statement if you initialize i a little better:


for (int i=((n-1+k)-((n-1)%k)); i%26lt;=m; i+=k) sum += i;
Reply:You must ensure that the loop terminates (so that it doesn't last forever). This is how:





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





void main()


{


int m,n,k , i ,sum = 0;





cout %26lt;%26lt; "Enter k: ";


cin %26gt;%26gt; k;


if( k %26lt;= 1)


cout %26lt;%26lt; "k must be greater than 1";


else


{


cout %26lt;%26lt; "Enter m: ";


cin %26gt;%26gt; m;


cout %26lt;%26lt; "Enter n: ";


cin %26gt;%26gt; n;


if(m %26gt; n)


{


m = m + n;


n = m - n;


m = m - n;


}


for(i=m ; i%26lt; n; i++)


{


if(i % k == 0)


sum +=i;


}


cout %26lt;%26lt; "Sum is " %26lt;%26lt; sum;


}


}





You have to check if m%26gt;n otherwise the loop





if(i = m; i%26lt; n; i++)





will never terminate.


We do this by swapping m and n if m%26gt;n


This is the classic way of swapping 2 numbers with only 2 variables:





m = m + n;


n = m - n;


m = m - n;





This is a complete program - compile and run this to see for yourself.
Reply:if (i % k)


{ i is evenly divided by k }


else


{ there is a remainder after the divide }


In C Programming, how do I search within arrays?

I'm having a hard time creating this program homework. It's written in C Language, not C++.





This is the instruction given by our teacher:





The program will accept 5 numbers. It will also accept a number to be searched (search among the inputted numbers). The program will also display the number of occurence of the number searched for and its exact location (location in the memory).





SAMPLE OUTPUT:


Enter 5 numbers: /* User inputs: 23 4 23 1 2 */


Enter number to be searched: /* user inputs: 23 */


/* the result is below */


Occurence(s): 2


Location: 0 2





I hope someone can help. It will be great if someone can show a source code. Thanks in advance. :)

In C Programming, how do I search within arrays?
int iOriginalNumbers[ 5 ];


int iNumberToBeSearched;


int iLocationArray[ 5 ] = {-1, -1, -1, -1, -1};


int iNumOccurences = 0;


int iCnt = 0, jCnt = 0;


char szDummy[1];





printf( "Enter 5 numbers, separated by a space, hit enter when done: " );





scanf( "%d %d %d %d %d", %26amp;iOriginalNumbers[0], %26amp;iOriginalNumbers[1], %26amp;iOriginalNumbers[2], %26amp;iOriginalNumbers[3], %26amp;iOriginalNumbers[4] );





printf( "\nEnter Number to be Searched: " );


scanf( "%d", %26amp;iNumberToBeSearched );





for( iCnt = 0; iCnt %26lt; 5; iCnt++ )


{


if( iOriginalNumbers[ iCnt ] == iNumberToBeSearched )


{


iNumOccurences++;


iLocationArray[ jCnt ] = iCnt;


jCnt++;


}


}





printf( "\nOccurence(s): %d\n", iNumOccurences );


printf( "\nLocation: ");


if( iNumOccurences %26lt;= 0 )


{


printf( "N/A" );


}


else


{


for( iCnt = 0; iCnt %26lt; 5; iCnt++ )


{


if( iLocationArray[ iCnt ] == -1 ) break;


printf( "%d ", iLocationArray[ iCnt ] );


}


}





printf( "\nPress enter to quit" );


scanf( "%s", szDummy );


return;





DISCLAIMER: I just typed it up on the space provided by answers, so it may have typos, silly mistakes, oversights etc. You need to #include header files like stdio.h, etc.

peacock plant

C++ Programming Question. How do you calculate Squares and Cubes?!?

I am trying to write a program for my Intro to C++ Course to calculate Squares and Cubes but I am unsuccessful. The printout is supposed to be aligned in a chart, 3 columns, with rows 1-10. Below is part of the program, but even this will not compile properly:





#include %26lt;iostream%26gt;


#include %26lt;iomanip%26gt;


#include %26lt;cmath%26gt;





using namespace std;





int main ()





{





cout %26lt;%26lt; setw(6) %26lt;%26lt; 1 %26lt;%26lt; setw(6) %26lt;%26lt; pow(1 , 2) %26lt;%26lt; setw(6) %26lt;%26lt; pow(1 , 3) %26lt;%26lt; endl;





return 0;





}








Any idea's where I am going wrong? Sorry if this is such a broad question. I have been working on this for hours and I am just having trouble getting the concepts of C++ down.





Thanks!!!

C++ Programming Question. How do you calculate Squares and Cubes?!?
logically u r goin right way
Reply:Here ya go, I'm assuming you are doing G++ compiler this compiles, and I think this is what you're trying to do.











Remember you can pass variables as parameters to functions.








#include %26lt;iostream%26gt;


#include %26lt;iomanip%26gt;


#include %26lt;cmath%26gt;





using namespace std;





int main ()





{





int num = 1;





while(num %26lt;= 10){


cout %26lt;%26lt; setw(6) %26lt;%26lt; num %26lt;%26lt; setw(6) %26lt;%26lt; pow(num , 2) %26lt;%26lt; setw(6) %26lt;%26lt; pow(num , 3) %26lt;%26lt; endl;


++num;


};


return 0;





}


C programming diamond design?

i need to know the code for a program in 'C'(not in C++) which gives a diamond shaped structure composed of * (asterixes).the program has to be done using the 'for' loop.

C programming diamond design?
Well, the best part of programming is figuring stuff out for yourself, but I can try and give you a hint:








you need some nested 'for' loops...and the variables, like 'i'





ex. for(i=0;i%26lt;whatever;i++)





are essential to your program outputting the correct number of asterisks. the printf() statement(s) should be included inside of your loops...and i'll leave the coding up to you =D good luck!
Reply:school assignment





do it urself ; thats the only way u can learn





other users plz dont help


C Programming Language: Printing Patterns With For Loops?

We are asked to do the following:





Write a program that prints the following patterns separately one below the other. Use for loops to generate the patterns. All asterisks ( * ) should by a single printf statement of the form printf ( “ * “ ); (this causes the asterisks to print side by side ).Hint : The last two patterns require that each line begin with an appropriate number of blanks.





A picture of the four patterns’ we are supposed to print can be found here: http://altunbay.isikun.edu.tr/cse105/fal...





I’ve used the following code – which works correctly – to print the patterns for A, B, and D, but I am having trouble with C. Here is my code, between the dotted lines:








--------------------------------------...








#include "stdio.h"


#define N 10


main()


{


int i,j;


for(i=1; i%26lt;=N; i++)


{


for(j=1; j%26lt;=i; j++)


printf("*");


printf("\n");





}


printf("\n");


for(i=N; i%26gt;=1; i--)


{


for(j=i; j%26gt;=1; j--)


printf("*");


printf("\n");


}





printf("\n");


for(i=1; i%26lt;=N; i++)


{


for(j=i; j%26lt;N; j++)


printf(" ");


for(j=1; j%26lt;=i; j++)


printf("*");


printf("\n");


}





}





--------------------------------------...





To anyone who answers, please show which for loop conditions can be used to print pattern C.

C Programming Language: Printing Patterns With For Loops?
Since this is a homework problem, I'm not going to give you the answer. I will try to guide you to the answer without giving it away. After all, I won't be helping you on your test and this is an important concept with nested loops.





The interesting part of this is you solved D. This means you also know how to generate C. Because, C is just a variation of D.





What did you have to do different with A and B? Wouldn't you have to do something similar to get C?





It seems you print a lot of asterisks first in C. you'd probably want to do something the opposite of D?





The answer is right in front of you and you know how to do it. You also have plenty of time to solve it before it is due.





Shadow Wolf


C# Programming Games Tutuorial (Visual Studio 2008, Direct X 10)?

I was curious if anyone knew where I can find a decent tutorial, book, or guide for how to program simple 3d games in C# code using visual studio 2008 express and directX 10. The tutorial need not be for absolute beginners to C#, but preferably not too esoteric. I can locate a fair amount for previous years, but, while not much has changed between visual studio 2005 and 2008 (though some stuff has), there is a huge difference between directX 10 and directX 9. If anyone knows where I can find a guide or tutorial for this, please let me know. Thanks in advance.

C# Programming Games Tutuorial (Visual Studio 2008, Direct X 10)?
I have 2008 if you go in the program and register on the bottom it says getting started. Click on beginner developer learning center and it brings you to videos on how to do stuff. After that you browse around and learn.

pink

C programming Probelem..Money changer?

hi everyone, how can I make a money changer program? like, if the user inputed 100 pesos and you want it to change by two 50 pesos...another example: if the user inputed 1000 pesos and you want it to change by one 500 pesos and five 100pesos. my program should be in .C file extension


hope you will help me.. thanks in advance!


(by the way pesos is the currency in Philippines)

C programming Probelem..Money changer?
You currently have the following currency.


Peso Notes


5


10


20


50


100


200


500


1000





centavos


1


5


10


25





Take the input and divide it in turn by each amount starting with the highest note.


The integer from the division is the number of that item that you want for change. The remainder becomes the new input value.


Stop when the input is zero.





It should be noted that the remainder from dividing 5 centavos will be the result for 1 centavos so you do not have to do this final divide. However it may be easier to code the divide to keep the program simple.


C programming problem related to lseek and dup2?

I just start learning to program in Linux and have problem like this.





1.


The following code is used to append 10 bytes to a file:


if (lseek(fd,0,SEEK_END) %26lt; 0 || write(fd, buf, 10) != 10)


{


opps("Seek/Write failed");


}


Assuming that none of the functions calls fail, buf is big enough, we have write permis-


sion, and fd refers to a file opened for writing then does the above code always works,


never works or sometimes works? Why?





2.


Consider the following C code:


int fd1, fd2;


char buf;


fd1 = open("file",O_RDONLY); /*open for reading */


fd2 = open("file",O_RDONLY); /*open for reading */


fd2 = dup2(fd1,fd2); /* make fd2 be the copy of fd1 */


close(fd1); /* we do not need fd1 anymore */


Assuming that none of the above function calls fail, explain in detail what happens with


the following line of C code.


read(fd2, %26amp;buf, 1);








Can someone help me,please!

C programming problem related to lseek and dup2?
how about doing your own homework?
Reply:wat


C++ Programming- Help Please e with a little problem I'm having with my program.?

Heres the question:





Drivers worried with mileage obtained by automobiles.1 driver kept track of all tanks of gas by recording miles and gallons used for tanks. Develop a C++ program that uses while loop to input the miles %26amp; gallons used for each tankful. Program should calculate%26amp;display the miles/gallon for each tankful. The program should calculate average miles per gallon obtained for all tankfuls





#include %26lt;iostream%26gt;


using namespace std;


int main()


{


double gallon;


double avrge;


double mile;


double milegallon;


counter=0;





cout%26lt;%26lt;"enter gallons used in tank( or 0 to quit) "%26lt;%26lt;endl;


cin%26gt;%26gt;gallon;


counter++;


while(gallon != 0)


{


cout%26lt;%26lt;"Please enter distance in miles"%26lt;%26lt;endl;


cin%26gt;%26gt;mile;


milegallon = mile/gallons;


cout%26lt;%26lt;"Mile per gallon is:"%26lt;%26lt;milegallon%26lt;%26lt;endl;


}


avrge = milegallon / counter;


cout%26lt;%26lt;"Overall average was"%26lt;%26lt;avrge%26lt;%26lt;endl;





return 0;


}





Is my counter correct?


Will 'milegallon' outside while loop have total miles per gallon from inside the loop or do I need to enter more info?

C++ Programming- Help Please e with a little problem I'm having with my program.?
You're close. Don't use a counter.





Instead, what you want to do is keep track of the total miles and total gallons. i.e. totMile += mile and totGal += gallon. When you get out of the loop divide the totMile by totGal to get the ave mpg.
Reply:That is going to be an endless loop. Before the closing } of the while loop you will need to ask how many gallons are used in the trip again. That way the user can say 0 to end the program.


C programming question....?

We have the following function: f(x)=500x-10x². Write a program that finds the value of x that maximizes f(x). Your program should print out the value of f(x) for each value of x. It should also print out which value of x produced the maximum value of f(x). In writing your program, you should do the following:





(a) In the header of your source code, include the pseudo code you used to design your program.





(b) Use a brute-force approach to find the answer. That is, create a loop that tries values of x from 0 to 50 (intergers only) in order to determine which value maximizes the function.





(c) Use x*x instead of the math.h function pow() for finding x². This will allow you to use a variable type of int for all variables.

C programming question....?
You need to loop over the values 0 to 50. Inside the loop you need to evaluate the function.





You also need to keep track of the running maximum and compare it with each value you calculate. When you find a bigger value, you save it away as the new running maximum.





You also need to save away the x value that produced your running maximum when you save the new running maximum.





So inside the loop you need something like





if (f %26gt; fmax)


{


....fmax = f;


....xmax = x;


}





There is one really tricky thing, and that is you have to initialize your running maximum. Otherwise the first time you execute that if statement the value will be undefined. One way is to initialise it to f(0) and loop from 1 to 50. Another is to initialize it to -INT_MAX (you need to #include something to get that, might be %26lt;limits.h%26gt; but can't remember offhand).





Good luck.

periwinkle

C programming question?

Problem C: Determining the Profit of the Goldfish Tank





Using your solutions to problems A and B, you will solve the following problem:





Given the length, width and height of the goldfish tank in inches, determine the amount of profit you can gain by selling the fish in the tank.





Assume that each goldfish in the tank requires 250 cubic inches of room in the tank to survive. (Thus, if the dimensions of the tank were 24x12x16 inches, exactly 18 fish could fit in the tank since 24x12x16 = 4608 and 4608/250 = 18.432, but you can't have .432 of a fish.) Also, assume that you sell each goldfish for $5.00. (You can store these values in constants in your program.)











Here's an example worked out:





If the dimensions of the tank are 24x12x16, we have already determined that the cost of building the tank is $28.80 and the cost of maintaining the tank is $23.04, so the total cost is $51.84.





But, we will sell 18 goldfish at $5.00 dollars a piece for a total gross revenue of $90.00. Thus, our profit is $90.00 - $51.84 = $38.16.











There is also a possibility that you may lose money with your fishtank. If this occurs, print out a message (following the sample below) indicating the amount of money lost.











Input Specification





1. The length, width and height of the tank will be positive integers.











Output Specification





Output the profit in dollars for selling goldfish to two decimal places. If there was a profit, your output should follow the format below, where XX.XX is the profit from selling the goldfish.





Your profit from selling goldfish is $XX.XX.





Otherwise, if there was a loss, you should follow the following format:





Your loss from selling goldfish is $XX.XX.





You may choose to handle the case where there was no profit or loss in any way you see fit.











Output Samples





Below are two sample outputs of running the program. Note that these samples are NOT a comprehensive test. You should test your program with different data than is shown here based on the specifications given above. In the sample run below, for clarity and ease of reading, the user input is given in italics while the program output is in bold.











Sample Run #1





What is the length of your goldfish tank in inches?





24





What is the width of your goldfish tank in inches?





12





What is the height of your goldfish tank in inches?





16





Your profit from selling goldfish is $38.16.











Sample Run #2





What is the length of your goldfish tank in inches?





1





What is the width of your goldfish tank in inches?





1





What is the height of your goldfish tank in inches?





1000





Your loss from selling goldfish is $65.02.

C programming question?
You failed to provide the previous questions. In other words, this program depends on how you calculate your costs. I assume those come from previous questions, which are not included in your information. That said, here's some code. (Too bad the spacing kills it.) You have to put in the formulae for the cost functions, and then it should work. If I were you, I'd test the program thoroughly after you're done and not just "trust it works." But don't get me wrong, I trust I write good code. :-p





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


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





int promptNum(char* question);


float costBuild(int length, int height, int width);


float costMaintain(int length, int height, int width);





int main()


{


int length, height, width;


length = promptNum("What is the length of your fishtank in inches?\n");


height = promptNum("What is the height of your fishtank in inches?\n");


width = promptNum("What is the width of your fishtank in inches?\n");





int volume = length * height * width;


int fish = floor(volume / 250);


float revenue = fish * 5.00;





float costs = costBuild(length, height, width)


+ costMaintain(length, height, width);


float profit = revenue - costs;





if (profit %26gt; 0)


printf("You had a PROFIT of %9.2f\n", profit);


else if (profit %26lt; 0)


printf("You had a LOSS of %9.2f\n", 0 - profit);


else if (profit == 0)


printf("Eh, you broke even. It could be a lot worse.\n");





return 0;


}





float costBuild(int length, int height, int width)


{


float cost;


// cost = [INSERT BUILD_COST FORMULA HERE]


return cost;


}





float costMaintain(int length, int height, int width)


{


float cost;


// cost = [INSERT MAINTAIN_COST FORMULA HERE]


return cost;


}





int promptNum(char* question)


{


printf(question);


int n;


scanf("%d", %26amp;n);


return n;


}
Reply:It is not that easy. May be you can contact a C expert. Check websites like http://askexpert.info/


C++ Input, output programming. PLEASE HELP!!!?

I'm currently writing a C++ program that reads in a text file and outputs certain things. So far, my program can read in the file then create a brand new file that contains the info from the first file (basically the new file is a duplicate of the first). Does anyone know how would I check for certain words or characters in the file? For example (several lines from the initial file):





SCALE3 0.0000000 0.000000 1.000000 0.000000...............


ATOM 1 N LYS A 2 -1.166 -1.878 1.710 1.00 0.00 N


ATOM 2 CA LYS A 2 -0.110 -1.837 0.660 1.00 0.00 C





These are three lines from the initial txt file. How would I do a check for the lines containing the word "ATOM" and print ONLY those lines to the output txt file. PLEASE HELP!!!

C++ Input, output programming. PLEASE HELP!!!?
first you need unformatted input. Assuming you're using an fstream, you could use either:


c=Myfile.get();


or Myfile.get(c);





(You can also get strings but that would be distracting.)





Now we have input we can woory about what we are going to do. Let's have an integer called State (as in state machines). Initialize it to 0.





while Myfile.good(){


c=Myfile.get();


if (c=='\n')





parse the next 4 letters for ATOM. If so, back up 4, set State to 2 and





while (State==2){


c=Myfile.get();


Outfile %26lt;%26lt; c;


if (c=='\n') State=0;


}





EDIT: other functions worth checking out on the fstream page cited below include putback(), which will rewind your file one char. Definitely use it at the end of the State==2 loop.





Of course if you are using FILE *InFile and fopen, fclose, and so forth from stdio.h (cstdio) you have fgetc(), and fread() for unformatted input, and fputc() and frwrite() for output.





fgetpos(FILE, *int) will put the position your position in a file into an integer -- useful when you want to fsetpos(FILE, *int) (okay, so they're not ints, they're fpos_t's.) In this case you would want to reset the file so you read atom, and you would want to reset it after getting a newline in State 2, which allows you to vet the next line in your text file.


(if you don't then in the above sample the second line with ATOM on it won't be read into the new file because when it would look for the A it would get a T).








That should work.





As you can tell I've been answering this when I'm tired. Sorry.


C++ Programming Help. Need a Program?

My problem to solve is:





The C++ standard template library contains a %26lt;string%26gt; class that can be used to handle strings. String functions that exist in the C library %26lt;string.h%26gt; are replaced by member functions of the %26lt;string%26gt; class. This project requires your own implementation of a simplified string class, called mystring. The class should contain all the basic string handling functions, as well as overloaded operators for some manipulations. All member functions should use basic operations. Make use of pointers where possible. Do not use functions from %26lt;string.h%26gt;.





A driver program must also be included to test all the functions. It should display a menu and complete instructions to the user.





Anyone whose willing to do this program just type the answer for the problem and post it. I will be proud that you made this programme for me. Pls Help. I need within 2 days

C++ Programming Help. Need a Program?
And I will be proud that you gave your paycheck to me.
Reply:You can find someone to help you from http://k.aplis.net/


Help with C++ programming?

Write a program that asks for the end user's name and for the scores on three class exams, each based on 100 points. If the average of the three exams carries a weight of 2/3 towards the final grade and the final-exam score carries a weight of 1/3 towards the final grade, the program ought to


A) ask for the end user's name (both the first and the last name)


B) greet the end user with his/her name,


C) Calculate the minimum score necessary on the final exam so that the end user will pass with a "C", not a "C-" nor a "C+"


and


D) print out the necessary score for the end user in a complete statement referring to the user by name.





note tha a C grade is from 73.0 to 77.0


I am a beginner, it will be better if you put basic codes.


Thank you

Help with C++ programming?
ok i wont write this all out for you but ill give you some pointers


i assume you know how to start off writing the program with you main function and all


so you are going to need to create some variables


you need a string for the first and last name so it might look like this





string strFirstName, strLastName;





then you need something for the test scores since this is a small program and dealing with huge numbers just use a double for these and have a different one for each grade you will work with





double dblTest1, dblTest2, dblTest3, dblTestTotal, dblFinal;





there are ways to do it with a lot fewer variables but im keeping it really simple





then you will need to get the information from the user. for this use cin and cout statements for example





cout %26lt;%26lt; "please enter your first name: ";


cin %26gt;%26gt; strFirstName;





repeat that for all of the info you need to get from the user





once you have all the info from the user you can get down to the math part. here is where i would suggest that you spend a few min thinking up a good equation like





finaltestscore = ((73 * 3) - ((test1 + test2 + test3) / 3 * 2));





i would need to know more about how your teacher wants all the rounding and such done to make it work the way she wants but this will get you on the right track





then when your done you just need a cout to output all of the info you need





cout %26lt;%26lt; strFirstName %26lt;%26lt; " " %26lt;%26lt; strLastName %26lt;%26lt; " you will need a score of: " %26lt;%26lt; dblFinal %26lt;%26lt; " in order to get a C for the class"%26lt;%26lt;endl;





you might also want to figure out the lowest avg that the user can have and still get a C and change the last line with an if / else statement





if you have any questions need help or want someone to check your code email me at aceofspades911@yahoo.com
Reply:I could answer this--for $20.
Reply:Do your own homework or you will get a C yourself.





I just fired someone yesterday because he couldn't write a proper code. I think he wished he had done his homework himself.





I decided to add written tests during interview because of this.
Reply:have you tried doing your homework on your own first? lol you know, i'm telling you this for your own good...C++ is a very difficult language...if you don't do your own homework (and/or projects), you will fail the course. what you're asking is not that complicated, so maybe you should try it first...you haven't even tried

night blooming cereus

C++ programming question?

I was doing this program on Visual Studio 2005 where the program converts C to F and vise versa but after debugging it, it doesnt give the expected result. Could someone tell me what is wrong with my code???








#include %26lt;iostream%26gt;


#include %26lt;iomanip%26gt;





using namespace::std;


using std::fixed;





int main()


{


int conversionType = 0;


double temp = 0.0;


double result = 0.0;





cout %26lt;%26lt; "Enter -1 (F to C) or 2 (C to F): ";


cin %26gt;%26gt; conversionType;


cout %26lt;%26lt; "Enter temperature: ";


cin %26gt;%26gt; temp;





if (conversionType == '-1')


{


result = (temp - 32) * 5 / 9 ;


}


else if (conversionType == '2')


{


result = temp * 9/5 + 32;





} //end if





cout %26lt;%26lt; "Result: " %26lt;%26lt; result %26lt;%26lt; endl;





return 0;


} //end of main function





--------------------------------------...

C++ programming question?
I'm not a c++ programmer but if your converstionType is an integer, why are you comparing it to a string? (conversionType == '2').
Reply:what the hell? ? Report It

Reply:what the hell? ? Report It

Reply:You're comparing the integer "conversionType" to a character in each of your if statements. Remove the quotes.
Reply:You are not pausing the prompt so that it can show the output. Add one of these


system ("PAUSE");


cin.ignore();


cin.get();


above return 0.





I use Dev C++, so I use system ("PAUSE"). You use something else, so these commands may not work. If they don't, then this definitely will.


It will hold the session until the user presses a key and since there is no more code after it, it will close the window.


Also, remove the quote or else it will return 0 regardless of what you put in.


#include %26lt;iostream%26gt;


#include %26lt;iomanip%26gt;





using namespace::std;


using std::fixed;





int main()


{


int conversionType = 0;


double temp = 0.0;


double result = 0.0;





cout %26lt;%26lt; "Enter -1 (F to C) or 2 (C to F): ";


cin %26gt;%26gt; conversionType;


cout %26lt;%26lt; "Enter temperature: ";


cin %26gt;%26gt; temp;





if (conversionType == -1)


{


result = (temp - 32) * 5 / 9 ;


}


else if (conversionType == 2)


{


result = temp * 9/5 + 32;





} //end if





cout %26lt;%26lt; "Result: " %26lt;%26lt; result %26lt;%26lt; endl;


char t;


cout%26lt;%26lt;"Press a key to end the session";


cin %26gt;%26gt; t;


return 0;


} //end of main function


C programming First Person Shooter?

In a first person shooter written in C++ (Unreal script), If i create a program to be looped with the game, like say a screen recorder, or a cheat, Will i need to know C++ to make something to run in it, or will C language be able to run with it?





Thanks

C programming First Person Shooter?
Both can work.
Reply:You might have to learn C++ as well.


C++ programming question?

Computer Program #4





Automobile suspension investigation





The vertical motion of an automobile after it has hit a pothole can be simply modeled using a one-degree-of-freedom dynamic equation. The solution to the simple model is given by





where,


and The parameters for a particular automobile are , and If we would like to know the first three times the car passes through the equilibrium point .





Write a C++ program that will find these three times unassisted by human intervention. That is, the program should search the function starting at t = 0.0 using the incremental search method until it finds an axis crossing. Then the program should use an appropriate method to converge on the crossing point until it is accurate to within seconds. Once the first time is found, the program should revert back to the incremental search method to find the second and third crossings using the same methodology.

C++ programming question?
Go and ask ur computer teacher..this pgmis way above wat i know as i just passed out frm 12th
Reply:i could not find any equation in the problem ..


C Programming Question?? Help!?

I need help writing a program in C language that finds twin primes... A twin prime is a prime number that differs from another prime number by two....this is how the program should work.








Please enter how many prime numbers you want the program to find: _





*** then the user enters for example 3.


the program writes:





2 is prime but not a twin prime.


3 is prime but not a twin prime.


4 is not prime.


5 is prime and is a twin prime in the prime pair 3, 5.


6 is not prime.


7 is prime and is a twin prime in the prime pair 5, 7.


8 is not prime.


9 is not prime.


10 is not prime.


11 is prime but not a twin prime.


12 is not prime.


13 is prime and is a twin prime in the prime pair 11, 13.





so the program found and wrote 3 twin primes.








PLEASE HELP!! THANK YOU.

C Programming Question?? Help!?
It is very easy, use a for loop


for(i=2;i%26lt;n;i++)


if(number%i == 0)


/* number is not prime */


..


}
Reply:First find the primes. Try using the method used in the sieve of Aristophanes. You can modify that method to fit your needs. Then find the twins.





The research and programming is left as an exercise to the reader.
Reply:lol ECS30, UCD?


If you know exactly what I am talking about in the above question then I can give a few intentionally vague hints (to protect my own self). If that first question didn't make any sense then disregard my entire post.





1.) You should have a book . . . the program found on page 162 will be helpful. Specifically the function in the first part of it tests whether or not numbers are prime. If you do not know what a function is then read from the beginning of the chapter until that page.


2.) By modifying the prime.c found on the webpage (not the one in the book) and adding in the function you have essentially all that you need. Just add another "if" statement (to the body where the results for prime numbers are) that tests whether (prime number - 2) is prime using the function. (So if prime number - 2 is prime, you know that the number is a twin prime, if not then the number is just prime)


You also need to add variables to count: the number of integers you went through, the number of primes, and the number of twin primes.


3.)I found this post when I was stuck earlier. Spent time a lot of time trying to do it with arrays according to one of the responses, you don't need any arrays at all.





Sorry but that is as much as I feel safe discussing since I don't know how much we're allowed to help each other. It took me literally 12 hours to do because I missed a few lectures and haven't been reading, but hopefully you are better prepared and will finish on time.
Reply:The best help I can offer is the suggestion to pay attention in class and do the reading. This is an easy problem, but I'm not going to do the entire assignment for you.





You need an algorithm to determine if a number is a prime, and a strategy for keeping track of the primes. You could keep an array of primes you've found so far and use that to find twins, or you could ask for every value N that is prime, if N-2 is prime. That would be easier, unless your assignment requires you to do it a certain way.





Other than that the rest is easy. You have probably covered all this in class. Good luck.
Reply:lawl

orchid cactus

C Programming "for" statement?

hi folks


write a c program that will accept 10 integers("99, 80, 50.. something like that...that ranged from 1-100 only, then the machine should determine the value if it is divisible by 3 or not, the program should also determine how many integers were divisible by 3 use for statement.





here's what ive done please help me continue it hehe


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


main()


{


int a,b,c;


clrscr();


printf("Divisible or not divisible by 3");


printf("Input an integer: ");


scanf("%d", a);


for(a=1;a%26lt;=10;a++)

C Programming "for" statement?
#include %26lt;stdio.h%26gt;


main()


{


int a[10], i, count;


count=0;


clrscr();


printf("Divisible or not divisible by 3");


printf("Input 10 integers: ");


for (i=0;i%26lt;10;i++)


{


scanf("%d", a[i]);


while(a[i]%26lt;=0 || a[i] %26gt;=100)


{


printf("Please enter number 1-100 only\n");


scanf("%d", a[i]);


}


}


for(i=0;i%26lt;10;a++)


{


if(a[i]%3==0)


{


printf("%d is divisble by 3\n", a[i]);


count++;


}


else


printf("%d is divisble by 3\n", a[i]);


}


printf("%d numbers are divisble by 3", count);
Reply:just looking at yours and the 1st answer, scanf()


requires an %26amp;.. scanf("%d",%26amp;a) or scanf("%d",%26amp;a[i])


C++ programming, Error E2194; could not find file hello.cpp?

I am trying to run a simple program and I've installed Borland C++ compiler for free on my computer. The code is supposed to simply write Hello World, on the screen in the command prompt box. The book I have tells me to type in bcc32 hello.cpp into the command prompt box to run the program, but I get the error message. It recognizes the bcc32 command, but then runs the E2194 message. I had to change the path in environment variables first since the bcc32 was not recognized at first, but after changing the path, this works. I have also created the two necessary text files bcc32.cfg and ilink32.cfg. The path is c:\Borland\Bcc55\Bin. I have the hello.cpp program in what I think is the right spot, but it seems to not be able to find it. Can anyone help me. I need to know how to tell the computer or program where to "look" for this file.

C++ programming, Error E2194; could not find file hello.cpp?
Borland is outdated!





Get a better compiler, like Dev-C++ (it's free, see sources).


Once you've installed it, click File (toolbar) %26gt; New %26gt; Project...


From there it'll give you a few program types.. (you can click the 'Introduction' tab for the Hello World example).





Have fun,


Dys.
Reply:dys is right you know dev-c++ rocks


C Programming Language: Using Recursion to Print the Fibonacci Series?

The Fibonacci series





0, 1, 1, 2, 3, 5, 8, 13, 21, …..





begins with the terms 0 and 1 and has the property that each succeeding term is the sum of the two preceding terms.





For this problem, we are asked to write a recursive function fib(n) that calculates the nth Fibonacci number. Recursion MUST be used.





In an earlier problem, we where asked to do the exact same thing, except we where to NOT use recursion. For that problem, I used the following code (between the dotted lines):





--------------------------------------...





main()


{


int c=1,f=0,s=1;


int i;


printf("%d%20d\n",f,f);


printf("%d%20d\n",s,s);


for (i=2; i%26lt;5||f%26lt;s; i++)


{


c=f+s;


f=s;


s=c;


printf("%d%20d\n",i,c);


}


}





--------------------------------------...





Which gave the correct output:








0 0


1 1


2 1


3 2


4 3


5 5


6 8


7 13


8 21


9 34


10 55


11 89


12 144


13 233


14 377


15 610


16 987


17 1597


18 2584


19 4181


20 6765


21 10946


22 17711


23 28657


24 46368


25 75025


26 121393


27 196418


28 317811


29 514229


30 832040


31 1346269


32 2178309


33 3524578


34 5702887


35 9227465


36 14930352


37 24157817


38 39088169


39 63245986


40 102334155


41 165580141


42 267914296


43 433494437


44 701408733


45 1134903170


46 1836311903


47 -1323752223














While I was able to come up with a code that works nonrecursively, I am not sure how to write a program that will print out the Fibonacci series by using recursion. Help would be greatly appreciated.

C Programming Language: Using Recursion to Print the Fibonacci Series?
That's interesting. Usually they have students try these methods in the opposite order, to show that recursive algorithms can be transformed into non-recursive ones.





The way to solve this is by going back to the mathematical definition of the Fibonacci series:


f(1) = 1


f(2) = 1


f(n) = f(n-1) + f(n-2)





So, to find a particular number in the Fibonacci series, you just need to calculate the previous two numbers and add them together.





If you take that last formula and simply translate it into a C function, you'll be most of the way there. Don't forget to treat n=1 and n=2 as special cases.
Reply:Simple: this is in my book:





//Begin function Fibonacci





int Fibonacci(int n)


{


if(n==0||n==1)


return 1;


else


return Fibonacci(n-1)+Fibonacci(n-2);


}





//End function Fibonacci
Reply:#include %26lt;iostream%26gt;





int main()


{


//define first two fibonacci series numbers.


int fib1 = 0;


int fib2 = 1;





//declare the variable to store the next number of fibonacci series


int fib3;





//declare the variable to store how many numbers to be printed. Default is 2.


int numbers = 2;





//the counter to keep track how many numbers are printed.


int counter = 2;





//Ask user how many numbers of the fibonacci series need to be printed.


std::cout %26lt;%26lt; "How many Fibonacci number you need ? : " ;





//Store the number.


std::cin %26gt;%26gt; numbers;





//If number entered is less than 3, exit the program.


if (numbers %26lt; 3) return 0;





//Print the first two element.


std::cout %26lt;%26lt; fib1 %26lt;%26lt; "\t" %26lt;%26lt; fib2;





//do-while loop to calculate the new element of the series and printing the same.


do {


counter++;


fib3 = fib1 + fib2;


std::cout %26lt;%26lt; "\t" %26lt;%26lt; fib3;


fib1 = fib2;


fib2 = fib3;


} while (counter %26lt;= numbers);





std::cout %26lt;%26lt; std::endl;


system("pause");


return 0;


}