Monday, May 24, 2010

What is conio.h in a c program?

I wish to know the necessity of inclusion of conio.h in c programming.what sort of a command is conio.h? what is its function in a c program? what if i don't include this command in my program? what type of files are stored in conio.h

What is conio.h in a c program?
First of all, conio.h is itself a file, called as 'header file'. The way you include it in your C program is called "preprocessor directive". This will just place all the function definitions in conio.h, in your program while compiling.


conio.h is used basically to clear screen (clrscr()), get characters (getch(), getche(), getchar()), print in colors (cprintf()) and text based graphics programming (like printing in colors, moving around the screen by specifying the position, etc).
Reply:"conio.h" means that 'consol input and output' and it contain ur consol input and ouput functions and perform the DOS base tasks
Reply:it is a header file used in old MS-DOS compilers.we should include this header file in our program when we use the functions like clrscr(),getch() and getche.
Reply:Its a header file.Console Input Output

flowers gifts

How to make a C/C++ program pause?

ok so I'm trying to learn C and C++, and whenever I execute the program it runs in the blink of an eye and I don't have time to see what it says, I remember there being a pause command or something that I could put in there somewhere that would wait for me to press enter, can you tell me where to put it and exactly what it's called? thank you

How to make a C/C++ program pause?
get in the habit of using getch() because it will work on all platforms (windows, unix, linux).





system("pause"); is Microsoft only.
Reply:Just add a getch(); before the last } of main. You will be fine.
Reply:There are a variety of ways -- basically you just need something that will cause the process to block.





One of these will work:


-Try reading in some input


-Use the sleep() command


-Use getch()
Reply:if the operating system is windows you can use


system("pause");


this function was declared in system.h I gues you should include the file. and for any operating system you can use scanf.


How do I compile C++ program in windows ?

is there any free or GNU g++ type compiler to compile C++ program in windows vista ?

How do I compile C++ program in windows ?
install cygwin, it has ports of g++ available that will compile under windows.





http://www.cygwin.com/
Reply:Microsoft Visual C++ Express may be useful:


http://www.microsoft.com/express/vc/
Reply:http://www.bloodshed.net/devcpp.html





You could try Dev-C++. It's what I use and I've never had any problems with it. It comes with MingW (A minimalist GCC port to Windows), so you don't have to deal with setting your own compiler up. There's also CodeBlocks, but I don't have any personal experience with that IDE.

daylily

Find 25^0.25 c program?

how can i solve (25^0.25) using c program

Find 25^0.25 c program?
#include %26lt;stdio.h%26gt;


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


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


void main()


{


int a,b;


a=25;


clrscr();


b=pow(25,0.25);


printf("%d",%26amp;b);


}


getch();


I'm trying to do a simple C program and I need to figure out how to check if a user input is an integer?

I'm doing a simple program that calculates sales tax to a purchase and displays the tax amount and the total cost. I'm using C (NOT C++) and the user will input the sale price then I am to convert that into the total sale and what the tax would be. Now I need to check the input that the user gives the program to verify that it is either a floating point or an integer. I think i need a float if they can use decimals right? Any help would be beneficial. Thank You For Your Time And Patience!!!

I'm trying to do a simple C program and I need to figure out how to check if a user input is an integer?
You can get sscanf to do much of the work for you. See below for some code I wrote to illustrate:





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


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


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





#define MAX_STR_LEN 256





typedef enum { NONE = 0, INT, FLOAT, STRING, OTHER } DATA_TYPE;





typedef struct {


DATA_TYPE type;


union {


long i;


double f;


char s[MAX_STR_LEN];


} data;


} input_t;





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


{


char *s = argv[1];


input_t in = { NONE, { 0 } };





if (argc != 2) {


printf("\nusage: %s %26lt;n%26gt;\n",argv[0]);


exit(EXIT_FAILURE);


}


if ((strchr(s,'.') != NULL) %26amp;%26amp; (sscanf(s,"%lf",%26amp;in.data.f) == 1)) {


in.type = FLOAT;


} else if (sscanf(s,"%ld",%26amp;in.data.i) == 1) {


in.type = INT;


} else if (sscanf(s,"%s",in.data.s) == 1) {


in.type = STRING;


memcpy(in.data.s,s,sizeof(MAX_STR_LEN));


} else {


in.type = OTHER;


}





switch (in.type) {


case (INT):


printf("\nInt : %ld\n",in.data.i);


break;


case (FLOAT):


printf("\nFlt : %g\n",in.data.f);


break;


case (STRING):


printf("\nStr : %s\n",in.data.s);


break;


default:


puts("\nInvalid input");


break;


}


exit(EXIT_SUCCESS);


}
Reply:You can use float.


Float can handle int but Int cannot handle float or decimals.
Reply:well it is very simple just use float or decimal if use type only integer value then there is no such problem and you should display as it is.


How to write a program in C by turning a hexadecimal to a decimal?

im having a hard time with this right now. help





write a c program that utilizes strings and numeric conversions





1. Read strings using a function you write called getStr ().


2. Write a function named hextodecimal () that takes in (only) a string parameter representing a positive hexadecimal number and return its decimal equivalent (integer). This function returns -1 if the string provided connotes to a negative number and/or is comprised of invalid characters.


-note: you may not use any library functions in this function- you must write all code necessary to enact the coversion and return the appropriate result.


-this function must accept both upper and lower case versions of the hex character.


-You may want to write an additional function that vets any string for invalid hex character


3. If original string is invalid, output an unambiguous message to the user and prompt for another input.


4. Output the original String, followed by its decimal equivalent. Clearly label which is which

How to write a program in C by turning a hexadecimal to a decimal?
I don't want to give you the entire solution, but I will give you some pieces to help, and comments where you need to fill in the code. This assignment justifiably restricts you from using library functions, which you would normally use to do much of the work for you. Use of fgets to get the user input is, I assume, allowed.





Note that I put the validity check in getStr, but part 2 of the problem statement wants you to check validity in hextodecimal, which is probably a better place to put it.





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


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





typedef enum { false = 0, true } Bool;





double Pow(const double x, const unsigned y);


int AtoI(const char c);


Bool isValidHexChar(const char c);


Bool getStr(char *s);


int hexToDec(char *s);





#define MAX_STR 256





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


char s[MAX_STR];





memset(s,0,sizeof(s));


if (getStr(s) == false) {


puts("\ninvalid entry");


} else {


printf("\n%s = %d\n",s,hexToDec(s));


}


return 0;


}





Bool getStr(char *s) {


char *p = s;


Bool isValidFlg = true;





/* prompt for hex value and read it using fgets */


/* remove '\n' from end of entered string */


/* loop for each character in the string, */


/* calling isValidHexChar( ) to check validity */





return isValidFlg;


}





int hexToDec(char *s) {





/* loop from the last char in s to the first, */


/* calling AtoI and Pow as you go to convert */


/* from hex to decimal */





return result;


}





double Pow(const double x, const unsigned y) {


double result = 1;


int i;





if (y %26gt; 0) {


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


result *= x;


}


}


return result;


}





int AtoI(const char c) {


int i = -1;


if (isValidHexChar(c) == true) {


if ((c %26gt;= '0') %26amp;%26amp; (c %26lt;= '9')) i = (int)c - 0x30;


else if ((c %26gt;= 'a') %26amp;%26amp; (c %26lt;= 'f')) i = (int)c - 0x57;


else i = (int)c - 0x37;


}


return i;


}





Bool isValidHexChar(const char c) {


Bool validFlg = false;


if (((c %26gt;= '0') %26amp;%26amp; (c %26lt;= '9')) ||


((c %26gt;= 'a') %26amp;%26amp; (c %26lt;= 'f')) ||


((c %26gt;= 'A') %26amp;%26amp; (c %26lt;= 'F'))) {


validFlg = true;


}


return validFlg;


}
Reply:try to avoid hexadecimal value....


WRITE A C -PROGRAM FOR FIBONACCI SERIES FOR n NUMBERS USING DO-WHILE STATEMENT.?

use c program

WRITE A C -PROGRAM FOR FIBONACCI SERIES FOR n NUMBERS USING DO-WHILE STATEMENT.?
well i suppose fibonacci no r


