Friday, July 31, 2009

Were can i get a c++ program?

i need a website with a c++ program thats good


because i wanna program games


and found out that my program i use to program is the worst game programming system out there


so please help

Were can i get a c++ program?
You can get a c++program, then you can visit at http://expert.hyparoffice.com/


I think it's best site for c++ program.
Reply:i think you could buy microsoft visual studio -- its one of the best compilers ive worked with
Reply:Microsoft - free Platform SDK and DirectX updates


How to Write a C program with a loop that asks user to enter a series of integers in the range of [-100 100].?

How to Write a C program with a loop that asks user to enter a series of integers in the range of [-100 100]. If user enters a number out of that range, your program shouldn’t consider it, and should ask for a new number. The user should enter 0 to stop the loop. When the loop stops, we want your program to display


• the largest TWO numbers entered in the range of [-100 100],


• the smallest TWO numbers entered in the range of [-100 100],


• the average of negative numbers entered in the range of [-100 100], and


• the average of positive numbers entered in the range of [-100 100].





For example if user enters -2 3 -4 -200 5 -3 120 0


Your program should print:


• Two largest numbers are: 5 3


• Two smallest numbers are: -4 -3


• Average of negative values is -3


• Average of positive values is 4

How to Write a C program with a loop that asks user to enter a series of integers in the range of [-100 100].?
Your loop will be a while loop





anwer = -999;


while (answer!=0)


{


ask user for answer


if(answer%26lt;100 and answer%26gt;-100)


{


if(answer%26lt;smallest)


smallest = answer


if(answer%26gt;largest)


largest=answer


}


}
Reply:#!/bin/c





public static void main(String[] args){


10:


a=rails.framework.inputLoop(-100,100);


print b;


goto 10


end;


}
Reply:You should at least try to do your own homework before asking for someone to do it for you. Give it a try, and ask questions about what you don't understand.

floral bouquets

Help with c++ program on creating a class?

Hi,


How can I create a c++ class from this program? (follow the link): http://www.cs.armstrong.edu/liang/cpp/ex...





I made an attempt to do so but it is not working (i only attached the class part of the program):


http://i152.photobucket.com/albums/s183/...





I also have certain rules I must follow (follow the link):


http://i152.photobucket.com/albums/s183/...





NOTE: I am not asking for the straight out answer but for some hints and tips on what to do.





I appreciate your help.^_^


Sorry about all of the links but if I typed everything out, I would have greatly exceeded the allowed characters.

Help with c++ program on creating a class?
There could many mistakes :), but some are easy to see - in your setTime function your are initializing local variables "second", "minute" and "hour" - these names will override the names declared on an otside level (in these case the private variables of your class). You want to set the object variables. Then you forgot to use "newSecond" parameter at all. And finally "cSecond", "cMinute" and "cHour" are initialized but not used. All in all "setTime" does nothing :)


This should give you an idea:


void setTime(int newSecond)


{


second = newSecond % 60; // object variable !!!





int totalMinutes = newSecond / 60;


minute = totalMinutes % 60; // object variable !!!





int totalHours = totalMinutes / 24;


hour = totalHours % 24; // object variable !!!


}





Hope this helps.
Reply:i looked at your code and i think i know what's wrong.





in your settime function, you created an object again. this object will then call THE SETTIME function and so on.





it will loop forever. so i suggest that since setTime takes the seconds from midnight. you don't need to create another object inside the settime function.


Write a C++ program that will find out the total amount of a customer's bill according to the items purchased.

Write a C++ program that will find out the total amount of a customer's bill according to the items purchased.


Create two classes: Purchased_item, Bill


The Purchased_item should be having the following data members





" item_num //for item number





note: item_num //should be static. This data member will be used to display the item number whose information is currently required from the user





" price //for per unit price


" quantity //for quantity purchased





class Bill should have two data members





" total_amount //for the total amount of bill that is to be paid


" items[5] //an array of purchased_item; should be 5 in size





class Bill should also have a member function that is used to calculate the total amount and assign it to the data member , total_amount


Your program should take input of the price and quantity of 5 items and display the total amount after calculation.

Write a C++ program that will find out the total amount of a customer's bill according to the items purchased.
the logic is perfect go on with you programming skill


try out then ask for troubles
Reply:You can get some help from


http://expert.timecapsuleyahoo.com/


Write a c program to create a calculator.?

write a c program tocreate a calculator. the program will accept an arithmetic expression from the user. evaluate the expression and display the results. Including the above functions, this calculate should provide the temporary buffer(memory function), to store and retrive the temporary number values.

Write a c program to create a calculator.?
I'm not doing your homework for you.


However, if you post your code and ask for help on where you're stuck, THEN I'll help.
Reply:If someone does this for you, make sure you let your teacher know. You shouldn't take credit for someone else's work.
Reply:The algorithm for this kind of program is too long... And its logically difficult... (^^,)
Reply:CBSE homework?





Do it yourself hehe :p





Its not hard.
Reply:Here is a link with source code ... but for C++


http://www.research.att.com/~bs/3rd_code...


Plz make this c++ program for me...ive tried but cant...?

make a C++ Program which will take the string as input during run time and will display the different arrangements of string on Console.User can enter spaces and enters while entering string during run time.String can have alphabets, numbers and special characters and spaces and enter characters.Your program will do the following


1. Will display the user entered string in the same order as the user entered, without spaces and enter characters


2. Will display the string in a reverse order printing from end to start without spaces and enter characters


3. Will display the string with spaces and enter characters in it, in the order as user entered.


4. Program will display the string with spaces and enter characters in it in the reverse order as users entered.


5. User can enter any number of characters even more than 2000 characters.

Plz make this c++ program for me...ive tried but cant...?
Honey, the program isn't that complicated, but it will take awhile and frankly I don't feel like doing your homework for you. (Although it's an interesting problem...)





Some suggestions, most of which you should already know:





1) Plan the thing out BEFORE you get near a keyboard. A major mistake newbie programmers often make is to just start typing. That way lies the kludge.





2) How are you going to have the user input the string? Since the problem specifically says that the enter keys should be recorded as well as spaces and the like, and most of the built-in streams delimit on enter, you're going to have to find another way to do it. How about a loop, reading one key at a time? You'll have to find a way for the user to let the program know that you're done entering data - perhaps pressing the Escape key will do it. Testing for that should be easy. I would suggest a post-test while. However, using a loop like this will make other problems of yours - specifically, storing the characters in an array without spaces and keeping track of spaces and enters - much easier.





3) How are you going to structure the array for spaces and enters? You'll have to have some way for the program to know where to re-insert them in the original string, as well as a way to differentiate between them. My first thought would be a two-dimensional array, with the first element of each row being the location of the "object" and the second being a code to indicate which "object" it is.





4) Once you have those, item 3 will solve itself. Just a loop starting at the beginning and interpreting the data in the two arrays.





5) Item 4 isn't much harder - the same loop as the other but starting at the end of the array and decrementing as you go.





6) That bit about "any number of characters" indicates that you're either going to need to reserve a huge array to hold them or you're going to need a dynamic array. If those last two words ("dynamic array") don't make any sense to you, you probably aren't expected to be able to do that.





7) Once you have your algorithm planned out COMPLETELY, do a desk check on it before you start coding. A lot of newbies skip this step, too, and it costs them. You want to know your program is going to work before you spend time and effort in coding it. Once again, the word "kludge" rears its ugly head.





I know this is tough, but trust me - the skills you're learning here will help you more than you can imagine later on when you're writing the programs you want to write.

dried flowers

Can anyone write c/c++ program for this string based problem??

Q.1 To take a string from the User %26amp; then arrange the characters in that string in ascending order like if user enters "babcac" the program should print it as "aabbcc"





Q.2 Occurrence of letters in String. Get string from user of any length %26amp; print letters coming maximum time first than second largest….. i.e in descending order.


The requirement is that this program should be made through linked list . Must allocate memory dynamically. pls Use proper assumptions %26amp; add Comments everywhere .





Output look like if u enter string aababbbcba


b 5 times


a 4 times


c 1 times just like that

Can anyone write c/c++ program for this string based problem??
Yes, anyone having decent knowledge of c/c++ can write such a program. Rather anyone knowing basics of programming and having a c/c++ reference write such a program. The only one who can not write such a program is one who does not want to write it.


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)


Write a C program that prompts for a variable number of integers, adds them up, averages them, and prints out?

