TRENDING NEWS

POPULAR NEWS

Question About C Coding

A question about C++ coding?

What you're looking for is an editor and a compiler. Generally, when the two are packaged together (usually with a debugger, as well), it's considered an IDE (Intergrated Development Environment). The more popular free IDEs are Visual C++ Express, Dev-C++, or Code::Blocks. The first of the three using Microsoft's C++ compiler, while the latter two use the MinGW port of GCC (G++). Avoid Turbo C++ if someone suggests it.

Question in C programming?

1) exclusive or.

a ^= 0x20;

2) pretty easy, ask user for a string to print and the number of times to loop. If the string is equal to "q" or "Q", quit the program. If not make a for loop that loops "number" times, printing out the string. Repeat using a do while loop.

EDIT: Sorry, thats what I get for answering before coffee. Thought he meant toggle the bit irrespective of its initial value.

Beginner, C++ PROGRAMMING HELP! 2 QUESTIONS! Coding provided...?

1 Code:

The problem is in your #include section

#include
#include //You didn't close
#include //You need this to utilize the input/output standard
#include //You need this to utilize system from the library standards

#2

Going to help you via comments, and hopefully you'll be able to code it.

Variables>>
// US_currency [float] // To save user's dollar amount
// Convert_currency [float] //To convert from user's dollar amount
// choice = 0 //For user's choice
// CANADIAN = 1.01615
// EURO = 0.638490
// INDIA = 40.1798
// JAPAN = 104.390
// MEXICO = 10.4613
// S_AFRICA = 7.60310
// UK = 0.504285
//start do-while loop
DO{
// ASK USER TO ENTER AMOUNT TO CONVERT IN US Dollars (no $)
// SAVE INTO US_Currency variable
// DISPLAY THE CHOICES FOR CONVERSION:
1. Canada Dollar
2. Eurozone Euro
3. India Rupee
4. Japan Yen
5. Mexico Peso
6. South Africa Rand
7. United Kingdom Pound
//Ask user to enter choice
// Save choice into choice variable

switch(choice)
{
case 1: Convert_currency = US_currency * CANADIAN; break;
case 2: Convert_currency = US_currency * EURO; break;
case 3: Convert_currency = US_currency * INDIA; break;
case 4: Convert_currency = US_currency * JAPAN; break;
case 5: Convert_currency = US_currency * MEXICO; break;
case 6: Convert_currency = US_currency * S_AFRICA; break;
case 7: Convert_currency = US_currency * UK; break;
default: choice=0;
} while(choice < 1);

//Display the US Dollar amount
//Display the choice and its Converted amount

It’s the ternary operator ( C Programming Tutorial ). It’s just a more concise way of writing an if-else statement. The following two code snippets are equivalent.if (x == 3) {
x++;
}
else {
x--;
}
x == 3 ? x++ : x--;
Some programmers find it confusing to read, especially if the expressions get longer. The most accepted use is with variable assignment.x = isTrue() ? 4 : 5;
It allows you to only write “x =” once instead of twice with the equivalent if-else.

I'll add a great resource that has recently launched: A community-driven list of C++ interview questions: Great C++ Interview Questions. Also, I found this slide extremely helpful while researching C++ interviewing on my own: Deep C. Good luck!

When people talk about C++ interview, usually it has two types: interview that focuses on the language itself and coding interview in C++. It's better for you to be clear about which one you are preparing for and I'll share some resources for both. It's not that common to have interviews that are mostly focused on the language, so I'll start from the coding interview in C++. In reality, the language doesn't really matter in this case and you don't need to remember all those syntax like STL functions either. What's more important is to have a solid foundation of data structures/algorithms that will help you solve those coding questions. Some recommended resources are:Coding interview questions and analysisLeetcodeGfgFor language interviews, nothing you can do but be really familiar with C++. The sad news is that C++ is one of the most difficult languages to be familiar since it has so many features and corner cases. Books like Effective C++: 55 Specific Ways to Improve Your Programs and Designs are highly recommended. It'll be even better if you can work on some projects with C++.

TRENDING NEWS