Join 136,419 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,352 people online right now. Registration is fast and FREE... Join Now!
Hi, m new with C not C++,,but i come to know that c there is only commands difference between c and c++ but plz help me making program in c not in c++ well i hav 4-5 programs to b completed till friday,,as my assignments,,i didn't get the lectures bcoz of some reason and now facing problem
programme statements are
1- Write a program in C which takes three input integers from the user and display the minimum, middle and maximum integers given by the user as input.
2- Write a program in C to perform different airthmetic operations using switch statement. The program will take two input integers from the user and then an airthmetic operator from the user to perfrom the specific operation on the given two integers.
3- Write C code to calculate the factorial of a positive integer given by the user as an input. Use the do/while structure ro accomplish this task.\
4- Write a program in C which will perform Addition, Subtraction, Multiplication and Division on two integers given by the user as input, program should have different functions (for example Add, Sub, Mul and Div) to perform these airthmetic operations.
I shall b very thankful if someone make programs to the above questions Thankss
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.
1- Write a program in C which takes three input integers from the user and display the minimum, middle and maximum integers given by the user as input.
2- Write a program in C to perform different airthmetic operations using switch statement. The program will take two input integers from the user and then an airthmetic operator from the user to perfrom the specific operation on the given two integers.
3- Write C code to calculate the factorial of a positive integer given by the user as an input. Use the do/while structure ro accomplish this task.\
4- Write a program in C which will perform Addition, Subtraction, Multiplication and Division on two integers given by the user as input, program should have different functions (for example Add, Sub, Mul and Div) to perform these airthmetic operations.
I shall b very thankful if someone make programs to the above questions Thankss
If you do a little web searching ... you should come up with LOADS of examples for these very common example problems.
Don't be afraid to look in other very simple languages. like Python, for these common example problems that each teach some basics...
(If you really can program in C++, these problems should be NO real challenge ... just a matter of a little conversion to C)
In any case, (C may require a lot more programmer work than C++), here is a link to a very well worn free course in C ...
well thanks for the link,,,i will post my programs which i made,, then i will ask questions from them,,actualy my concepts are not that much clear thats why i face prob. in creating a program,, any way i will post my program after 9-10 hours bcoz i don't hav rite now here,,its in an other PC once again thanks for yours rplies
/* Problem 1 -(To get you started) ... a program in C which gets 3 integers from the user, via the keyboard, and then displays the minimum, middle and maximum integers in order.
We can use a simple bubble sort for ordering the numbers.
Note: C doesn't support passing by ref so easily as C++ does ...
We must pass the address in ... of the object being passed Then 'catch' that address as a 'pointer' (i.e. an address) for the object
*/
/* Here ... we tell the compiler that a,b,c are all addresses for int's */ void sort(int* a, int* b, int* c) { int temp; /* using a BUBBLE SORT: first ... 'bubble' the highest to c then 'bubble' the next highest to b ... and we are done
NOTE: below ... *a and *b take the int values at addresses a and b since on the top line we told the compiler that a and b were pointers to (i.e. addresses for) 'int' */ if( *a > *b ) /* if value at address a > value at address b then swap */ { temp = *a; *a = *b; *b = temp; } if( *b > *c ) /* swap */ { temp = *b; *b = *c; *c = temp; } if( *a > *b ) /* swap */ { temp = *a; *a = *b; *b = temp; }
}
int main() { int a=0, b, c, t; for(;;) { printf( "Input 3 non zero integers to be ordered : " ); a=b=c=0; /* use these zeros as flags for bad data input */ scanf( "%d%d%d", &a, &b, &c ); while( (t=getchar()) != '\n' ) ; /* flush stdin */
/* check for bad data ... */ if( a==0 || b==0 || c== 0 ) { printf("\nIntegers only ... "); continue; /* from the top of the for loop ...*/ }
sort( &a, &b, &c ); /* pass addresses to sort function */
printf( "Now in order %d %d %d\n\n", a, b, c );
printf("Press 'Enter' to continue ... 'x' to exit ... "); t =getchar(); if ( t=='x' || t=='X' ) return 0; if ( t !='\n') while( (t=getchar()) != '\n' ) ; /* flush stdin */ } }
This post has been edited by David W: 16 Oct, 2008 - 01:17 PM
Thank you for your enthusiasm and contributions however please make sure you read the forum rules. We are not supposed to provide code unless the poster has shown an effort to solve the problem.
Moderators will often remove your solution if the user has not shown an effort.
Moderators will often remove your solution if the user has not shown an effort.
Thanks for the info ...
Here ... as stated ... I thought that ONE example ... might help?
"Problem 1 - (To get you started) ..."
As you might have experienced, if you came to C after learning C++ first, ... that initially C, may present quite a challenge ... if you are going there from all the nice things available only in C++, (passing by ref is just one.)
This forum is a great place to learn. I recall how difficult it was for me to get started. My goal is to help 'break the ice' .... so to speak. There are lots of hard problems ahead ... after one gets 'a break through' ... and gets a start.
I appreciate your kind words.
Shalom,
David
This post has been edited by David W: 17 Oct, 2008 - 03:22 AM