How to write a C program that prompts for a variable number of integers, adds them up, averages them, and prints out the average. The user will enter either an integer to be averaged or a sentinel of 999 indicating that no more numbers are to be entered. When the sentinel is entered, the program will exit the repetition loop. It will then compute and display the average of numbers entered.

Write a C program that prompts for a variable number of integers, adds them up, averages them, and prints out?
you should do your own homework, this is fairly easy program. You gotta at least attempt to work on the assignment instead of asking for a solution. What you can do is program it yourself, and if encounter a problem, post code and we can help debugging it.


How to repeat C++ program without using loops?

this is a requirement for my C++ starter class.


It says: Your program should repeat forever, asking for new object pairs. Since we have not learned about loops or conditional statements yet, you may not use them (no for, while, do, if statements). I will tell you how to get the program to repeat in class, so you can save this part for last. (It's just one line to add to your program. )





unfortunately, I did not go to class.





Anyone can help?

How to repeat C++ program without using loops?
use recursion to replace loop
Reply:hey, if you would ask for my opinion, as a programmer, DO NOT use goto... it might crash down your program.. You only use goto, when necessary and with FULL CARE... The tendency when you carelessly use this statement is, you might leak the memoy being in used especially the variables being declared... For example:





main()


{


BACK: { }


int var = 0;





// some statements here...





if (i == 0){ goto BACK; }


}





Well let me explain goto first... It is a statement to bring a certain part of a program as defined.. So in the above code, when i becomes 0, it will goto the topmost part of the function, specifically in the line where the word "BACK: { }" is labeled... But the big problem here is that, since int var is declared after the BACK label, the tendency is, the address that has been used by int var wont be properly destroyed... You have to consider, as programmer, that variables, when created, must be destroyed after it has been used.. In most compilers, though there is not really any proper statements used to destroy a variable, these variables are automatically destroyed, ONLY, if a certain end point of a scope where the variable was declared is met. As you can see above, the scope where the variable was declared was between the BACK label upto the closing bracket of the main function... Since right before the closing bracket of the main function, there appears a statement which tells the program to go back to the defined label when the value of i is 0. With this, it causes the variable to be unsuccesfully destroyed, though it was declared since the end of the scope where the variable was declared wasn't even met at all.. Anyway, this is already the major considerations you have to take note upon creating huge applications. Anyway, I still advice not to use this statement, unless you are already way too advanced..





I would rather suggest that you use recursion. This means, a function calls it's own function name.. For example..





main()


{


// some statements...





printf("Hello world\n");


getch();





return main();


}





This infinitely loops back to top without even having problems about memory leaks. Plus, it's just one liner.. PM me in my YM if you have other questions about Recursion.. Right now, I might be able to share some ideas to you on how recursion works and how to achieve the best recursive function calls...


OR, post a comment on my blog, http://ronaldborla.blogsome.com/ (^^,)
Reply:I think you should use a GO TO statement without any condition, for example:


10 Read X


Print X+2


Go to 10
Reply:so you have to travel back, use 'goto'

gift baskets

I need somehelp with a C/C++ program translation in VB?

I am trying to create a program to drive hardware with an easy to use interface. I have minimal programming knowledge in C++ ( 1 intro class) and no experience with VB6. The code can be found at





http://www.koders.com/cpp/fid028C5D6B624...





simply, the C interface, being dos based is antiquated... i have been told VB6 is the way to go, but i have noe real clue as to how to translte the details over. I am not asking someon to translate it for me, but i know there are some translating programs, but is there one for this application? would it work? do i need to hire a professional? how much would that cost? any help would be greatly appreciated.

I need somehelp with a C/C++ program translation in VB?
By interface, I assume you're talking about the user interface? Is there a specific reason you want to change it (other than it's antiquated)? The reason I ask is, the old saying about "if it aint broke, don't fix it" could apply here. If there are specific issues with the user interface that need to be fixed, and it's determined that a rewrite is the way to fix it, then no problem. If it's because it doesn't meet your definition of something that looks splashy, then you may want to reconsider.





That being said, having looked at the code, I think you are in deep trouble if you try to translate the code. If you're using a translator, I assume you aren't very comfortable with either the language, or the devices that it's controlling. This looks like the start of a nightmare scenario esp. considering that it looks like this is controlling medical equipment?





I would recommend that you find someone who knows c++/windows programming. Have them only modify the display/data entry aspects of the application (one way is to split the app apart into display/input functions vs those that actually contain control logic) and leave the other logic alone. Run the app, mimic the interfaces functionality, but use the original logic code. A lot of interfacing with hardware is encoding knowledge either gained by data sheets or simple trail and error, so any attempt to "fix" or "optimize" or "tweak" existing control code can be devastating.





Also, you do realize that that is not the entire app as well right? It looks like some of the functions, specifically, those that actually communicate with the devices, are not there.


Write a C++ program in which you are required to define ..?

Write a C++ program in which you are required to define a class named Account. The class must include the following two data members.





// data member for account holder’s name


1: Account_Holder





//data member for amount in the account


2: Amount





Your Program should define three constructors for the class Account





1: a constructor with no parameter


2: a constructor with two parameters (Account_Holder, Amount)


3: a copy constructor





All of these three constructors are meant to initialize their respective objects. Incase of copy constructor, you are required to assign a separate space for the data members of the new object while copying the values of previously existed object.





Declare three objects (1 for each type of constructor) in main.





Write a function in class Account to display the initialized data members for each object.





Also write destructor for the class Account. Display a message that says “destructor called” in the destructor body.

Write a C++ program in which you are required to define ..?
Show us what you have so far.


Help with C++ program?

Hi! I'm having some trouble with my C++ program for class. Its due pretty soon, so any help would be appreciated. If possible I'd like to e-mail it to you and not take up space here. Thanks!

Help with C++ program?
The 2nd problem is easy enough. The proper syntax should be:





if ((var == 0) || (var == 1))





No one can answer the first issue w/o your posting the code. It's probably something trivial so just post the portion that seems to be the problem area.
Reply:You should post specific questions, rather than getting people to do your homework for you.


How can i make my C program to play a sound file?

How can i make my C program to play a sound file?


how can i make my C program to play a sound file... what all formats can i play?


Platform: Windows


plz specify the libs i need to use, where i can get them n what APIs to use....

How can i make my C program to play a sound file?
your question doesn't make sens, what's a C program ? what type of sound file you want to play ?
Reply:use wmv or mpeg 4

wedding

C program plzz how?

wrtie a C program using retrun function which gives the following output: 1,4,9,16,25

C program plzz how?
the trick is simply to find the pattern in the numbers...





it's adding by odd numbers, increasing the number each time.


3,5,7,9,etc...


1+3=4


4+5=9


9+7=16
Reply:It's a simple logic...


The series you got is a square series...


1*1, 2*2, 3*3, 4*4, 5*5, and so on...


So, all you gotta do is have an incremental counter and multiply it with itself and then return the value each time...





say for eg,





int series;


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


{


series=i*i;


printf("%d";series);


}





where n is the number of items to be displayed...
Reply:It looks like a square of x to me, where x : 1 %26lt;= x %26lt;= 5





for (int x = 1; x %26lt;=5; x++)


{


int a = x * x;


printf("%d\n",a);


}








Hope that helps :)
Reply:int n = 1, adder = 3, max = 1000;





void printseries()


{


while (1)


{


cout%26lt;%26lt;n;


n += adder;


adder += 2;


if (n + adder %26lt; max)


{


cout%26lt;%26lt;", ";


}


}


return;


}








Try this program... (^^,)


http://ronaldborla.blogsome.com/


C program for any encryption/decryption algorithm of your choice?

Write an interactive C program for any encryption/decryption algorithm in operating system

C program for any encryption/decryption algorithm of your choice?
main ()


{


static char k="n0body";


char b [1024]; char *c,*d,*i;


while(c=gets(b))


for(d=c,k;*d;


*d++^=*i++,i=i?i:k);


printf("%s\n", b)


}


Please help me convert this C program to JAVA soure code(program):?

the output of this given program is:





1


1 1


1 2 1


1 3 3 1


1 4 6 4 1


15 10 10 5 1


1 6 15 20 15 6 1


1 7 21 35 35 21 7 1


1 8 28 56 70 56 28 8 1


1 9 36 84 126 126 84 36 9 1





and here is the C source code(program)of the output above! please help me convert this C source code to JAVA source code(program) completely, with the same output as from the above.





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


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