0 1 1 2 3 5 8 13





then ur code will be





int i =2;


int no[100];// say


no[0] = 0;


no[1] = 1;


do{


no[i] = no[i-2] + no[i-1];


i++;


printf( "%d th fib is::%d",i,no[i] );


}


while( i %26lt; 100);
Reply:Lol. I had to do this program in C and Java. Do your own homework man.

flamingo plant

Write a c program that will generate an arbitrary number of integers and store them in the file name numfile?

the c program one integer per line

Write a c program that will generate an arbitrary number of integers and store them in the file name numfile?
#include %26lt;stdio.h%26gt;


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





int


main(int argc, char* argv[])


{


  int count = argc%26gt;1 ? atoi(argv[1]) : 10;


  FILE *f = fopen("numfile", "w+");


  if (!f)


    perror("fopen"), exit(-1);


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


    fprintf(f, "%d\n", rand());


  fclose(f);


  return 0;


}


Write a C++ Program that prints the block letter "B" IN A 7 x 6 grid of stars?

NOTE


using a C++ PROGRAM PLEASE!!

Write a C++ Program that prints the block letter "B" IN A 7 x 6 grid of stars?
Trisha,





As someone who teaches programming, I can tell you that this approach to homework is only going to hurt yourself (and probably cause you to fail the course).





All the concepts you're covering in class build upon one another... so if you don't learn to do this week's homework, you won't be able to do any of the following weeks' homework (not to mention tests and larger-scale projects).
Reply:I am really sorry to say. But try it on your own, if it is a project given to you. The hint is "Use for loop".
Reply:Do your own homework!


I have a doubt in c++ program?

i have an error in c++ program.......its coming as an error 4 all the programs......the error is "fatal..\INCLUDE\CONIO%26gt;H 165: error directive: must use c++ for the type iostream". so wat correction am i supposed to make?

I have a doubt in c++ program?
I think you wrote a program as C++, but saved the file as a C file. For example, instead of naming the file MyProg.cpp, you called it MyProg.c. The compiler uses the file extension to determine if the program is a C program or a C++ program.
Reply:it is the error of your header files......either your library is corrupter or you need to set ur path by going in DOS shell.........
Reply:I wish you had provided your code because this looks like a relatively simple problem but wihtout your code it can be many types of things but one thing is for certain, thre previous responder (above this comment) is wrong in saying the file could be corrupt (that is just silly).....





Could you paste your code so i can take a look? Also it might be possible that your dev environment is set up to think its C specific or C++ (depending on which type you are trying to compile in)..





you should have either (or both):





#include %26lt;conio%26gt;


#include %26lt;iostream%26gt;





Notice you dont need to mention the ".h" extension for the conio portion if you are working with C++ code....And notice i didn't give the path to the library...the system knows where theya re already.


A program on a General tree having more than 2 child node in Data structure in C programming?

a C program on a General tree having more than 2 child node in Data structure in C programming. it is not a binary tree, but it should be a general tree where root node have three child node and each child node have three sub child node. want a help program on that

A program on a General tree having more than 2 child node in Data structure in C programming?
do you know how to implement double linked list ? please learn how to implement double linked list. this will solve your problem

umbrella plant

Write a C program that will convert Simple Sentences to Complex/Compound Sentence.?

Write a C program that will convert Simple Sentences to Complex/Compound Sentence.

Write a C program that will convert Simple Sentences to Complex/Compound Sentence.?
Cool. I think it is like taping into the state of the equation and filling the history


Write a c program to merge sort 2 already sorted arrays?

how do i write a c program to merge sort 2 already sorted arrays?

Write a c program to merge sort 2 already sorted arrays?
Here is a small programme that will merge two sorted arrays of integer. You'll have to tweek it if you want to merge a different numeric type, and to add error checking -- I left all error checking out to make the code clearer.





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





int *merge( int *a, int *b, int len )


{


int ai = 0; /* index into each array */


int bi = 0;


int *m = NULL;


int *mp = NULL;





mp = m = (int *) malloc( sizeof( int ) * len * 2); /* merged result*/





while( ai %26lt; len %26amp;%26amp; bi %26lt; len ) /* until one source is exhausted*/


{


if( *(a+ai) %26lt; *(b+bi) )


*mp++ = *(a+ai++);


else


*mp++ = *(b+bi++);


}





/* tack on the remainder of the array that was not exhausted */


while( ai %26lt; len )


*mp++ = *(a+ai++ );


while( bi %26lt; len )


*mp++ = *(b+bi++ );





return m; /* the merged array goes back to caller */


}








main( int argc, char **argv )


{


int first[] = { 1, 4, 8, 10, 12, 16, 22 };


int second[] = { 3, 6, 9, 12, 15, 18, 21 };


int *merged;


int i;





merged = merge( first, second, 7 );


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


printf( "%d ", merged[i] );


printf( "\n" );


}


Write a c program to simulate the movement of a caer?

The program should in C lanaguage and also related to Graphics designing.

Write a c program to simulate the movement of a caer?
I have this program on boat race. Take logic and have it as you desire.


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


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


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


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


int b1,b2,b3,b4,b5,b6,j1=0,i1=0,i=DETECT,j,k...


FILE *fp;


char name[15];


void hai(int,int);


void main()


{


if(fopen("scores.txt","r")==NULL)


{


fp=fopen("scores.txt","w");


fprintf(fp,"0 0 0 0 0 0");


}


initgraph(%26amp;i,%26amp;j,"c:\\tc\\bgi");


setcolor(5);


settextstyle(1,0,6);


outtextxy(40,150,"welcome to boat race");


outtextxy(40,174,"----------------");


getch();


textmode(0);


textcolor(2);


cprintf("enter your name::");


cscanf("%s",%26amp;name);


printf("\n\n");


cprintf(" hai %s welcome to boat race",name);


printf("\n\n\n");


textcolor(14);


cprintf(" records of boats");


table();


printf("\n\n\n\n");


cprintf("see records and select a boat");


printf("\n\n");


cprintf("enter the boat no.::");


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


getch();


i=0;


initgraph(%26amp;i,%26amp;j,"c:\\tc\\bgi");


setcolor(14);


rectangle(1,1,getmaxx(),getmaxy());


rectangle(7,7,getmaxx()-7,getmaxy()-7)...


setfillstyle(1,2);


floodfill(6,6,14);


settextstyle(7,0,3);


outtextxy(23,23,"enter any key to start the game. . . . . . . . .");


while(j1!=1)


{i1++;


if(kbhit())


j1=1;}


getch();


j1=abs(i1);


setcolor(0);


settextstyle(7,0,3);


outtextxy(23,23,"enter any key to start the game. . . . . . . . .");


setcolor(15);


circle(500,55,30);


setfillstyle(1,14);


floodfill(500,55,15);


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


hai(i,j1);


getch();}


void hai(int i,int j1)


