I've forgotten the program we used to write C programs. i need to be able to write, test, compile and debug programs written in C programming language... what's the program to use?
What program do i use for writing and testing and compiling C programs?
microsoft's visual c++
Reply:www.cprogramming.com/
www.cyberdiem.com/vin/learn.html
www.math.utah.edu/~beebe/software/c-to...
Here's a few to get you started
Reply:Codeblocks is a great easy and free IDE
Visit http://www.codeblocks.org/
Reply:Don`t bother with visual studio if you are a begginer. It`s a great tool definitely the best, but i think something simpler would be more convenient for you
It`s called DevCpp from Bloodshed. Its an easy to use IDE, with samples, and It`s 100% free.
Friday, July 31, 2009
Is there any C++ programming competition for kids?
My 9 year old is into C++ programming. Is there any competition for kids?
Is there any C++ programming competition for kids?
I doubt that there is such a competition. Yahoo Answer may not be the best place to find the answer. Check out google group http://groups.google.com/group/comp.lang...
Anodizing 101: Opportunities are never lost. The other fellow takes those you miss.
Torrey Hills Technologies, LLC
http://www.threerollmill.com
http://www.torreyhillstech.com
http://www.anodizingracksonline.com
http://www.beltfurnaces.com
Is there any C++ programming competition for kids?
I doubt that there is such a competition. Yahoo Answer may not be the best place to find the answer. Check out google group http://groups.google.com/group/comp.lang...
Anodizing 101: Opportunities are never lost. The other fellow takes those you miss.
Torrey Hills Technologies, LLC
http://www.threerollmill.com
http://www.torreyhillstech.com
http://www.anodizingracksonline.com
http://www.beltfurnaces.com
How to write a c program that chooses 3 out of 5 largest numbers?
Hi everyone! I was wondering if you could help me write this C program. I've spent a lot of time on it and I can't think of anything good. Hints would be appreciated as well :D
"Write a complete C program that will ask a user for 5 integer numbers and will print out on the screen the three largest. "
Thank you!
How to write a c program that chooses 3 out of 5 largest numbers?
no offense, but this is very basic. This has little to do with C language, you need to think on how to figure out which is the largest numbers. This is more of an exercise on how you can think logically than it is programming.
You need to do a comparison, and the largest number needs to be held and then compared against the others. Once you figure out the largest, you do a comparison with the 4 remaining, until you have the 3 largest.
Reply:I'll leave the actuall coding to you, but for the logic, you'll want to store them into an array of ints, run them through the sort routing of your choice (knowing it's only 5 elements means you can use any method, even the brute force methods, and it will be pretty cheap), then output elements 0-2 (or 2-4, depending on how you sort) of the array.
Reply:Define four integers. One for Input, a Largest, Second and Third.
I would initialize them all to zero because it's Hip, Modern, and you never know what garbage is lurking in your memory unless you watch old episodes of Reboot.
Repeat five times:
Get the Input number.
Compare it to Largest.
If Input is bigger than Largest
swap Third and Second
swap Largest and Second
swap Input and Largest
Else if Input is bigger than Second
swap Third and Second
swap Input and Second
Else if Input is bigger than Third
swap Input and Third
Else do nothing.
End Repeat five times.
Print Largest, Second and Third.
End program.
"Write a complete C program that will ask a user for 5 integer numbers and will print out on the screen the three largest. "
Thank you!
How to write a c program that chooses 3 out of 5 largest numbers?
no offense, but this is very basic. This has little to do with C language, you need to think on how to figure out which is the largest numbers. This is more of an exercise on how you can think logically than it is programming.
You need to do a comparison, and the largest number needs to be held and then compared against the others. Once you figure out the largest, you do a comparison with the 4 remaining, until you have the 3 largest.
Reply:I'll leave the actuall coding to you, but for the logic, you'll want to store them into an array of ints, run them through the sort routing of your choice (knowing it's only 5 elements means you can use any method, even the brute force methods, and it will be pretty cheap), then output elements 0-2 (or 2-4, depending on how you sort) of the array.
Reply:Define four integers. One for Input, a Largest, Second and Third.
I would initialize them all to zero because it's Hip, Modern, and you never know what garbage is lurking in your memory unless you watch old episodes of Reboot.
Repeat five times:
Get the Input number.
Compare it to Largest.
If Input is bigger than Largest
swap Third and Second
swap Largest and Second
swap Input and Largest
Else if Input is bigger than Second
swap Third and Second
swap Input and Second
Else if Input is bigger than Third
swap Input and Third
Else do nothing.
End Repeat five times.
Print Largest, Second and Third.
End program.
Anyone know a GOOD book for C++ programming?
I need a good book for learning C++. I am in C++ Programming II in college and certain things I have trouble grasping and the text we use sucks.
Anyone know a GOOD book for C++ programming?
When it comes to programming books, O'Reilly is pretty much the gold standard:
http://www.oreilly.com/pub/topic/cprog
But if you're on a budget, you can find a dozen or so free on-line books on C++ programming here:
http://www.freeprogrammingresources.com/...
Reply:ivor horton's
white flowers
Anyone know a GOOD book for C++ programming?
When it comes to programming books, O'Reilly is pretty much the gold standard:
http://www.oreilly.com/pub/topic/cprog
But if you're on a budget, you can find a dozen or so free on-line books on C++ programming here:
http://www.freeprogrammingresources.com/...
Reply:ivor horton's
white flowers
How to check if a number is odd or even without using the modulus in c programming?
I assume that your number is an integer. Easiest is to use the bitwise "and" operation:
if ((x %26amp; 1) != 0) printf ("x is odd\n");
------------------
The questioner asked for further detail in email, so:
Well, if this is about an exam, I'm sure that they've covered bit operations in C.
C = A %26amp; B; means AND all of the bits of A and B together. Each bit in C is set if and only if both corresponding bits are set in A and B.
C = A | B; means OR all of the bits of A and B together. Each bit in C is set if either corresponding bit is set in A and B.
C = A ^ B; is an "exclusive OR" (XOR). Each bit in C is set if the corresponding bits bits in A and B are different.
So, in my original answer the result of the expression (A%26amp;1) will have 0's in all but the lowest bit. The lowest bit will be equal to the lowest bit of A.
And in binary, any even number has a lowest bit equal to zero, and any odd number has a low bit equal to 1. (It's kind of like in decimal, that any number divisible by 10 has a last digit of 0.)
There are other ways you could have done this, such as:
if ((a/2)*2 == a) printf ("a is even\n");
but the %26amp; example is much more efficient.
Good luck.
How to check if a number is odd or even without using the modulus in c programming?
if (x/2)=round(x/2) then even else odd?
I guess that would work.
if ((x %26amp; 1) != 0) printf ("x is odd\n");
------------------
The questioner asked for further detail in email, so:
Well, if this is about an exam, I'm sure that they've covered bit operations in C.
C = A %26amp; B; means AND all of the bits of A and B together. Each bit in C is set if and only if both corresponding bits are set in A and B.
C = A | B; means OR all of the bits of A and B together. Each bit in C is set if either corresponding bit is set in A and B.
C = A ^ B; is an "exclusive OR" (XOR). Each bit in C is set if the corresponding bits bits in A and B are different.
So, in my original answer the result of the expression (A%26amp;1) will have 0's in all but the lowest bit. The lowest bit will be equal to the lowest bit of A.
And in binary, any even number has a lowest bit equal to zero, and any odd number has a low bit equal to 1. (It's kind of like in decimal, that any number divisible by 10 has a last digit of 0.)
There are other ways you could have done this, such as:
if ((a/2)*2 == a) printf ("a is even\n");
but the %26amp; example is much more efficient.
Good luck.
How to check if a number is odd or even without using the modulus in c programming?
if (x/2)=round(x/2) then even else odd?
I guess that would work.
C Programming: How do you calculate the average in a loop?
hi guys, i just want to ask something about this program im making for my assignment.
im supposed to make a program that will display numbers 10 to 100 with intervals of 10, in the left column and the profit(5% of the sales) on the right column. after the loop ends, the average of the sales should be displayed at the bottom. and my question is... whats the code for calculating the average of the loop?
here's my code:
#include %26lt;stdio.h%26gt;
void main()
{
float sales, avg;
printf("Sales Projection (in thousands).\n\n");
printf("\tSales\tProfit\n");
for (sales=10;sales%26lt;=100;sales+=10)
{
printf("\t$%.f\t$%.2f\n",sales, sales*0.05);
}
printf("\n\tAverage Sales: $%.2f", avg);
}
any help would be very much appreciated ^^
C Programming: How do you calculate the average in a loop?
The average is the sum of the items divided by the number of items. But you knew that.
Declare a variable to hold the sum and initialize it outside the loop
float, sales, avg, sum;
sum = 0;
While you are printing out the sales, keep a running total inside the loop
sum += sales;
after the loop, calculate the average
avg = sum / 10;
In the more general case, you'd know beforehand or calculate how many items you added up, and you'd divide by that instead of by the constant 10.
Reply:Use below code
#include %26lt;stdio.h%26gt;
void main()
{
float sales, avg=0.0;
printf("Sales Projection (in thousands).\n\n");
printf("\tSales\tProfit\n");
for (sales=10;sales%26lt;=100;sales+=10...
{
printf("\t$%.f\t$%.2f\n",sales... sales*0.05);
avg+=sales;
}
avg/=10;
printf("\n\tAverage Sales: $%.2f", avg);
}
im supposed to make a program that will display numbers 10 to 100 with intervals of 10, in the left column and the profit(5% of the sales) on the right column. after the loop ends, the average of the sales should be displayed at the bottom. and my question is... whats the code for calculating the average of the loop?
here's my code:
#include %26lt;stdio.h%26gt;
void main()
{
float sales, avg;
printf("Sales Projection (in thousands).\n\n");
printf("\tSales\tProfit\n");
for (sales=10;sales%26lt;=100;sales+=10)
{
printf("\t$%.f\t$%.2f\n",sales, sales*0.05);
}
printf("\n\tAverage Sales: $%.2f", avg);
}
any help would be very much appreciated ^^
C Programming: How do you calculate the average in a loop?
The average is the sum of the items divided by the number of items. But you knew that.
Declare a variable to hold the sum and initialize it outside the loop
float, sales, avg, sum;
sum = 0;
While you are printing out the sales, keep a running total inside the loop
sum += sales;
after the loop, calculate the average
avg = sum / 10;
In the more general case, you'd know beforehand or calculate how many items you added up, and you'd divide by that instead of by the constant 10.
Reply:Use below code
#include %26lt;stdio.h%26gt;
void main()
{
float sales, avg=0.0;
printf("Sales Projection (in thousands).\n\n");
printf("\tSales\tProfit\n");
for (sales=10;sales%26lt;=100;sales+=10...
{
printf("\t$%.f\t$%.2f\n",sales... sales*0.05);
avg+=sales;
}
avg/=10;
printf("\n\tAverage Sales: $%.2f", avg);
}
C Programming: How can I count Decimal Places!?
My program uses scanf to take the value of a floating number. The problem is, I want it to also tell how many decimal points there were in the number.
For example, let's say someone inputs in 2.34. I want my program to know that there are 2 decimal places, as well as store the value of 2.34 as some variable.
Any bright ideas?
C Programming: How can I count Decimal Places!?
I would use sprintf() to convert it from a float to a string and then search the string for the decimal and count the digits after it.
Reply:1. First, convert your floating point number into integer. i.e. 2.34 --%26gt; to 2.
2. Subtract the integer from the floating point number. i.e. 2.34-2=0.34.
3. Multiply the difference by 10. ==%26gt; 0.34*10=3.4 parallely increment the counter say i=1.
4. Go to the step one. Repeat until the difference turns out to be zero.
Reply:convert to string,
subtract the location of the decimal point in the string from the length of the string
For example, let's say someone inputs in 2.34. I want my program to know that there are 2 decimal places, as well as store the value of 2.34 as some variable.
Any bright ideas?
C Programming: How can I count Decimal Places!?
I would use sprintf() to convert it from a float to a string and then search the string for the decimal and count the digits after it.
Reply:1. First, convert your floating point number into integer. i.e. 2.34 --%26gt; to 2.
2. Subtract the integer from the floating point number. i.e. 2.34-2=0.34.
3. Multiply the difference by 10. ==%26gt; 0.34*10=3.4 parallely increment the counter say i=1.
4. Go to the step one. Repeat until the difference turns out to be zero.
Reply:convert to string,
subtract the location of the decimal point in the string from the length of the string
Subscribe to:
Posts (Atom)