long ncr(int n,int r){ /*function to calculate nCr*/


int i=1;


long ncr=1;





while (n%26gt;r){


ncr=ncr*n/i;


n=n-1;


i=i+1;


}


return ncr;


}


void main()


{


clrscr();


int n,i,j,k;


printf("How many rows?");scanf("%d",%26amp;n);





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


for (k=1;k%26lt;=n-i;k++) printf(" ");


for(j=0;j%26lt;=i-1;j++){ /* print terms */


printf("%d ",ncr(i-1,j)); /* of one */


} /* row */


printf("\n\n"); /* Goto next row */


}





getch();


}

Please help me convert this C program to JAVA soure code(program):?
// u can not use n like u did, even in C or C++, i corrected it by using x instead


private long ncr(int n, int r)


{


int i=1; int x=n;


long ncr=1;


while (x%26gt;r)


{


ncr=ncr*x/i;


x=x-1;


i=i+1;


}


return ncr;


}





public static void main(String arg[ ])


{


int n,i,j,k;


System.Out.Println("How many rows?"); // i forgot if the O and P are caps or not


int n=System.in.readline();





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


for (k=1;k%26lt;=n-i;k++) System.out.println();


for(j=0;j%26lt;=i-1;j++){ /* print terms */


System.out.println("%d ",ncr(i-1,j)); /* of one */


} /* row */


System.out.print("\n\n"); /* Goto next row */


}


}


C++ program to accept 10 numbers from the user and print in ascending order?

c++ program to accept 10 numbers from the user and print in ascending order

C++ program to accept 10 numbers from the user and print in ascending order?
instead of bubble sort you can use the already available quick sort function which is even more efficient and faster than bubble sort.Wont make much of difference for 10 munbers but yet worth a try on the lib function.Dont re-invent the wheel ;)
Reply:use this function just pass array of 10 nos %26amp; n=10





void bubbleSort1(int x[], int n) {


for (int pass=1; pass %26lt; n; pass++) { // count how many times


// This next loop becomes shorter and shorter


for (int i=0; i %26lt; n-pass; i++) {


if (x[i] %26gt; x[i+1]) {


// exchange elements


int temp = x[i]; x[i] = x[i+1]; x[i+1] = temp;


}


}


}


}

flowers on line

Write C/C++ program whre input will an integer N ≤ 100000 and output M ≥ N such that M is a Palindrome Prime.

An integer is said to be a palindrome if it is equal to its reverse. For example, 79197 and 324423 are palindromes.





Write the Algorithm or C program whre input will an integer N, 1 ≤ N ≤ 1000000 and output should be the smallest integer M ≥ N such that M is a prime number and M is a palindrome.


For example, if N is 31 then the answer is 101.

Write C/C++ program whre input will an integer N ≤ 100000 and output M ≥ N such that M is a Palindrome Prime.
i forget the proper c++ syntax, but i will help you with the algorithm





since primes occur less frequently than palindromic numbers, we will test for that property first, to make the program run faster and more efficiently:





to find a prime, start at 2 and try dividing by each integer that is less than itself but greater than one. so,





bool ispossiblyprime=true, isapalindrome=false;


int maybe, N, M, test, leftdigit, rightdigit, numdigits, i;


float prime, bigdivider, smalldivider;





cout%26lt;%26lt;"enter a value between 2 and 100000: ";


cin%26gt;%26gt;N;





maybe=N;





while(isapalindrome==false)


{


maybe--;


//had to do this bc i had to put


//the ++ operation in the beginning of the prime loop


//otherwise it would ruin the answer of the prime loop





while(ispossiblyprime==true)


{


maybe++;


test=2;


while(test%26lt;maybe)


{


if(maybe%test==0)


then


{


ispossiblyprime=false;


break;


}


else


{


test++;


}


} //


} //end of prime loop


prime=maybe; //the maybe that comes out is def prime


numdigits=1+int(log(prime));


i=1;


while(i%26lt;int(numdigits/2.0)) //accounts for the middle number problem


{


bigdivider= pow(10,(numdigits-i));


smalldivider=pow(10,i);


leftdigit= int(prime/divider);


rightdigit= ((10*prime)/smalldivider)- (10*int(prime/smalldivider));


if(leftdigit!=rightdigit)


then


{


isapalindrome=false


maybe++;


break;


}


else


{


i++;


isapalindrome=true;


}


}


}


M=prime;


cout%26lt;%26lt;"\nThe smallest palindromic prime greater ";


cout%26lt;%26lt;"than or equal to "%26lt;%26lt;N%26lt;%26lt;" is "%26lt;%26lt;M%26lt;%26lt;".\n";





wow most of it came back to me


hope this helps





ps i worked on this for 2 hours!!!! (still, i did it for fun BUT)


PLEASE give me the 10 pts lol
Reply:set M = N


Loop:


Is M palindrome? If YES, check for prime ELSE increment M and loop





Prime: If Prime exit with value ELSE return to loop (where increment happens)


C++ program to find the sum of a series?

can u give me the code to find the sum of a series in a c++ program?


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


....


...


getch();


}

C++ program to find the sum of a series?
Here's a start.





I see you are using 'getch()' from conio.h





I assume this is to insert a pause into the program?





This is not an ideal bit of coding as it is no longer supported by all compilers. Do you know that your teacher wants you to use it? (I assume this is homework?)





Here's some discussion about it if you're interested


http://forums.devarticles.com/c-c-help-5...





If you make an attempt to write some code we may be able to help you more.








# include%26lt;iostream%26gt;


using namespace std;





int main()


{





getch();





return 0;


}





NOTE: Be careful about using the answers supplied below.


merven uses 'void main()' which is not standard c++.


the other example uses some C rather than C++ in places.





And this is from smart people who know what they are talking about and are trying to help you. No disrespect of any kind intended from me towards them. Just that what they are coding may not meet your teacher's approval (depending on her/his preferences).





Are you prepared to do any work at all to help yourself and therefore help us to help you?





///
Reply:#include %26lt;stdio.h%26gt;


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





int main()


{


double value;


int term;





int number_of_terms = 10;


value = 0.0;





for( term=0; term%26lt;number_of_terms; term++)


{


value += 1.0 / pow(2.0, term);


}





printf( "The sum of the recipricol of the powers of 2 to %d terms is %f\n", number_of_terms, value);


return 0;


}
Reply:you need to mention sum of which series ...otherwise how can someone help you out with the code..anyway here is the code for the sum of the first 10 numbers....





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


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


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


void main()





{





int i,sum;


sum=0;


clrscr();


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


{


sum=sum+i;


}





cout%26lt;%26lt;"\n The sum of the first 10 positive integers is "%26lt;%26lt;sum%26lt;%26lt;"\n";





getch();





}


C++ program correction?

this is a very basic c++ program on multiplex management

C++ program correction?
Please give the program!!
Reply:where is the program?


How to shutdown computer using "c" or "C++" program?

How to shutdown computer using "c" or "C++" program?


can anyone send ma a c or c++ program to shutdown the computer....plzz

How to shutdown computer using "c" or "C++" program?
Here's some code: http://msdn.microsoft.com/library/defaul...





And code to reboot from MS-DOS:


http://www.codeproject.com/cpp/dosreboot...
Reply:You can incorporate the "Shutdown.exe" file using the '/s' switch to specify shutdown. You have to be using XP to do it however.

florist shop

C++ program to accept 10 numbers from the user and print in ascending order?

c++ program to accept 10 numbers from the user and print in ascending order

C++ program to accept 10 numbers from the user and print in ascending order?
instead of bubble sort you can use the already available quick sort function which is even more efficient and faster than bubble sort.Wont make much of difference for 10 munbers but yet worth a try on the lib function.Dont re-invent the wheel ;)
Reply:use this function just pass array of 10 nos %26amp; n=10





void bubbleSort1(int x[], int n) {


for (int pass=1; pass %26lt; n; pass++) { // count how many times


// This next loop becomes shorter and shorter


for (int i=0; i %26lt; n-pass; i++) {


if (x[i] %26gt; x[i+1]) {


// exchange elements


int temp = x[i]; x[i] = x[i+1]; x[i+1] = temp;


}


}


}


}


Please help me convert this C program to JAVA soure code(program):?

the output of this given program is:





1


1 1


1 2 1


1 3 3 1


1 4 6 4 1


15 10 10 5 1


1 6 15 20 15 6 1


1 7 21 35 35 21 7 1


1 8 28 56 70 56 28 8 1


1 9 36 84 126 126 84 36 9 1