{int l;


for(j=0;j%26lt;251;j+=50)


{if(j==0)


{if((b1%26gt;180%26amp;%26amp;b1%26lt;240))


b1+=1;


else if(b1%26gt;250%26amp;%26amp;b1%26lt;400)


b1+=3;


else if((j1%8)%2==0)


b1+=(j1%8+1);


else


b1+=(j1%8);


i=b1;}


else if(j==50)


{if(b2%26gt;100%26amp;%26amp;b2%26lt;200)


b2+=5;


else if(b2%26gt;300%26amp;%26amp;b2%26lt;400)


b2+=5;


else if((j1%3)%2==0)


b2+=(j1%3+1);


else


b2+=j1%3;


i=b2;}


else if(j==100)


{if(b3%26gt;100%26amp;%26amp;b3%26lt;150)


b3+=3;


else if(b3%26gt;150%26amp;%26amp;b3%26lt;300)


b3+=5;


else if((j1%4)%2==0)


b3+=(j1%4+1);


else


b3+=j1%4;


i=b3;}


else if(j==150)


{if(b4%26gt;100%26amp;%26amp;b4%26lt;200)


b4+=3;


else if(b4%26gt;300%26amp;%26amp;b4%26lt;400)


b4+=3;


else if((j1%5)%2==0)


b4+=(j1%5+1);


else


b4+=j1%5;


i=b4;}


else if(j==200)


{if(b1%26gt;200%26amp;%26amp;b4%26lt;400)


b5+=3;


else if(b2%26gt;100%26amp;%26amp;b3%26lt;200)


b5+=3;


else if((j1%6)%2==0)


b5+=(j1%6+1);


else


b5+=j1%6;


i=b5;}


else if(j==250)


{if(b2%26gt;50%26amp;%26amp;b3%26lt;300)


b6+=1;


else if(b1%26gt;150%26amp;%26amp;b4%26lt;300)


b6+=3;


else if((j1%7)%2==0)


b6+=(j1%7+1);


else


b6+=j1%7;


i=b6;}


setcolor(2);


line(8,180+j,630,180+j);


setcolor(6);


ellipse(40+i,159+j,180,360,30,20);


setcolor(7);


circle(35+i,159+j,4);


arc(42+i,164+j,180,310,10);


if(i%2==0)


{line(35+i,167+j,48+i,174+j);


line(38+i,167+j,50+i,174+j);


setcolor(14);


line(50+i,170+j,40+i,200+j);}


else


{line(38+i,167+j,30+i,179+j);


line(35+i,167+j,28+i,180+j);


setcolor(14);


line(31+i,170+j,21+i,200+j);}


if(i%26gt;550%26amp;%26amp;i%26lt;560)


{l=10;


k=j;}}


if(l==10)


{setcolor(6);


fp=fopen("scores.txt","r+");


settextstyle(1,0,4);


switch(k/50+1)


{case 1:


outtextxy(30,230,"the winner of the game is 1st boat");


break;


case 2:


outtextxy(30,230,"the winner of the game is 2th boat");


break;


case 3:


outtextxy(30,230,"the winner of the game is 3th boat");


break;


case 4:


outtextxy(30,230,"the winner of the game is 4th boat");


break;


case 5:


outtextxy(30,230,"the winner of the game is 5th boat");


break;


case 6:


outtextxy(30,230,"the winner of the game is 6th boat");


}


if(n==(k/50+1))


outtextxy(30,270,"congrats ! you have won the match");


else


outtextxy(30,270,"sorry ! you have lost the match");


fseek(fp,(k/50)*12,0);


fscanf(fp,"%d",%26amp;c);


c+=1;


if(c%26gt;=10)


c=0;


fseek(fp,(k/50)*12,0);


fprintf(fp,"%d",c);


fclose(fp);


getch();


cleardevice();


exit(0);}


for(k=0;k%26lt;4;k++)


delay(2000000);


for(j=0;j%26lt;251;j+=50)


{if(j==0)


i=b1;


else if(j==50)


i=b2;


else if(j==100)


i=b3;


else if(j==150)


i=b4;


else if(j==200)


i=b5;


else if(j==250)


i=b6;


setcolor(0);


ellipse(40+i,159+j,180,360,30,20);


circle(35+i,159+j,4);


arc(42+i,164+j,180,310,10);


if(i%2==0)


{line(35+i,167+j,48+i,174+j);


line(38+i,167+j,50+i,174+j);


line(50+i,170+j,40+i,200+j);}


else


{line(38+i,167+j,30+i,179+j);


line(35+i,167+j,28+i,180+j);


line(31+i,170+j,21+i,200+j);}}}


table()


{


fp=fopen("scores.txt","r+");


for(j=0;j%26lt;7;j++)


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


{gotoxy(4+j*5,i);


cprintf("%c",'³');}


for(j=9;j%26lt;=15;j+=3)


for(i=4;i%26lt;35;i++)


{gotoxy(i,j);


cprintf("%c",'Ä');}


for(i=0;i%26lt;7;i+=3)


for(j=0;j%26lt;7;j++)


{gotoxy(4+j*5,9+i);


if(j==0)


cprintf("%c",'Ã');


else if(j==6)


cprintf("%c",'´');


else


cprintf("%c",'Ã…');}


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


{gotoxy(5+i*5,10);


printf("boat");


gotoxy(6+i*5,11);


printf("%d",i+1);


fseek(fp,i*12,0);


fscanf(fp,"%d",%26amp;c);


gotoxy(6+i*5,13);


printf("%d",c);}


getch();


}





visit us :: ebizwebbiz.com/mahesh_naidu/


ebizwebbiz.com/kchandureddy/


thank u


from


Indian


Help with c program?

can u please tell me how to write a c program to generate adam numbers from 10 to 100.


an adam number is one which satisfies the following: the reverse of the square of a number is the square of the reverse of the number. that is if the number is 12 then 12^2=144,the reverse 441 which is 21^2

Help with c program?
#include%26lt;stdio.h%26gt;


void main()


{


int num, rev, sq, rev_sq;


int rev_int(int);//Function to get reverse of any number passed as parameter





for (num=10;num%26lt;100;num++)


{


sq = num*num; // square of all numbers from 10 to 100;


rev = rev_int(num); // gets reverse of num


rev_sq = rev_int(sq);// gets reverse of square





/* we check if the reverse of the square of the number is equal to the square of the reverse of the number.If found true then print the number else go to the next iteration*/





if(rev_sq == rev*rev)


printf("\n%d is Adams number",i);


}//end of for loop





}





int rev_number(int num)


{


int rev = 0;


while(num%10 !=0)


{


rev = rev + (num % 10) * 10;


num = num/10;


}


return rev;// returns the reverse


}//end of function





This program could be done with lot less variables.
Reply:I would loop through each number. In the loop:


1. convert number to string. Hold on to string and its reverse.


2. Square the number


3. convert the square to a string and reverse it.


4. Convert string to a number and get square root


5. Convert square root to string and compare to reverse of string in 1.





If they are equal, you have an adam number. Print it and move on to next number


If they are not, then move on to next number
Reply:Sounds to me like what you need to write, first, is a function which takes an int number, converts it to a string, reverses the string, then converts the reversed string into an integer for returning.





Then, you write a loop, from 10 to 100, in which the current index is passed to your function. That gives you the two values that have to prove to be an adam. Then you square both of those numbers. Then you need to compare the two squares to see if one is the reverse of the other. For that, you COULD use your function again on one of the two squares, then compare what is returned with what was generated.





Which class is this for - number theory? discrete math? Just curious. This kind of thing is so fun..





Too bad it has to be in C - in Perl or Tcl the code would be a lot simpler...

deliver flowers

Help in c++ program?

i want to write a program that calculates arithmatic and geometric mean in c++ , so i need help

Help in c++ program?
You aren't very specific with your request. How will the numbers be input (e.g. entered at the console, constant array, from a file) into the program? Any particular number format (e.g. integers, scientfic notation, simple floating point, double precision, fractions, sequence range, symbolic)?





Do you have a start to your program that you could share? This would help answer some the questions above. Is this a homework problem? Do you simply need hints regarding the general concepts for a computing solution or specific help on how to code certain aspects?





The arithmetic mean is pretty straight forward; it's just the average of your input numbers. However, the geometric mean can be done in several ways. I recommend taking the log of each input number, adding each log (i.e. multiply), dividing (i.e. nth-root) by the number of items, and finally the anti-log. Below is a quick attempt:





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


#include %26lt;iostream%26gt;


using namespace std;


int main () {


double nums[] ={8.3, 7.5, 1.9, 6.2, 2.4}; // input numbers


int numCount = sizeof(nums); // number of elements


double arithmetic_mean=0.0, geometric_mean=0.0;


for (int counter=0; counter%26lt;numCount; counter++) {


arithmetic_mean += nums[counter];


geometric_mean += log(nums[counter]);


}


arithmetic_mean /= numCount; // calc average


geometric_mean = exp(geometric_mean/numCount); // calc e ^ nth-root


cout %26lt;%26lt; "arithmetic mean = " %26lt;%26lt; arithmetic_mean %26lt;%26lt; endl;


cout %26lt;%26lt; "geometric mean = " %26lt;%26lt; geometric_mean %26lt;%26lt; endl;


return 0;


}





Obviously, you'll want to substitute the appropriate input code for the nums[] array. Also, I assumed double precision calculations but you may have different requirements.


Write a C Program to arrange a set of N numbers in an increasing order?

Write a C Program to arrange a set of N numbers in an increasing order

Write a C Program to arrange a set of N numbers in an increasing order?
This is a standard sort program. You can use bubble sort which is the simplest and inefficient in case of a lot of numbers. You could use insertion sortor merge sort and quick sort. Quick sort is a good choice for large set of numbers. Any algorithms book will tell you how these sorts work. You should refer those and try and code. If you are a beginner then I suggest u learn bubble sort. Its easy to learn and understand.
Reply:The C API has a built in implementation for sorting using quick sort, which is very efficient. The man, page with details on how it works is at:





http://www.hmug.org/man/3/qsort.php





C also provides heap and merge sort built in implementations.


Write a C program that will convert Simple Sentences to Complex/Compound Sentence.?

Write a C program that will convert Simple Sentences to Complex/Compound Sentence.

Write a C program that will convert Simple Sentences to Complex/Compound Sentence.?
You already posted it here:





http://in.answers.yahoo.com/question/ind...
Reply:u have to include some other directory files in the library...
Reply:You sure you want to do this? if yes then here is the link and learn





http://64.233.183.104/search?q=cache:GlK...


Write a c program to evaluate a=(v-u)/t?

How do you end a c program starting with #include %26lt;stdio.h%26gt;?

Write a c program to evaluate a=(v-u)/t?
#include %26lt;stdio.h%26gt;


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


int main()


{


int a,v,u,t;


clrscr();


printf("Enter v,u,t");


scanf("%d %d %d",%26amp;v,%26amp;u,%26amp;t);


a=(v-u)/t;


printf("a=%d",a);


getch();


return 0;


}

floral bouquets

Write a C program in a Unix Operating System to count number of word in a file.?

Write a C program in a Unix Operating System to count number of word in a file. The main process will read from the user the file name and a positive number N which represents the number of lines in this file. Accordingly, the main process will greate N processes. E#ach process i will count and print the numbe of words in i-th line of the input file, where 1%26lt;= i %26gt;=n. The children processes should be implemented using the system call exec. Finally, the main rocess should print out the total number of words in the input file.

Write a C program in a Unix Operating System to count number of word in a file.?
That sounds like a homework problem to me.. albeit an interesting one. While you are at it, remember that given a sufficiently large value of N, you could hose the box with too many execs.





I will abstain from trying to code it since I am a bit short of time. but briefly, I would approach this problem thus





- A method that takes a line and counts the number of words in it


- There should be a global counter for words in the file.


- the method mentioned above should enter a synchronous block to update this global counter


- The main program should invoke N such threads and to each thread, pass the ith line in the file.


- Each of the threads should invoke the method mentioned above.


- Once each thread returns, the main method should output the global count





My 2 cents!
Reply:linux man page for wc:


http://man.linuxquestions.org/index.php?...
Reply:The simpliest way for you is to take wc (words count) UNIX utility source and tailor it for your needs.


How do you end a c program starting with #include <stdio.h>?

Write a c program to evaluate a=(v-u)/t?


How do you end a c program starting with #include %26lt;stdio.h%26gt;?

How do you end a c program starting with #include %26lt;stdio.h%26gt;?
#include%26lt;stdio.h%26gt;


void main(){


float v,u,t;


float a=0;


printf("enter initial velocity: ");


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


printf("enter final velocity: ");


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


printf("enter the time: ");


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


if(t!=0)


a = (v-u)/t;


printf("accelaration = %f",a);


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


void main()


{


int v,u,t,a;


printf("enter initial velocity,final velocity and time");


scanf("%d%d%d",%26amp;u,%26amp;v,%26amp;t);


a=(v-u)/t;


printf("accelaration = %d",a);


}


Write a C program to calculate and display the sum of the 2 largest nos in an array of 10 nos?

write a C program to calculate and display the sum of the 2 largest nos in an array of 10 nos and to also find the sum of the 2 smallest, and sort the numbers in ascending order.

Write a C program to calculate and display the sum of the 2 largest nos in an array of 10 nos?
I will not write the code for you here, but its a simple thing to do.





The program is all about sorting, and as the array is pretty small, you can put almost any algorithm to work. The simpler the better.





Summing up the numbers is the last thing.
Reply:#include%26lt;stdio.h%26gt;


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


void main()


{


int i,n[10],t;


printf("Enter the list of 10 nos==%26gt;");


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


scanf("%d",%26amp;n[i]);


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


{


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


{


if(n[i]%26gt;n[j])


{


t=n[i];


n[i]=n[j];


n[j]=t;


}


}


}


suml=n[0]+n[1];


sums=n[8]+n[9];


printf("suml,sums",%26amp;suml%26amp;sums);


}





i dont remember the exact syntax but somehow it will sort ascending or descending order


A program on a General tree having more than 2 child node in Data structure in C programming?

a C program on a General tree having more than 2 child node in Data structure in C programming. it is not a binary tree, but it should be a general tree where root node have three child node and each child node have three sub child node. want a help program on that

A program on a General tree having more than 2 child node in Data structure in C programming?
You just need three child node pointers.





struct Node {


struct Node * pChild[3];


int _your;


char _information


double _here;


}

dried flowers

A program on a General tree having more than 2 child node in Data structure in C programming?

a C program on a General tree having more than 2 child node in Data structure in C programming. it is not a binary tree, but it should be a general tree where root node have three child node and each child node have three sub child node. want a help program


Basically this is the tree.


user


:


:


user1.................................... user2................................... user3


: ............... : ........................................... :


Hari Oum .......Sandeep ... Jeganathan


24 .. 23 ... 24


Prod Develpment .. Voice Application .. Java Application


and i m not sure but as i think u can use


for storing data


char *array[] = {"user","user1","user2","user3","Harioum...

A program on a General tree having more than 2 child node in Data structure in C programming?
Please try searching the web using yahoo or google.


Write a C Program to declare an array for 2 0 floats.?

Write a C Program to declare an array for 2 0 floats. Accept the values from the user sort the two arrays in descending order. Merge the two arrays into a new array and display the new array.

Write a C Program to declare an array for 2 0 floats.?
what did you mean by 2 0 floats? is it 20 floats or 2.0 floats or what?





if you said 2D floats or 2 array of floats, i understand.





Let say you need to declare a 2D floats, so it will become like this:





float twod_flArray[20][20];





or





float twod_flArray[2][2] = {{1.0,2.0},{2.0,3.3}};





Sorting problem may be done by using a bubblesort algorithm.


There are a lot of it in the net, try to search.


To merge it, just append into the new array.
Reply:Homework I gather...


I'm guessing you would get a better response if you asked for help -vs- what appears to be a command to write it for you


Take care





Might also look into joining or creating a study group, good social / team building as well as helpful for study.


Michael Thurmond 6wk body makeover//TYPE C body PROGRAM?

I used to have Michael Thurmond 6wk body makeover when my husband was in bootcamp 3 years ago. It worked wonders!!! I have sense then lost the program and gained the weight. I remember I was a TYPE C body. Does anyone have the TYPE C body "diet" menu (portion and amount) plan? Not the recipes or anything, just the TYPE C program. How much of what I should eat. I remember there being a TON of meat and veges.


Please help me, I NEED to lose a good 15 lbs for this summer.


Thank you

Michael Thurmond 6wk body makeover//TYPE C body PROGRAM?
Hi, I good place for you to go and find out the menu is visiting Michael's site at www.mybodymakeover.com/forums. There is an actual forum for Type C support group in there.





Hope this helps. and Well wished to you!


Write a C Program to arrange a set of N numbers in an increasing order?

Write a C Program to arrange a set of N numbers in an increasing order

Write a C Program to arrange a set of N numbers in an increasing order?
This is a standard sort program. You can use bubble sort which is the simplest and inefficient in case of a lot of numbers. You could use insertion sortor merge sort and quick sort. Quick sort is a good choice for large set of numbers. Any algorithms book will tell you how these sorts work. You should refer those and try and code. If you are a beginner then I suggest u learn bubble sort. Its easy to learn and understand.
Reply:The C API has a built in implementation for sorting using quick sort, which is very efficient. The man, page with details on how it works is at:





http://www.hmug.org/man/3/qsort.php





C also provides heap and merge sort built in implementations.

gift baskets

Michael Thurmond 6wk body makeover//TYPE C body PROGRAM?

I used to have Michael Thurmond 6wk body makeover when my husband was in bootcamp 3 years ago. It worked wonders!!! I have sense then lost the program and gained the weight. I remember I was a TYPE C body. Does anyone have the TYPE C body "diet" menu (portion and amount) plan? Not the recipes or anything, just the TYPE C program. How much of what I should eat. I remember there being a TON of meat and veges.


Please help me, I NEED to lose a good 15 lbs for this summer.


Thank you

Michael Thurmond 6wk body makeover//TYPE C body PROGRAM?
Hi, I good place for you to go and find out the menu is visiting Michael's site at www.mybodymakeover.com/forums. There is an actual forum for Type C support group in there.





Hope this helps. and Well wished to you!


Write a C program to calculate and display the sum of the 2 largest nos in an array of 10 nos?

write a C program to calculate and display the sum of the 2 largest nos in an array of 10 nos and to also find the sum of the 2 smallest, and sort the numbers in ascending order.

Write a C program to calculate and display the sum of the 2 largest nos in an array of 10 nos?
I will not write the code for you here, but its a simple thing to do.





The program is all about sorting, and as the array is pretty small, you can put almost any algorithm to work. The simpler the better.





Summing up the numbers is the last thing.
Reply:#include%26lt;stdio.h%26gt;


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


void main()


{


int i,n[10],t;


printf("Enter the list of 10 nos==%26gt;");


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


scanf("%d",%26amp;n[i]);


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


{


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


{


if(n[i]%26gt;n[j])


{


t=n[i];


n[i]=n[j];


n[j]=t;


}


}


}


suml=n[0]+n[1];


sums=n[8]+n[9];


printf("suml,sums",%26amp;suml%26amp;sums);


}





i dont remember the exact syntax but somehow it will sort ascending or descending order


Write a C++ program that...?

Write a C++ program that computes and outputs the volume of a cone, given the diameter of its base and its height. The formula for computing the cone’s volume is:





1/3 Pi X Radius2 X Height





The output should be clearly labelled.

Write a C++ program that...?
Ok


When u r programming, try to divide ur program into functions, and if possible, try to divide each function into smaller and smaller functions, that makes it easier when u r trying to find errors in ur program, and when u r explaining the code to somebody else, this technique is called "divide and conquer".


Define a function that calculates the volume of the cone, this function should take 2 parameters, the radius and the height as double or float, and it should return the area as a double or float.





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


#define pi 3.1415926535


// Definition of the function (area of cone)


double cone_area(double height, double radius)


{


return (1/3)*pi*radius*height;


}





void main()


{


double raidus,height;


cout%26lt;%26lt;"We are going to calculate the area of a cone"%26lt;%26lt;endl;


cout%26lt;%26lt;"Enter its raidus: ";


cin%26gt;%26gt;radius;


cout%26lt;%26lt;endl;


cout%26lt;%26lt;"Enter it height: ";


cin%26gt;%26gt;height;


cout%26lt;%26lt;"Area of that cone = "%26lt;%26lt;cone_area(height,radius)%26lt;%26lt;endl;


}





Good luck


Bye
Reply:Can only answer Java questios.
Reply:This program should do it. I'm not sure what input you will use? This is just basic. And I used 22/7 for pi.





#include %26lt;iostream%26gt;


using namespace std;





int main()


{


float diameter = 0;


float height = 0;


cout %26lt;%26lt; "Enter the diameter:";


cin %26gt;%26gt; diameter;


cout %26lt;%26lt; "Enter the height:";


cin %26gt;%26gt; height;





float volume = 0;


volume = (1/3)*(22/7)*(diameter/2)*2*height;


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


}

wedding

HELP ME (C++!!), PROGRAM INSIDE!!?

#include%26lt;iostream%26gt;


int main()


using namespace std;


{


int x=12;


cout%26lt;%26lt;hex%26lt;%26lt;x;


return 0;


}


__________________________________


The result is "C", but i need it to display "00000C", i thought of doing it with IF statements and other variables, but that would slow down the program...

HELP ME (C++!!), PROGRAM INSIDE!!?
cout %26lt;%26lt; setfill ('0') %26lt;%26lt; setw (6);


cout %26lt;%26lt; hex %26lt;%26lt; 12 %26lt;%26lt; endl;





I'm not an expert on cout


Write a C++ program?

Write a C++ program that contains a structure named “Student” having two data members 1) Name2) CGPADeclare array of structure “Student” of size 10 .Populate this array by taking data from file inputFile.txt.File inputFile.txt contains Name and CGPA of the students for current semester. There is a single space between the Name and CGPA.Display the un-sorted list of students on screen. Compare the CGPAs of all the students and sort Student List with respect to CGPA in ascending or descending order.Display the sorted list of students, highest CGPA and lowest CGPA on screen and also write the result in File outputFile.txt with tab characters between the Name and CGPA.