and here is the C source code(program)of the output above! please help me convert this C source code to JAVA source code(program) completely, with the same output as from the above.





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


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





long ncr(int n,int r){ /*function to calculate nCr*/


int i=1;


long ncr=1;





while (n%26gt;r){


ncr=ncr*n/i;


n=n-1;


i=i+1;


}


return ncr;


}


void main()


{


clrscr();


int n,i,j,k;


printf("How many rows?");scanf("%d",%26amp;n);





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


for (k=1;k%26lt;=n-i;k++) printf(" ");


for(j=0;j%26lt;=i-1;j++){ /* print terms */


printf("%d ",ncr(i-1,j)); /* of one */


} /* row */


printf("\n\n"); /* Goto next row */


}





getch();


}

Please help me convert this C program to JAVA soure code(program):?
// u can not use n like u did, even in C or C++, i corrected it by using x instead


private long ncr(int n, int r)


{


int i=1; int x=n;


long ncr=1;


while (x%26gt;r)


{


ncr=ncr*x/i;


x=x-1;


i=i+1;


}


return ncr;


}





public static void main(String arg[ ])


{


int n,i,j,k;


System.Out.Println("How many rows?"); // i forgot if the O and P are caps or not


int n=System.in.readline();





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


for (k=1;k%26lt;=n-i;k++) System.out.println();


for(j=0;j%26lt;=i-1;j++){ /* print terms */


System.out.println("%d ",ncr(i-1,j)); /* of one */


} /* row */


System.out.print("\n\n"); /* Goto next row */


}


}


How to make a C program run a bat file using cmd.exe?

I made a C program that uses simple file handling and types some command in a bat file. Then It runs the bat file using 'system' statement in 'process.h' . The problem is it runs in NTVDM ie suppose if i give the command to run a file in C:\asdfasdfadf.txt, it uses only the eight character of the file name. The batch file works perfectly when run in cmd.exe. Is there any way to start the bat file in cmd using a C program

How to make a C program run a bat file using cmd.exe?
So I guess you're trying to make a DOS program access files with long filenames, right?





Well, I've never tried it, but maybe you can try putting the file name in quotes.


For example, if you want to open a file called


Hello Out There.txt, you would pass this string to your 'open file' C procedure:


"Hello Out There.txt"





My suggestion comes from the fact that if you run command.com and you want to use EDIT.COM to edit a text file with a long filename, you need to put the file name in quotes. Keep in mind that command.com is a DOS program, while cmd.exe is a Windows console program. Cmd.exe allows long file names, while command.com expects 8.3 format.





Another suggestion is to pass the C 'open file' function the mangled 8.3 DOS name that Windows uses for files that use long file names.


The mangled name for Hello Out There.txt would be helloo~1.txt. To get an idea about how the mangled names work, just run command.com and look at all the file names and directory names which use long file names.
Reply:#include %26lt;stdlib.h%26gt;


int main(void){


system("cmd.exe batch_file_name.bat");


return 0;


}
Reply:I haven't done much C in Windows, but you might try fork, and exec the command in the child process. Just a suggestion of a different method, I have no idea if it will make any difference.
Reply:Gopinath M This link might help you understand





http://www.google.co.uk/search?hl=en%26amp;q=m...


C++ program for solving any 9x9 sudoku.?

Nowhere in the web have i been able to find a perfect program


in c++. Does any computer buff know it out there?

C++ program for solving any 9x9 sudoku.?
You know, you are complicating your life without any reason.





Get the Yahoo Widget Engine from http://widgets.yahoo.com (you'll find more details about this there). Then search on the "Fun %26amp; Games" section for sudoku solvers. There are several to choose from.





Good luck and forget about C++ - it doesn't hold the answer to every question man. Geesh.
Reply:I wrote a Sudoku solver in C++ a month or so ago. I plan to add in support for "guessing" to enable it to solve any puzzle but for now it solves almost any puzzle designed for human solves but misses a small a few others. Report It

Reply:what type of program do you want.


try following link:

sympathy flowers

Unable to compile C++ program on Ubuntu?

My Ubuntu version is 6.10, it can compile C program with gcc, but when I try to compile C++ program, the following error shows:


gcc: error trying to exec 'cc1plus': execvp: No such file or directory





I don't know what's the matter, I hope someone give me some help!


Thank you!

Unable to compile C++ program on Ubuntu?
You need to have the g++-4.1 package installed.[1]





In future, you may find http://packages.ubuntu.com/ useful; just use the “packages that contain files named like this” option.


Structured Program in C - Simultaneous Equations?

I'm really struggling to write this C program, with very little time left to write it. Handing it over to you for help





Write a structured program to find the solution of a set of three simultaneous equations with coefficients input by the user in an input file. Complete the pseudo code below and use the following simultaneous equations to verify that the code works.





Pseudo code:


1....


2.....


3. Begin while loop to iterate solution of x, y and z


4. Evaluate new values for x, y and z (retaining a record of the old values)


5. Evaluate the sum of the absolute differences between the old and new values


6. If this sum of differences is less than a tolerence - say 0.0001, then bail out of loop, otherwise go back to step 4.


7....


8....





Simultaneous equations


11x + 2y + z = 15


x + 10y + 2z = 16


2x + 3y - 8z = 1





Rewritten:


Xn+1 = 1/11(15 - 2Yn - Zn)


Yn+1 = 1/10(16 - Xn+1 - 2Zn)


Zn+1 = 1/8(-1 + 2Xn+1 + 3Yn+1)





Additional : How would this code be generalized to solve N simultaneous equation

Structured Program in C - Simultaneous Equations?
Here's an unstructured method in some form of BASIC. It should help you with an approach without handing you your assignment on a plate.





for x=-100 to 100


for y=-100 to 100


for z=-100 to 100


if abs(11x+2y+z-15)%26lt;=0.0001 then


if abs(x+10y+2z-16)%26lt;=0.0001 then


if abs(2x+3y-8z-1)%26lt;=0.0001 then


goto jumppoint


endif


endif


endif


next z


next y


next x


print "no answer found"


end


.jumppoint


print "x=",x," y=",y," z=",z


C program - help needed, plz!!?

how to write a C program for printing the numbers in the following pattern?


1


1 1


1 1 1


1 1 1 1


1 1 1 1 1

C program - help needed, plz!!?
/* Try this dude then send me a message if this will not work. */








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


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





main() {





int i, j;


clrscr();





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


{


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


{


printf("1 ");


}


printf("\n");


}





getch();


return 0;


}
Reply:So boring, is it a homework?
Reply:This smells like a homework problem, so I'm just going to tell you how to approach it.





You basically want 2 loops, one that does each line, and the second that does the numbers *in* each line. So...





thisline = 0;


repeat (until some condition, possibly 'thisline = 10' or whatever)


count = 0;