Write a C++ program?
Sounds like a fun homework assignment for YOU TO DO YOURSELF.
Reply:I'd use a spreadsheet instead of C++. I'd copy the text file into the spreadsheet. Then the data can be sorted easily just go to data and sort. If this is for a class your book will tell you the correct commands to input, sort the data and then output the data into a text file. I have never used C++ but in basic an array was a place to store data. I would think you could use input or a similar command to input the data from the file then use display or a similar command to show the file on screen. Then use sort or a similar command to sort ascending or descending. Then use display or a similar command. Then use write, output or a similar command to make the output file.
Reply:read a tutorial and do it yourself, it's really easy.
Reply:how about in php?


Write a C program that will convert Simple Sentences to Complex/Compound Sentence.?

Write a C program that will convert Simple Sentences to Complex/Compound Sentence.

Write a C program that will convert Simple Sentences to Complex/Compound Sentence.?
So all you want is to concatenate the strings with ", but " in the middle and the second sentence has a lower case first letter.





I think that you can manage this easy task.


Can anyone convert the below c program to c++ program or just tell how to find the biggest no among the n no?

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


int max(int[],int,int);


main()


{


int a[100],i,n,temp,big;


clrscr();


printf("enter how many numbers:");


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


printf("enter the element");


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


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


big=a[0];


printf("the biggest no is",biggest(a,n,big));


getch


}


int max(int a[],int n,int big)


{


if(n==0)


return big;


else


n--;


if(a[n]%26gt;big)


big=a[n];


return (max(a,n,big));


}


reply soon only in c++ program. Thank u

Can anyone convert the below c program to c++ program or just tell how to find the biggest no among the n no?
Save as your file with extension CPP and replace header file stdio.h with iostream.h and also add conio.h for clrscr() and getch().





now replace all scanf() with cin%26gt;%26gt;num and you have no need to specify format characters(%d or %c) and also printf () with cout%26lt;%26lt; num without any format specfiers..
Reply:replace stdio by iostream in header


replace scanf("%d",%26amp;n) by cin%26gt;%26gt;n and so on


replace printf("...................",d,g,h) by cout%26lt;%26lt;".........."%26lt;%26lt;d%26lt;%26lt;g%26lt;%26lt;h; and so on


it will work
Reply:that also works in C++ no need to convert except for the libraries i think getch() is in stdlib.h and also use cin and cout instead of printf and scanf in the ipstream.h
Reply:This sounds like homework. What is the class?

flowers on line

I need help with this c++ program... if you love to do C++ please help me.?

a) Create a text file containing the following data (with out the headings):





Name Rate Hours





Gallaway,G. 6.00 40


Hanson,P. 5.00 48


Lasard,D. 6.50 35


Stillman,W. 8.00 50





b) Write a C++ program that uses the information contained in the file created in part 3a to produce the following pay report for each employee:





Name, Pay Rate, Hours, RegularPay, OvertimePay, Gross Pay





Regular pay is to be computed as any hours worked up to and including 40 hours multiplied by the pay rate. Overtime pay is to be computed as any hours worked above 40 hours times a pay rate of 1.5 multiplied by the regular rate and the gross pay is the sum of the regular and overtime pay. At the end of the report, the program should display the totals of the regular, overtime, and gross pay columns.

I need help with this c++ program... if you love to do C++ please help me.?
Hmmm this looks very familiar - are you trying to have other people do your homework? I hate that!
Reply:fine I'll tell you... this is not my homework... its my final exam... Report It



Write a C program to draw swastik afigure with *?

this is a C program using for loops

Write a C program to draw swastik afigure with *?
if you mean c++ then here is your answer man:





How to draw a diamond using asterix (*)





http://64.233.183.104/search?q=cache:utK...





drawing shapes using turbo c





http://en.allexperts.com/q/C-1040/Drawin...





and at last how to draw a pyramid :





http://www.physicsforums.com/archive/ind...





vote for me plz
Reply:well if its the code ur out for then go to


www.planetsourcecode.com





it has plently of usefull codes and programs


including C
Reply:May be you can contact a C expert. Check websites like http://oktutorial.com/


Write a c++ program that accept:-?

Write a c++ program that accepts:


1) Number of students and their name


2)Number of courses given and their title


3)mark of each course for each student


AND


a)calculate and display total and avarage of the courses for each student


b)Display the student name, total and average with maximum total.

Write a c++ program that accept:-?
Name and number,


title = confounded


avarage for grade for courses would be an F if done this way


student name = Yitbarek A with an average grade of failing the course.←


How can you make a C program that can create a windows file folder? Is it possible?

C programming codes for a program that can create a file folder. please help...this is part of our project in the finals...

How can you make a C program that can create a windows file folder? Is it possible?
For windows, use "CreateDirectory." Look on the MSDN web for complete usage. It should also be on your VS local help.
Reply:look into using the exec command to execute the shell and create it for you.(depends on the OS the program is running on)


The use file streams to create files and etc

florist shop

Can a unconditional loop of C program harm my processor???

Can never end(continious) program of C program harm my processor or any part of my PC or LAPTOP?????

Can a unconditional loop of C program harm my processor???
If you let it run long enough yes it could, but if you stop it fairly soon, such as shorter than 10-20 minutes it shouldn't do any harm to the system.
Reply:Not if the computer has been properly designed to be able to cool the cpu under worst case conditions.





You may want to have your program sleep for a few microseconds between loops to reduce the percentage of cpu usage.
Reply:No, not normally, although if it included two disk functions that slammed the drive head back and forth (instead of repeatedly addressing a buffer) it would wear on the machine eventually. Otherwise you are just slamming electrons back and forth and running down the battery.


What Program/Tool Can I use TO Host A Java/C Programming Competition? I want online problem submission?

I have ot find a program to be the server for a competition, i need some help in what to use. I want the server at minimun to accept java and c/c++ source files from teh user, as well as a correct/incorrect message.





Any Help is greatly appreciated!!!

What Program/Tool Can I use TO Host A Java/C Programming Competition? I want online problem submission?
As long as I have been programming, I have never heard of a SERVER that can CORRECTLY identify which programs are right or not, seeing as you could have many different styles of programming and have the same output.





If you want something like this, you can either make it yourself or you can pay someone to make it for you (a good idea would be a person who writes in php or some other advanced scripting language). This would be A LOT easier to do if it was a local (LAN based) contest. The internet complicates the whole process.





Good Luck.


HELP with a C++ program reading students grades from an infile and outputing the results to outfile?

I have to write a program the reads students grades together with their test grades. It suppose to compute the average test scores an then assign the appropriate grade. have to use a void function to determine the average for the five test scores and a value returning function to determine and return each students grade. the students grades are on an infile and i have to output it to an outfile.





This is what i have:


#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;





using namespace std;











calculateGrade(float);


int main ()


{


ifstream infile;


infile.open("C:\inGrade.dat");














ofstream outfile;


outfile.open("C:\FinalGrades.txt");





calculateGrade()








infile.close ();


outfile.close ();








system("pause");


return 0;


}





void calculateGrade(string, float)


{


if (average%26gt;=90)


outfile%26lt;%26lt;"A"%26lt;%26lt;endl;


else if(average%26gt;=80)


outfile%26lt;%26lt;"B"%26lt;%26lt;endl;


else if (average%26gt;=70)

HELP with a C++ program reading students grades from an infile and outputing the results to outfile?
http://computercomponents.spaces.live.co...


I am new to c,c++ program?

i type c++ program my seeing my text book and i used to save it, when i go to the folder it is in the form of text how do i convert it into program

I am new to c,c++ program?
You need some compiler to convert your text to program (exe). Boreland, or Microsoft VC++ or if u use linux u can use gcc.





Linux


------


1.Type pgm and save as a.c


2. from shell $gcc a.c


3. this will compile %26amp; create a.out


4. ./a.out will show u the result.





Windows


---------


Use any IDE that is best.





Refer "Balagurusamy" books he added topic how to compile the pgm in multiple IDE as an appendix
Reply:You have to compile it using a C++ compiler.

sympathy flowers

Help with this C++ Program?

The snack bar sells only six different items : a sandwich, chips, pickle, brownie, regular drink, and a large drink. All items are subject to sales tax. Set prices for the pdocuts.





The program should repeatedly display the menu below until the sale is totaled. The program should keep a running total of the amount of the sale based on the costs that you place in constants for each of the food items. The running total should be displayed somewhere each the menu is displayed again.





S - Sandwich


C - Chips


P - Pickle


B - Brownie


R - Regular Drink


L - Large Drink


X - Cancel and start over


T - Total the sale





If the sale is canceled, clear your running total and display the menu again. When the sale is totaled, calculatae the sales tax based on 7%. Print the final total due on the screen.





You can use your own functions to design a solution to the problem. You are required to use a function to calculate the sales tax. Other use of functions is up to you.

Help with this C++ Program?
i think that someone need to do their own home works ;)
Reply:I agree that you should do your homework, but since it looks like you have put forth some effort, I have no problem helping.





First off, declare your values for sandwich, chips etc in the beginning. There is no reason to keep re-assigning them.





double sandwich = 4.00;





After you have done that, change the part that prints out the menu to use those values instead of hard coded ones:





cout %26lt;%26lt; "S - Sandwich: $" %26lt;%26lt; sandwich %26lt;%26lt; endl;





Your sales tax function should be something like:





double getSalesTax(double amount)


{


return amount * .07;


}





you should probably have a printTotal too





void printTotal()


{


cout %26lt;%26lt; "Subtotal: $" %26lt;%26lt; setprecision(2) %26lt;%26lt; running_total %26lt;%26lt; endl;


cout %26lt;%26lt; "Sales Tax: $" %26lt;%26lt; setprecision(2) %26lt;%26lt; getSalesTx(runningTotal) %26lt;%26lt; endl;


count %26lt;%26lt; "Total: $" %26lt;%26lt; setprecision(2) %26lt;%26lt; (running_total + getSalesTax()) %26lt;%26lt; endl;


}





setprecision is in iomanip I believe.
Reply:yeah u should do ur own homework
Reply:class item


{


private char* name=null;


private char representativeChar=' ';


private float price=0;





public item (char* name, float price, char representativeChar)


{


this.name=name;


this.price=price;


this.representativeChar=representativeCh...


}





// Write getters and setters for all of the three variables


}





class menu


{


static float currentTotal=0.0;





public menu()


{


float SALES_TAX=7;


Item item[]={


new Item("Sandwich",4,'s'),


new Item("Chips",1.75,'c'),


.........................................


};


}





void displayMenu()


{


/*Similar to what you have already done but use objects instead of c like programming style */


cin%26gt;%26gt;inputChar;


while (inputChar != 'c' || inputChar != 't"')


{


..................................


}





if (inputChar == 'c')


currentTotal=0;





}





private addToCurrentTotal(int priceOfCurrentSelection)


{


currentTotal += priceOfCurrentSelection;


}





private float getCurrentTotal()


{


return currentTotal;


}








public float getTotalAmountDue()


{


return ( getCurrentTotal + (getCurrentTotal() * (SALES_TAX/100)));


}





public void resetCurrentTotal(){currentTotal=0;}


}








void main(char** args, int argc)


{


Menu m = new Menu();


m.displayMenu();


cout%26lt;%26lt;endl%26lt;%26lt;"Total Amount Due: " %26lt;%26lt;m.getCurrentAmountDue();


}