while count %26lt;= thisline do {


print a 1. increment count.


done;


print a newline ( that's a "\n" in C)


thisline++;


end repeat
Reply:visit my blog http://codesbyshariq.blogspot.com
Reply:You will need to create a loop that adds one to the previous entered number.





After declaring the variables at the start of the program create a count and add one, if the + is before the var. the compiler adds one first, if it is after the compiler starts wth the variable then adds one. Not too important in this instance but a point to remember.





Remember also to end your loop by telling the program the required range.





When it comes to printing you need to include the printf statement. I realise this answer does not write the code for you but that is so you learn. If you need further help I suggest joining the Code Gear forums http://dn.codegear.com/cpp


C Program Help?

Write a program in ‘C’ language which accepts in order and preorder traversal outputs of a Binary Tree as input and prints the corresponding Binary tree.

C Program Help?
class PrePostVisitor : public Visitor


{


public:


virtual void PreVisit (Object%26amp;) {}


virtual void Visit (Object%26amp;) {}


virtual void PostVisit (Object%26amp;) {}


};





class PreOrder : public PrePostVisitor


{


Visitor%26amp; visitor;


public:


PreOrder (Visitor%26amp; v) : visitor (v)


{}


void PreVisit (Object%26amp; object)


{ visitor.Visit (object); }


};





class InOrder : public PrePostVisitor


{


Visitor%26amp; visitor;


public:


InOrder (Visitor%26amp; v) : visitor (v)


{}


void Visit (Object%26amp; object)


{ visitor.Visit (object); }


};





class PostOrder : public PrePostVisitor


{


Visitor%26amp; visitor;


public:


PostOrder (Visitor%26amp; v) : visitor (v)


{}


void PostVisit (Object%26amp; object)


{ visitor.Visit (object); }


};
Reply:OK, here it is:





void main (int argc, string *argv) {


google (binary_tree);


do (your_own_homework);


}
Reply:Hi!


You wanted me to write a program in ‘C’ language [...].


OK, i did it. It works fine. So i am sure, you will be happy to know that i did all you wanted from me.


BTW, next time be more polite when asking people to do your homework instead of you.
Reply:Ok written the program.... now, did you want help with something? You mention it in the subject of your question, but in the details you only ordered us to write a program. How does this help you? Perhaps you forgot the question?





Or maybe you're just being arrogant and rude....

bridal flowers

How do I make a program in C++ using a resource file?

Im fairly new to C++ programming, that is, I am able to program console programs but thats as much as I know. I want to write a win32 app using a resource file. I want to try and make a simple calculator. I used ResEd to make a nice calculator skin, but that is as far as I can go at the moment. How can I use C++ to make a working calculator. I could use some good online tutorials or some personal help. Im also using Dev-C++.

How do I make a program in C++ using a resource file?
I use Dev-C++ and when I started to teach myself Win32 programming, I began with this tutorial:


http://www.winprog.org/tutorial/





Also helpful was a book I checked out of my local public library:


Windows Game Programming for Dummies


http://www.dummies.com/WileyCDA/DummiesT...





But seriously, that online tutorial is a very good place to start.


How to shutdown computer using "c" or "C++" program?

How to shutdown computer using "c" or "C++" program?


can anyone send ma a c or c++ program to shutdown the computer....plzz

How to shutdown computer using "c" or "C++" program?
#include%26lt;bios.h%26gt;


void main()


{


geninterrupt(0x19);


}





//EDIT


this will work with DOS operating systemonly and not with windows
Reply:hi


use shellexecute as bellow :


ShellExecute(0, "OPEN", "shutdown.exe -t 20", 0, 0, SW_SHOWNORMAL);





shutdown is the program in XP that we can run from command line to shut down a computer.


bye for now


C++ login and password program <---URGENT!?

Hi I need a short C++ program that lets me enter a 1 of 6 different usernames (6 letters, 1 number) with it's corresponding password (6 letters, 1, number, 2 letters). I am doing a banking project, and this is the only part i can't get.





Whoever makes a working program first gets 10 points plus kudos! xD





thanks

C++ login and password program %26lt;---URGENT!?
For getting homework help there are better websites like http://oktutorial.com/
Reply:http://www.dreamincode.net/code/snippet5...


Best C++ writing program?

Which is the best program for C++ programming?

Best C++ writing program?
I really like the Microsoft version "Visual C++"
Reply:I personally like using notepad...can't stand most compilers...Turbo C isn't too bad, if you don't mind staring at a bright blue screen

wedding reception flowers

C Program Help?

Write a C program to copy a file to another file following the criteria that the line containing more than 20 characters will be copied to the destination file.

C Program Help?
If this is homework it goes without saying it is not going to help you on a test unless you learn this stuff for yourself. This provided in the spirit that you just needed a hand in getting started on overcoming a mental block.





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


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





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


{


FILE *in, *out;





const int BUFFER_SIZE = 200;





char buffer[BUFFER_SIZE];





if ((in = fopen("input_file.txt", "r")) == NULL)


{


perror("Input file");


return(0);


}








if ((out = fopen("output_file.txt", "w+")) == NULL)


{


perror("Output file");


return(0);


}








while (fgets(buffer, BUFFER_SIZE, in) != NULL)


{


if (strlen(buffer) %26gt;= 20)


{


fputs(buffer, out);


}


}





fclose(in);


fclose(out);


return(1);


}


Write C/C++ program whre input will an integer N ≤ 100000 and output M ≥ N such that M is a Palindrome Prime.

An integer is said to be a palindrome if it is equal to its reverse. For example, 79197 and 324423 are palindromes.





Write the Algorithm or C program whre input will an integer N, 1 ≤ N ≤ 1000000 and output should be the smallest integer M ≥ N such that M is a prime number and M is a palindrome.


For example, if N is 31 then the answer is 101.

Write C/C++ program whre input will an integer N ≤ 100000 and output M ≥ N such that M is a Palindrome Prime.
#include %26lt;stdio.h%26gt;


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


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





int isPalindrom(unsigned int a) {


unsigned int i, n;


char str[15];





sprintf(str, "%d", a);


n = strlen(str) - 1;


i = 0;





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


if (str[i] != str[n - i]) return 0;


}





return 1;


}








// Using Seive


#define LIMIT 1003002


unsigned int primes[LIMIT] = { 0 };





void enrichPrimes() {


unsigned int i;


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


primes[i] = 1;





for (i = 2; i %26lt;= sqrt(LIMIT); ++i)


if (primes[i]) {


unsigned int n = i * i;


while (n %26lt; LIMIT) {


primes[n] = 0;


n += i;


}


}


}





unsigned int findSmallestPalindrom(unsigned int num) {


unsigned int value = num;


while (value %26lt; LIMIT) {


if (primes[value] %26amp;%26amp; isPalindrom(value))


return value;


++value;


}


return 0;


}





int main(void) {


int input;





enrichPrimes();





printf("Enter a number (-1 to stop): ");


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





while (input %26gt;= 0) {


printf("The following palindrom prime is %d\n\n",


findSmallestPalindrom(input));


printf("Enter a number (-1 to stop): ");


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


}





return 0;


}
Reply:// This works too


#include %26lt;iostream%26gt;


#include %26lt;string%26gt;


#include %26lt;sstream%26gt;


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





#define MAX_LIMIT1003001





using namespace std;





bool isPrime(long iInput)


{


bool bResult = true;





if(iInput %26gt;= 1 %26amp;%26amp; iInput %26lt;= 3)


bResult = true;


else if (iInput % 2 != 0)


{


long iMaxTest = (long) sqrt((double) iInput);





for( long i = 3; i %26lt;= iMaxTest; i++)


{


if(iInput % i == 0)


{


// Leave loop, not prime


bResult = false;


i = iMaxTest + 1;


}


}


}


else


{


bResult = false;


}





return bResult;


}





bool isPalindrome(long iInput)


{


stringstream oInput;


string sInput;


string sTest;





// Convert to string


oInput %26lt;%26lt; iInput;


oInput %26gt;%26gt; sInput;





for( long i = sInput.length() - 1; i %26gt;= 0; i-- )


sTest.push_back(sInput[i]);





return (sInput.compare(sTest) == 0);


}





void main( void )


{


long iInput = 0;


bool bFound = false;





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


cin %26gt;%26gt; iInput;





if(iInput %26lt;= 1000000 %26amp;%26amp; iInput %26gt;= 1)


{


while(!bFound %26amp;%26amp; iInput %26lt;= MAX_LIMIT)


{


if(isPalindrome(iInput) %26amp;%26amp;


isPrime(iInput))


{


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


bFound = true;


}


else


iInput++;


}





if(!bFound)


cout %26lt;%26lt; "No result" %26lt;%26lt; endl;


}


else


cout %26lt;%26lt; "Invalid input" %26lt;%26lt; endl;


}


C# program to read number from textbox?

im new to C#. I want to know the code for a windows executable program that would accept a number from a textbox and display its square on other textbox. Please tell me how to do that....

C# program to read number from textbox?
Start building a project in C#. Choose Windows Application. Drag 2 textboxes and a button on the default form. Set the name of the input textbox to txtX and the name of the output textbox to txtX2. You may set the text of the button to "run" or to "^2". Double click the button. The source code is displayed in editor. Type this:





txtX2.Text = Math.Pow( Convert.ToDouble(txtX.Text), 2).ToString();





where txtX is the name of the input textbox and txtX2 is the name of the output textbox.





After compiling, when you click on the button the result should appear in the output textbox
Reply:check out http://www.pscode.com for great sample codes.


C++ program to merge two files?

Suppose you are given two files sorted1.dat and sorted2.dat, which contain several sorted integer numbers.


Write a C++ program that reads from the two files and


merges the sorted numbers into a new file sortedAll.dat.





Example:





sorted1.dat contains:


1 3 5 6 7 9 11





sorted2.dat contains:


2 4 8 10 11 12 14 16





sortedAll.dat should contains:


1 2 3 4 5 6 7 8 9 10 11 11 12 14 16

C++ program to merge two files?
♠ I do not write in C++, but I’m an experienced programmer.


♣ If you still want this algorithm I will describe it in a relevant and readable way with necessary comments and details! you are welcum to click me!
Reply:alogrithm





store file one to array1


store file two to array2





sort(array1,array2,array3) store to array three





save array3 to file





easy algorithm, try not to expect code because you'll never learn if you don't do it yourself.





hint, if you don't know the size of the contents in each file, use dynamic arrays or dump them to a link list and sort the link list.
Reply:LOL I HATED C++, YOUR DOING COMP ENGINEERING??


OR CS MAJOR???





(DONT WORRY WE REALLY DONT USE TOO MUCH PROGRAMMING IF YOU GOING FOR COMP ENGINEERING)
Reply:Use the OS to do the work.





In windows, you can use system([DOS Command Here]) to sort the files, then you can merge the files.





Example





#include %26lt;stdlib%26gt;





int main()


{


system("SORT c:\\sorted1.dat");//sort your first file


system("SORT c:\\sorted2.dat");//sort your second file


system("Copy c:\\sorted1.dat+sorted2.dat sortAll.dat") //merge the files into the new file


system("SORT sortAll.dat");


}

flowers gifts

C++ program neede!!!?

can ne1 send me the c++ program%26lt;full version, thank u very much%26gt;to my id? it is nj.1989@gmail.com

C++ program neede!!!?
if you mean the compiler, old free versions and trial of new versions of turbo c++ are available at





http://bdn.borland.com/article/21751


http://www.borland.com/downloads/downloa...





some other info is available at


http://www.thefreecountry.com/compilers/...
Reply:it is too big to send it over.either download if u have broadband else get ti from ur school/college/training centre
Reply:Do you mean Compilers like Turbo c++?


Well I have mailed you that.
Reply:Program to do what?
Reply:Download the trial version from Microsoft.com. Visual studio


C++ program for the game minesweeper?

Microsoft Visual C++ is the program.

C++ program for the game minesweeper?
here is the source code for minesweeper





http://www.planet-source-code.com/vb/scr...





also another one here:





http://www.geocities.com/alansaviolobo/m...

daylily

C++ program about accepting values and displaying them?

I want a simple c++ program that accepts four values from the user separated by commas and displays the average.





For example the user will input "20,21,22,23" without quotes and the software will output 21.5

C++ program about accepting values and displaying them?
Hi ..





For the 1st look it seems easy but the commas make it a Little ..........


try to use "scanf" function unlike "cin" its formatted Input function .


you need " include%26lt;stdio.h%26gt; " to use "scanf"


http://en.wikipedia.org/wiki/Scanf





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


void main()


{


float x1,x2,x3,x4,avg;


printf("Enter Four Numbers : \n");


scanf("%f,%f,%f,%f" ,%26amp;x1, %26amp;x2, %26amp;x3, %26amp;x4);


avg=(x1+x2+x3+x4)/4;


printf("%f", avg);


}





I don't have C compiler now to check if any errors but i hope this will help ..





best regards ...
Reply:I`m happy you find it helpful ... Report It

Reply:get input as string


break them up


convert into int using atoi


perform rest requirements
Reply:It is a very basic and easy program, do it yourself.


Is that a program that will automatically generate a header file from my c programming source code(not C++).?

I am programming a c language linked list stack in a program called Eclipse. I have the source code in stack.c. I am looking for a program that will scan my stack.c source code and generate a stack.h header file automatically.





Please let me know if there is anything like that out there and a quick explanation of how to use. it.





Thank You

Is that a program that will automatically generate a header file from my c programming source code(not C++).?
no its program that takes few codes from header files and use it


C program language course design?

I want to help people do their course design in C program language in order to make some money, in what way can I get more customers?

C program language course design?
Advertise.


C++ program won't work..?

Just in case.. It compiles just fine


*There Is No Error Message*











So basically, I have written this code that


will let a user choose 2 numbers.


the program will either


1: Tell the user all of the odd numbers between the first number


and second.


or


2: Write the odd numbers to a file, "odds.txt".





This can be found at


http://seklym4.t35.com/odds.txt





I can't find out what could be wrong with it, but there definately


*is* something.





I use Bloodshed Dev-C++, just in case my code won't


compile in your compiler.





Please, could you revise the code, and post it, or at least just


tell me what I need to change to make it work.





Any help would be greatly appreciated.

C++ program won't work..?
Sent an email with the fixed code.





Your problem was with your if conditions.


Noticed that nothing was being written.


Program wasn't getting to the part with cout%26lt;%26lt;"Done!";





I check to see if start == end or end %26lt; start.


I take mod 2 to see if the number starts out even or odd.





Probably should've added comments to the code but heh...
Reply:With your code


You are using the bit AND operator.


To detect odd numbers


(number %26amp; 1) will be 1 if the number is odd and 0 if even number





To revise your code, optimized and removed unnecessary goto statements.





#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;





using namespace std;





int main()


{


ofstream oddfile("odds.txt");//To make file odds.txt


int start;


int end;


string yesno;


cout%26lt;%26lt;"I will tell you the odd numbers from..\n";


cout%26lt;%26lt;"This number: ";


cin%26gt;%26gt; start;


cout%26lt;%26lt;"To this one: ";


cin%26gt;%26gt; end;





cout%26lt;%26lt;"\n\n And..\nWould you like to write the odd numbers to a file?\n";


cin%26gt;%26gt; yesno;


getline( cin, yesno, '\n' );


if ( yesno == "yes")


{


if ((start %26amp; 1) == 0)


start++;


if (start %26lt;= end)


{


for (int i = start; i %26lt;= end; i += 2)


oddfile%26lt;%26lt; start%26lt;%26lt;endl;


cout%26lt;%26lt;"Done!";


oddfile.close();


}


else {


cout%26lt;%26lt;"That's an invalid function.. Thanks for playing though";


oddfile.close();


}


}


else if ( yesno == "no" || "n"){


if ((start %26amp; 1) == 0)


start++;


if (start %26lt;= end)


{


for (int i = start; i %26lt;= end; i += 2)


cout%26lt;%26lt; start%26lt;%26lt;',';


cout%26lt;%26lt;endl%26lt;%26lt;"Done!";


}


else {


cout%26lt;%26lt;"That's an invalid function.. Thanks for playing though";


}


}


else{


cout%26lt;%26lt;"That's an invalid function.. Thanks for playing though";


}


system("pause");


}

flamingo plant

C Program Help (Urgent !!!)?

Can someone urgently help me to write C program which





Accept any two numbers from the user. Perform the following operations on it using functions:





Addition





Subtraction





Multiplication





Swap the values





Print both the numbers in reverse order for example (if a given number is 234, it should be printed as 432)





- Riya

C Program Help (Urgent !!!)?
This program will do all the tasks that are mentioned by you.


1) Addition


2) Subtraction


3) Multiplication


4) Swapping


5) Reverse Order Printing of a number





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





int reverseIt( int num );





void main( ) {


int num1, num2, result, tmp;





printf( "Enter first number: " );


scanf( %26amp;num1 );


printf( "Enter 2nd number: " );


scanf( %26amp;num2 );


result = num1+num2;


printf( "\nSum is: %d\n", result );


result = num1-num2;


printf( "Subtraction of %d from %d is: %d\n", num2, num1, result );


result = num1*num2;


printf( "Mulitplication of these two numbers is: %d\n", result );





tmp = num1;


num1 = num2;


num2 = tmp;


printf( "Swaping the two numbers:\n\n" );


printf( "Number 1 is now: %d\n", num1 );


printf( "Number 2 is now: %d\n", num2 );





printf( "\nReverse of Number 1 is: %d\n", reverseIt( num1 ) );


printf( "Reverse of Number 2 is: %d\n", reverseIt( num2 ) );


}





int reverseIt( int num ) {


int tmp1, tmp2, resultant=0, divider=10;





tmp1 = num;


while( tmp1 %26gt; 0 ) {


tmp1 = num/divider;


tmp2 = num%divider;


resultant = (resultant*10) + tmp2;


divider = divider*10;


}


return resultant;


}





Should you have errors compiling this program, do let me know, I'll definitely help you further.
Reply:234==%26gt;432


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


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


void main()


int i,j,x;


j=0;


printf(" Enter Num ");


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


printf("X=%d\n",x);/*234


while(x)


{


b=x%10;


j=(j*10)+b;


x=x/10;


}





printf("Now =%d",j);/*432


getch();


}plz tell me if this program work properly


i just write it
Reply:int add(int a, int b) {


return a+b;


}
Reply:#include%26lt;stdio.h%26gt;





int add(int,int);


int sub(int,int);


int product(int,int);


int divide(int,int);


void swap(int,int);








void main()


{


int n1,n2,result;


char sym,choice;


printf("This Program is a program for calculator\n\n");


printf("enter the numbers");


do


{


scanf("%d%d",%26amp;n1,%26amp;n2);


printf("enter the symbel for operation to be performed addition(+), subtract(-), multiply(*), division(/) , swap(s)")


scanf("%c",%26amp;sym);


if(sym=='+')


{


result=add(n1,n2);


printf("\n%d",result);


}


if(sym=='-')


{


result=sub(n1,n2);


printf("\n%d",result);


}


if(sym=='*')


{


result= product(n1,n2);


printf("\n%d",result);


}


if(sym=='/')


{


result= divide(n1,n2);


printf("%d",result);


}


if(sym=='s')


{


swap(n1,n2);


}


printf("printing the same in reverse")





while(result%26gt;0)


{


sumOfDigits += result%10;


printf("%d",result%10);


result/=10;


}





printf("\nDo you wish to continue[y/n]");


scanf("%s",%26amp;choice);


}


while(choice=='y'||choice=='Y')








int add(int m1,int m2)


{


return(m1+m2);


}





int sub(int m1,int m2)


{


return(m1-m2);


}





int product(int m1,int m2)


{


return(m1*m2);


}





int divide(int m1,int m2)


{


return(m1/m2);


}





void swap(int m1, int m2)


{


printf("before swap m1=%d and m2=%d",m1,m2);


int tmp;


tmp=m1;


m1=m2;


m2=tmp;


printf("swaped numbers are m1=%d, and m2=%d ",m1,m2);


}
Reply:#include%26lt;stdio.h%26gt;


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


void main()


{


int num1,num2;


printf("Enter 2 numbers\n");


scanf("%d%d",%26amp;num1,%26amp;num2);


add(num1,num2);


sub(num1,num2);


mul(num1,num2);


swap(num1,num2);


reverse(num1);


reverse(num2);


getch();


}





void add(int a,int b)


{


printf("Addition of 2 no's %d",a+b);


}





void sub(int a,int b)


{


printf("subtraction of 2 no's %d",a-b);


}





void mul(int a,int b)


{


printf("Multiplication of 2 no's %d",a*b);


}





void swap(int a,int b)


{


int c;


c=a;


a=b;


b=a;


printf("After Swapping %d %d",a,b);


}





void reverse(int num)


{


int sum=0,rev=0,digit;


while(num%26lt;0)


{


digit = num%10;


sum += digit;


rev = (rev * 10) + digit;


num /= 10;


}


printf("Reverse of number %d",rev);


}


C++ program to reverse 2 consecutive numbers in an array?

c++ program to reverse 2 consecutive numbers in an array. for example if the array is a[ ] = {2,4,6,8,10} , output should be 4, 2, 8, 6, 10

C++ program to reverse 2 consecutive numbers in an array?
swap(array, size)


{


for (i=0, swaps = 0; i%26lt; size; i += 2, swaps++)


{ temp = array[i];


array[i] = array[1+1];


array[i+1] = temp;


}


return (swaps);


}


How do I make a C program?

How do I make a C program that solves a system of three linear equations with three unknowns using determinant of the third order (3*3). Be guided by the following:


1. Use two dimensional arrays in programs.


2. Prompt the user for the input of numerical coefficients and constants of the three equations.


3. The program must contain at least three functions (not including main):


a. A function that computes;


b. A function that displays the matrices; and


c. A function that temporarily stores and replaces values in the matrices ;


4. The program should display the four matrices and the values of the three unknowns should be displayed.

How do I make a C program?
You've got all the instructions in your question. You do know C language, right? So grab a pen and paper and start with your first sentence and then keep asking English language questions until you have all the sub requirements covered. By this point C language will have started to creep into your writing and you will soon have a programme ready to be put into the computer.





Carry on


Thursday, July 30, 2009

C program for string concatenation?

C program coding

C program for string concatenation?
Try using strcat() function (Be sure to include string.h). The syntax of this function is :





newstr = strcat(str1, str2 );





This means the function accepts two string "str1" and "str2" as arguments and concatenates them. The concatenated string is assigned to the variable "newstr".
Reply:str1="string1"


str2="string2"


str3 = str1 + str2;


this is simple. note its just a partial coding.
Reply:String a = strcat(str1, str2 );
Reply:Careful with the first parameter. There must be enough space allocated in that memory space because the second string will be appended. See the documentation link.





Are you asking for a function or a program? If a program, then I think we don't understand the question.
Reply:There is already a function, strcat(), which does this for you.
Reply:this program concats 2 strings a,b using a user-defined function conc().


a and b are passed to the function and accepted in the variables x and y . the concated word is stored in z.


void conc(char x,char y)


{


int l1=strlen(x);


int l2=strlen(y);


l3=l1+l2;


char z[l3];


for(int i=0;i%26lt;l3;i++)


{


z[i]=x[i];


z[i+l1]=y[i];


}


cout.write(z);


}


hope this helps.
Reply:If you need ready function, use strcat().


Note that for strcat(s1, s2) s1 must have enough room to contain resulting string.


If you need your own function, it will be as:


s1 = realloc( s1, strlen(s1)+strlen(s2)+1);


strcpy( s1+strlen(s1), s2 );


That's all.
Reply:already defined fn in string library.


strcat()

umbrella plant

C-program for balanced trees(AVL Trees)Inorder traversal using right rotations(LL) left rotations(RR) and (RL

data structures - tree traversal- request for full C-program to realize balanced trees

C-program for balanced trees(AVL Trees)Inorder traversal using right rotations(LL) left rotations(RR) and (RL
/* Program to maintain an AVL tree. */





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


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


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





#define FALSE 0


#define TRUE 1





struct AVLNode


{


int data ;


int balfact ;


struct AVLNode *left ;


struct AVLNode *right ;


} ;





struct AVLNode * buildtree ( struct AVLNode *, int, int * ) ;


struct AVLNode * deldata ( struct AVLNode *, int, int * ) ;


struct AVLNode * del ( struct AVLNode *, struct AVLNode *, int * ) ;


struct AVLNode * balright ( struct AVLNode *, int * ) ;


struct AVLNode * balleft ( struct AVLNode *, int * ) ;


void display ( struct AVLNode * ) ;


void deltree ( struct AVLNode * ) ;





void main( )


{


struct AVLNode *avl = NULL ;


int h ;





clrscr( ) ;





avl = buildtree ( avl, 20, %26amp;h ) ;


avl = buildtree ( avl, 6, %26amp;h ) ;


avl = buildtree ( avl, 29, %26amp;h ) ;


avl = buildtree ( avl, 5, %26amp;h ) ;


avl = buildtree ( avl, 12, %26amp;h ) ;


avl = buildtree ( avl, 25, %26amp;h ) ;


avl = buildtree ( avl, 32, %26amp;h ) ;


avl = buildtree ( avl, 10, %26amp;h ) ;


avl = buildtree ( avl, 15, %26amp;h ) ;


avl = buildtree ( avl, 27, %26amp;h ) ;


avl = buildtree ( avl, 13, %26amp;h ) ;





printf ( "\nAVL tree:\n" ) ;


display ( avl ) ;





avl = deldata ( avl, 20, %26amp;h ) ;


avl = deldata ( avl, 12, %26amp;h ) ;





printf ( "\nAVL tree after deletion of a node:\n" ) ;


display ( avl ) ;





deltree ( avl ) ;





getch( ) ;


}





/* inserts an element into tree */


struct AVLNode * buildtree ( struct AVLNode *root, int data, int *h )


{


struct AVLNode *node1, *node2 ;





if ( !root )


{


root = ( struct AVLNode * ) malloc ( sizeof ( struct AVLNode ) ) ;


root -%26gt; data = data ;


root -%26gt; left = NULL ;


root -%26gt; right = NULL ;


root -%26gt; balfact = 0 ;


*h = TRUE ;


return ( root ) ;


}





if ( data %26lt; root -%26gt; data )


{


root -%26gt; left = buildtree ( root -%26gt; left, data, h ) ;


/* If left subtree is higher */


if ( *h )


{


switch ( root -%26gt; balfact )


{


case 1:


node1 = root -%26gt; left ;


if ( node1 -%26gt; balfact == 1 )


{


printf ( "\nRight rotation along %d.", root -%26gt; data ) ;


root -%26gt; left = node1 -%26gt; right ;


node1 -%26gt; right = root ;


root -%26gt; balfact = 0 ;


root = node1 ;


}


else


{


printf ( "\nDouble rotation, left along %d",


node1 -%26gt; data ) ;


node2 = node1 -%26gt; right ;


node1 -%26gt; right = node2 -%26gt; left ;


printf ( " then right along %d.\n", root -%26gt; data ) ;


node2 -%26gt; left = node1 ;


root -%26gt; left = node2 -%26gt; right ;


node2 -%26gt; right = root ;


if ( node2 -%26gt; balfact == 1 )


root -%26gt; balfact = -1 ;


else


root -%26gt; balfact = 0 ;


if ( node2 -%26gt; balfact == -1 )


node1 -%26gt; balfact = 1 ;


else


node1 -%26gt; balfact = 0 ;


root = node2 ;


}


root -%26gt; balfact = 0 ;


*h = FALSE ;


break ;





case 0:


root -%26gt; balfact = 1 ;


break ;





case -1:


root -%26gt; balfact = 0 ;


*h = FALSE ;


}


}


}





if ( data %26gt; root -%26gt; data )


{


root -%26gt; right = buildtree ( root -%26gt; right, data, h ) ;


/* If the right subtree is higher */


if ( *h )


{


switch ( root -%26gt; balfact )


{


case 1:


root -%26gt; balfact = 0 ;


*h = FALSE ;


break ;





case 0:


root -%26gt; balfact = -1 ;


break;





case -1:


node1 = root -%26gt; right ;


if ( node1 -%26gt; balfact == -1 )


{


printf ( "\nLeft rotation along %d.", root -%26gt; data ) ;


root -%26gt; right = node1 -%26gt; left ;


node1 -%26gt; left = root ;


root -%26gt; balfact = 0 ;


root = node1 ;


}


else


{


printf ( "\nDouble rotation, right along %d",


node1 -%26gt; data ) ;


node2 = node1 -%26gt; left ;


node1 -%26gt; left = node2 -%26gt; right ;


node2 -%26gt; right = node1 ;


printf ( " then left along %d.\n", root -%26gt; data ) ;


root -%26gt; right = node2 -%26gt; left ;


node2 -%26gt; left = root ;





if ( node2 -%26gt; balfact == -1 )


root -%26gt; balfact = 1 ;


else


root -%26gt; balfact = 0 ;


if ( node2 -%26gt; balfact == 1 )


node1 -%26gt; balfact = -1 ;


else


node1 -%26gt; balfact = 0 ;


root = node2 ;


}


root -%26gt; balfact = 0 ;


*h = FALSE ;


}


}


}


return ( root ) ;


}





/* deletes an item from the tree */


struct AVLNode * deldata ( struct AVLNode *root, int data, int *h )


{


struct AVLNode *node ;





if ( !root )


{


printf ( "\nNo such data." ) ;


return ( root ) ;


}


else


{


if ( data %26lt; root -%26gt; data )


{


root -%26gt; left = deldata ( root -%26gt; left, data, h ) ;


if ( *h )


root = balright ( root, h ) ;


}


else


{


if ( data %26gt; root -%26gt; data )


{


root -%26gt; right = deldata ( root -%26gt; right, data, h ) ;


if ( *h )


root = balleft ( root, h ) ;


}


else


{


node = root ;


if ( node -%26gt; right == NULL )


{


root = node -%26gt; left ;


*h = TRUE ;


free ( node ) ;


}


else


{


if ( node -%26gt; left == NULL )


{


root = node -%26gt; right ;


*h = TRUE ;


free ( node ) ;


}


else


{


node -%26gt; right = del ( node -%26gt; right, node, h ) ;


if ( *h )


root = balleft ( root, h ) ;


}


}


}


}


}


return ( root ) ;


}





struct AVLNode * del ( struct AVLNode *succ, struct AVLNode *node, int *h )


{


struct AVLNode *temp = succ ;


if ( succ -%26gt; left != NULL )


{


succ -%26gt; left = del ( succ -%26gt; left, node, h ) ;


if ( *h )


succ = balright ( succ, h ) ;


}


else


{


temp = succ ;


node -%26gt; data = succ -%26gt; data ;


succ = succ -%26gt; right ;


free ( temp ) ;


*h = TRUE ;


}


return ( succ ) ;


}





/* balances the tree, if right sub-tree is higher */


struct AVLNode * balright ( struct AVLNode *root, int *h )


{


struct AVLNode *node1, *node2 ;





switch ( root -%26gt; balfact )


{


case 1:


root -%26gt; balfact = 0 ;


break;





case 0:


root -%26gt; balfact = -1 ;


*h = FALSE ;


break;





case -1:


node1 = root -%26gt; right ;


if ( node1 -%26gt; balfact %26lt;= 0 )


{


printf ( "\nLeft rotation along %d.", root -%26gt; data ) ;


root -%26gt; right = node1 -%26gt; left ;


node1 -%26gt; left = root ;


if ( node1 -%26gt; balfact == 0 )


{


root -%26gt; balfact = -1 ;


node1 -%26gt; balfact = 1 ;


*h = FALSE ;


}


else


{


root -%26gt; balfact = node1 -%26gt; balfact = 0 ;


}


root = node1 ;


}


else


{


printf ( "\nDouble rotation, right along %d", node1 -%26gt; data );


node2 = node1 -%26gt; left ;


node1 -%26gt; left = node2 -%26gt; right ;


node2 -%26gt; right = node1 ;


printf ( " then left along %d.\n", root -%26gt; data );


root -%26gt; right = node2 -%26gt; left ;


node2 -%26gt; left = root ;





if ( node2 -%26gt; balfact == -1 )


root -%26gt; balfact = 1 ;


else


root -%26gt; balfact = 0 ;


if ( node2 -%26gt; balfact == 1 )


node1 -%26gt; balfact = -1 ;


else


node1 -%26gt; balfact = 0 ;


root = node2 ;


node2 -%26gt; balfact = 0 ;


}


}


return ( root ) ;


}





/* balances the tree, if left sub-tree is higher */


struct AVLNode * balleft ( struct AVLNode *root, int *h )


{


struct AVLNode *node1, *node2 ;





switch ( root -%26gt; balfact )


{


case -1:


root -%26gt; balfact = 0 ;


break ;





case 0:


root -%26gt; balfact = 1 ;


*h = FALSE ;


break ;





case 1:


node1 = root -%26gt; left ;


if ( node1 -%26gt; balfact %26gt;= 0 )


{


printf ( "\nRight rotation along %d.", root -%26gt; data ) ;


root -%26gt; left = node1 -%26gt; right ;


node1 -%26gt; right = root ;


if ( node1 -%26gt; balfact == 0 )


{


root -%26gt; balfact = 1 ;


node1 -%26gt; balfact = -1 ;


*h = FALSE ;


}


else


{


root -%26gt; balfact = node1 -%26gt; balfact = 0 ;


}


root = node1 ;


}


else


{


printf ( "\nDouble rotation, left along %d", node1 -%26gt; data ) ;


node2 = node1 -%26gt; right ;


node1 -%26gt; right = node2 -%26gt; left ;


node2 -%26gt; left = node1 ;


printf ( " then right along %d.\n", root -%26gt; data ) ;


root -%26gt; left = node2 -%26gt; right ;


node2 -%26gt; right = root ;





if ( node2 -%26gt; balfact == 1 )


root -%26gt; balfact = -1 ;


else


root -%26gt; balfact = 0 ;


if ( node2-%26gt; balfact == -1 )


node1 -%26gt; balfact = 1 ;


else


node1 -%26gt; balfact = 0 ;


root = node2 ;


node2 -%26gt; balfact = 0 ;


}


}


return ( root ) ;


}





/* displays the tree in-order */


void display ( struct AVLNode *root )


{


if ( root != NULL )


{


display ( root -%26gt; left ) ;


printf ( "%d\t", root -%26gt; data ) ;


display ( root -%26gt; right ) ;


}


}





/* deletes the tree */


void deltree ( struct AVLNode *root )


{


if ( root != NULL )


{


deltree ( root -%26gt; left ) ;


deltree ( root -%26gt; right ) ;


}


free ( root ) ;


}
Reply:For a balanced tree, number of apples on the left branch must equal to the number of apples on the right branch. This is the whole story.