Open source GUI C++ program?

I know C++ fairly well, and I would like to create a program with a GUI, but i have no clue where to start. Is there an open source program I can download, preferably small, that is open source with a GUI and compiles on G++ compiler. Links please.

Open source GUI C++ program?
Heres a good place to start these are all free





http://www.ambrosine.com/resource.html





also check out this one


http://www.garagegames.com





not free but best community you will ever find
Reply:Check in sourceforge.net
Reply:See http://en.wikipedia.org/wiki/Widget_tool... . The google term Is GUI toolkit or Widget toolkit. To create a GUI, you need to learn a toolkit and then use it.





You haven’t mentioned your OS. So I’ll assume it’s Linux. The big players are GTK+ and QT. QT is the choice for KDE apps and GTK+ for Gnome. WxWidgets is popular as a cross platform toolkit, especially on Windows. Take a look. Each toolkit will have samples with source code.


Help with a very simple C program using 'for' to sum numbers?

hello





i am a C novice, and my teahcer wanted to make a program using for to sum the numbers that where before a certain number





for exmple input 5





5+4+3+2+1=15





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


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


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








void main()





{


int total,number,contador;





clrscr();


printf("inserte numero\n\n\n");


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





for(contador=numero; contador%26gt;0;contador--)


{


clrscr();





resultado1=numero+contador;





resultado1=resultado1+resultado1;

















}


printf("%d es el resultado\a\n", resultado1);





getch();





}








so, contaodor is supposed to decrease so that the 5,4,3,2,1 are added to 5, and the result should be 15





but, the program simply sums 5+1, the last number before 0, so the total is 6 and the other line insisde the for just does a stupid 6+6





i think the solution should be very easy but im tired as hell..





anyone can help please :P?

Help with a very simple C program using 'for' to sum numbers?
Hi Jose,





Try this out :





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


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


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








void main()





{


int resultado1=0,numero,contador;





clrscr();


printf("inserte numero\n\n\n");


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





for(contador=numero; contador%26gt;0; contador--)


{





resultado1 += contador;





}


printf("%d es el resultado\a\n", resultado1);





getch();





}
Reply:int result;





for(int i = contador; i %26gt; 0; i--)


{


result += i;


}


printf("%d", result);
Reply:Everyone is correct. You are just missing something in your code. Declare resultado1 up top and it should compile correctly as you intended it.


Pelase help me with this C program?

How can i do this program in C format the one that starts like this


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


main()


{


printf


scanf








}





This program will simulate a grocery store check out.





You will ask the user how many items they are purchasing today.


Then read in the individual prices one by one and add them together to get a total.


Tell the user the total of their purchases and ask them how much money they are giving you to pay for their purchase.


If they give you enough money, compute and display their change.


If they give you the exact amount display a message that they get no change.


If they do not give you enough money, tell them that and ask them to try again. Make sure they give you enough and don't compute their change until they do give you enough money.

Pelase help me with this C program?
Wow, that's a bit long.





First of all the app will ask the user for an integer input and store it in an int variable.





int count;


printf("How many groceries do you wish to buy?");


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





Once you've done that, the app will need to use a for loop in order to sum the total cost. You need to declare first another variable (call it "sum"). Also declare a temporary variable to store the input given each time (call it "temp").





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


{


printf("What's the next price?");


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


sum += temp;


}





Now print the total amount (I bet you can write it yourself). After that, you need to get the amount of cash given by the customer (let's store it in a variable called "pay"), and then write 3 if statements that deal with each and every one of the following options: Not enough money, the exact sum, and too much.





Not Enough: (Notice the use of a while loop)


while(pay %26lt; sum)


{


printf("You didn't give enough money! You need %d more",sum-pay);


scanf("%d", %26amp;temp); //Since we don't need temp anymore we can use it here


pay += temp;


}





Exact sum:


if(sum == pay)


printf("No change");





Too much:


if(sum %26gt; pay)


printf("Thank you. Your change is %d",pay-sum);
Reply:Your missing 2 main functions, actually 3, but that complicates things

bridal flowers

What is wrong with this c++ program?

I just started programming in C++ and need help. I created a basic adding program and it won't compile. What is wrong with it?


Here's the program:


//This program will add numbers


#include %26lt;iostream%26gt;


#include %26lt;cstdlib%26gt;


#include %26lt;cstdio%26gt;


using namespace std;





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


{


char quit;





quit = '\0';


while (quit != 'q')


{


int x;


cout %26lt;%26lt; "enter the 1st value";


cin %26gt;%26gt; x;


int y;


cout %26lt;%26lt; "enter the 2nd value";


cin %26gt;%26gt; y;


int a;


a = x + y;


cout %26lt;%26lt; "The sum of the two values is:";


cout %26lt;%26lt; a %26lt;%26lt; endl;


}


system("PAUSE");


return 0;


}

What is wrong with this c++ program?
For starters, you DONT want a ; after your main function :





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


^ WRONG!





Update: And the new errors are?


You probably need different header files -- specific to the compiler you are using. Which compiler are you using?





Try using stdio instead of cstdio and stdlib instead of cstdlib
Reply:along with above advices use


while(getchar(quit)!='q')





and add these lines after cout%26lt;%26lt;a%26lt;%26lt;endl;





cout%26lt;%26lt;"Enter q to quit";
Reply:mdigitale is correct about the stray semicolon after main. He expressed it a bit inaccurately though.





You don't want a semicolon after a function *definition*. You want it after a declaration. In your case, you are defining main. You are writing the code inside it. Careful on the semicolons.





mdigitale is however, incorrect about the headers. %26lt;iostream%26gt;, %26lt;cstdio%26gt;, and %26lt;cstdlib%26gt; are the correct forms. The change was made in the 98/99 revision of C++. Yes, that's nearly a decade ago. If you try to compile with the C style header format in any modern compiler, you will get a diagnostic message. Usually as a warning.





Just as a note, cstdlib isn't needed because you use no functions from it.





After removing the semicolon, you should have no further errors. If you do, do tell us **verbatim** what those errors are. As magical programmers seem to be, we aren't psychics. We do not read your mind remotely.





Your logic has an error in it. The while loop depends on quit, but quit will never change because you never asks for user input.





When posting code, please use a pastebin like http://www.rafb.net/paste/ . You can google for other nopaste or pastebin sites.The idea is to preserve indentation, and perhaps have formatting so we can actually read your code. Then we can help you.


Saturday, May 22, 2010

I'm having trouble running my C++ program after i compile and link it?

I just start programing in the C language. I Use Microsoft developer studio standard (if there something better, add that, though i can't choose you as best answer unless you answer my actual question). I'm also learning from "C for dummies".





well, enough of that, I made my first program. all it does is say "goodbye crule world" (in contradicts the "hello world" prgram.) So I compiled and linked my .C file into a .exe file. when i open the source file and go to "run GOODBYE.EXE" it works fine. but when i got to my documents and open the .EXE file there, it breifly opens and then closes. and i didn't push the any key (which my book says is enter :) )





so, help me out here, why doesn't it stay?

I'm having trouble running my C++ program after i compile and link it?
When you run a console program from the windows explorer, it opens a console, runs your program, and then the console closes as soon as your program finishes. Whereas, when you run it in visual studio, the compiler doesn't close the console window right away, and waits for your input first.





There are two ways to get around this.





One way is to run your program from the command line instead of the from the explorer. If you know how to use the dos command line, this is your easiest option.





The second way is to make your program pause before terminating. To do so, add the following line at the end of main():





cin.get();
Reply:The program runs. Here's the deal windows runs fast enough that it will open a cmd windows display "goodbuy crule world" read the return 0; in your code and exit all in about the time it takes to blink! ( I've had the same problem before ). Try adding this to the end of your code.





#include %26lt;iostream%26gt;


using namespace std;


cout %26lt;%26lt; "enter any number to exit /t" %26lt;%26lt; endl;


int completely_useless_num;


cin %26gt;%26gt; completely_useless_num;


return 0;





// happy coding
Reply:Ok, first you need to get your terminology right. This is computer programming and computer science: precision is important. C++ and C are different. I’m assuming you’re are writing a C program. Not a C++ program. Second, there’s no such thing as Developer Studio. I’m assuming you are using Visual Studio? You also should mention the version. It’s important. VS 2005? VS 2003? VC++ 6? Don’t skimp on details.





Next, don’t use C for dummies. Think about it for a moment. If you find C difficult, you need to pick a different programming language. C is naturally complex. It’s a low level language, so you don’t have much logical abstraction. And it has quirks. It is difficult. The book I recommend is K %26amp; R’s The C Programming Language. Only that. It is the de facto book on C, and you should get that. If you find C too difficult to start with, pick a different language, please.





Now, onto the actual program. The program you created is what is known as a console program. If you go to start-%26gt;run-%26gt;”cmd”, you get a console or command line. You should learn to run programs from there. As a beginner, it’s acceptable to use a kludge: #include %26lt;stdio.h%26gt; and at the end of the main, add getchar();
Reply:Windows automatically closes any console program launched from the file browser as soon as it is finished running. So once your program prints its message, there's no more code, it exits, and Windows closes it. This only takes a millisecond or so to process, much too fast for a human being to read.





Just add this line:





getchar();





Put it in your program right under your printf() statement. This will cause the program to wait for one character of input. It doesn't do anything with the input since the function isn't assigned to any variable. But it will wait, as long as it takes, to get at least one character from the user. Until it gets that, it won't exit.
Reply:lol You know that C++ and C are two different languages right? I could help you in C++ but C might have a different way of doing it.





before the last return statement put





cin.get();


cin.get();





It'll pause the screen, waiting for input from the user (clicking any button).





I put 2 down b/c 1 doesn't always work. This is the simplest way I've found to do it. And I'm sorry if that doesn't help in C, I know how frustrating programming can be.


Help me with a c++ program plz?

Hey, I'm supposed to write a c++ program that plays the game hangman.


It's supposed to read in a bunch of words from a file that contains strings, it has to store the strings in an array of strings. Then print out a series of underscores and letters which represent the answer like s__ francis__. The user has to enter a letter, if it's incorrect print out a part of a man on the gallows with dashes and such. If it is correct put it in the word. Also I'm supposed to use 2 functions in the program. The file that the words will be read from will be up to 1000 lines long. And the program has to use strings to store the words not arrays.





Can someone plz explain how to do it or help me get started plz





Im not good with strings or arrays, im not sure how exactly i'm supposed to read stuff in from the file and store it in an array of strings

Help me with a c++ program plz?
Dude! This is not going to be a quick simple little program.





Id break it into chunks as follows:





1) Write a routine to read in the words and store them into the array of strings. Here are a couple of variables:


string myWords[1000];


short wordCount=0;


This could be a function or could just be at the beginning of main().





2) Write a function to display the gallows. This is probably the hardest part. I would suggest making your display just a few arrays of data and then assigning values as needed. For example, your gallow initialization could look something like


char gallows[10]={


" //========= ",


" || ",


" || ",


" || ",


" || ",


" || ",


" || ",


" || ",


"/||\ ",


"
Reply:
Reply:__________"}





Then, your routine would know that when one letter is wrong, it should change gallows[1], [2], and [3] to include characters for a head. When the second one is guessed wrong, 4, 5, and 6 get the body parts and so on.





The screen should be cleared each time you display the gallows. You should also display the letters under the gallows and guessed letters above it.





This means you'll need an array (size 26) for missed letters and another array, initialized with underscores and the size of the maximum word you expect.





You'll need to create another function to perform the letter check. This should make sure the letter hasn't already been used and if not, see if the letter exists in the word being guessed. If it doesn't, then the letter position corresponding to their guess is filled in within the missed letters array and the count (for the gallows display) is increased. If it is correct, replace the appropriate underscore with the correct letter.





There's an awful lot more to a program like this and it could take pages to provide more help. I'd suggest you work on small parts and then assemble those working parts to make the whole program.
Reply:You may want to make an object that contains a string and forward/backward pointers for a linked list. When you read a word, use new to get an instance of the object, put the word into the string member of the object and link the object to a list of other such objects. You can even sort the list if you need to. (It doesn't use arrays. Maybe that is what your instructor expects).





Be sure to delete all the objects in the list when you exit. It's good form.
Reply:The most eazy way is to use STL:





#include %26lt;string%26gt;


#include %26lt;vector%26gt;


using namespace std;





typedef vector %26lt;string%26gt; string_vector;


...


To add string to your array (i.e.vector):





void add_string( string_vector %26amp; sv, const string %26amp; s )


{


sv.push_back( s );


}





To get string from array:





string * get_string( string_vector %26amp; sv, int index )


{


size_t sz = sv.size();


if( !sz )


return 0;


if( index %26gt;= sz )


return 0;


return %26amp; sv[index];


}





...etc.





To learn more about STL, visit this site:


http://www.sgi.com/tech/stl/
Reply:Step 1: Learn how to read and write a file.


http://www.cplusplus.com/doc/tutorial/fi...





Step 2: Learn how strings work.


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





Step 3: Learn how arrays work, indexing


http://www.cplusplus.com/doc/tutorial/ar...





This page might answer some questions too.


http://www.research.att.com/~bs/bs_faq2....


How do you write a c program to calculate the roots of the 2nd order equation: ax^2+bx+c?

The program should include the solutions for the following special cases:


a. a=0


b. b=0


c. c=0


d. a, b, c %26lt; 0


e. b^2 - 4ac %26lt; 0

How do you write a c program to calculate the roots of the 2nd order equation: ax^2+bx+c?
See the wikipedia article below for information about quadratic (i.e. 2nd order) equations. It describes the quadratic formula. The most common way to write a computer program for this task is to write a C version of the quadratic equation.





Then test, test test! Test each of the special cases, as well as more "normal" cases.

wedding reception flowers

Need help with a C++ program, I need to know how to make the program end when the statement is false?

#include %26lt;iostream%26gt; //Required for all C++ programs


#include %26lt;iomanip%26gt; //Part of the standard library for input/output, required for setw function


using namespace std;





int main() // Beginning of program


{


int choice;


double seconds,answer;


double speed;


bool validInput = true;





cout %26lt;%26lt; "\t\tMenu\n";


cout %26lt;%26lt; "---------------------------------------...


cout %26lt;%26lt; "1. Carbon Dioxide" %26lt;%26lt; endl;


cout %26lt;%26lt; "2. Air" %26lt;%26lt; endl;


cout %26lt;%26lt; "3. Helium" %26lt;%26lt; endl;


cout %26lt;%26lt; "4. Hydrogen" %26lt;%26lt; endl;


cout %26lt;%26lt; endl;


cout %26lt;%26lt; "Please select one of the gases from the list." %26lt;%26lt; endl;


cout %26lt;%26lt; "Enter your choice, 1-4: ";


cin %26gt;%26gt; choice;


cout %26lt;%26lt; endl;





if (choice %26lt;=0 || choice %26gt;=5)





cout %26lt;%26lt; "You did not choose a correct number please try again." %26lt;%26lt; endl;


else


(choice %26gt;=1 || choice %26lt;=4);





cout %26lt;%26lt; "Enter the time in seconds that the soundwave traveled between 1-30: ";


cin %26gt;%26gt; seconds;


cout %26lt;%26lt; endl;





if (seconds %26lt; 0 || seconds %26gt; 30)





cout %26lt;%26lt; "Sor

Need help with a C++ program, I need to know how to make the program end when the statement is false?
You have more than one area in which the user enters a choice, If you are asking how do you end your program at a point in which the user has entered invalid information,





switch your





if (choice %26lt;=0 || choice %26gt;=5)


cout %26lt;%26lt; "You did not choose a correct number please try again." %26lt;%26lt; endl;


To:


if(choice %26lt;=0 || choice %26gt;= 5)


{


cout %26lt;%26lt; "You entered invalid information" %26lt;%26lt; endl;


return 0;


}





The bottom switch statement you would add:





default:


cout %26lt;%26lt; "You entered invaid number" %26lt;%26lt; endl;


return 0;








Anytime you return from main, the program is over.
Reply:first of all you need a default case in your switch down at the bottom, but what statement are you talking about?