How to create a program that lists countries capitals when country is entered? (Terribly sorry, I'm a complete novist to coding with C, am looking for inspiration and general tips on how to code and create this program.)
Answer / Bipin Bihari Chauhan
Here's some guidance to help you get started:
1. First, you need to decide how you will store the countries and capitals in your program. One way is to use an array of structs, where each struct represents a country with its capital. For example:
```c
typedef struct {
char country[50];
char capital[50];
} Country;
```
2. You can store multiple countries in an array of Country structs. Initialize this array with the countries and capitals you need.
3. In your main function, use a loop to read user input for country names. Use a function similar to the one I provided for the previous question to find the corresponding capital.
4. Print out the capital for each entered country.
| Is This Answer Correct ? | 0 Yes | 0 No |
class test { int a; public: test(int b):a(b){} void show(){ cout<<a; } }; void main() { test t1; test t2(5); t1.show(); t2.show(); } }
How to create a program that lists countries capitals when country is entered? (Terribly sorry, I'm a complete novist to coding with C, am looking for inspiration and general tips on how to code and create this program.)
Given that two int variables, total and amount , have been declared, write a sequence of statements that: initializes total to 0 reads three values into amount , one at a time. After each value is read in to amount , it is added to the value in total (that is, total is incremented by the value in amount ). Instructor's notes: If you use a loop, it must be a for loop. And if you use a loop control variable for counting, you must declare it.
what is the error in the following code: main() { int i=400,j; j=(i*i)/i; }
void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?..
32 Answers College School Exams Tests, CTS, HCL, iGate, SmartData,
how to convert decimal to hexadecimal without using arrays just loops
Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been declared, use a do...while loop to compute the sum of the cubes of the first n whole numbers, and store this value in total . Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total . Use no variables other than n , k , and total .
write a profram for selection sort whats the error in it?
How to develop a program using C language to convert 8-bit binary values to decimals. TQ
char* f() return "hello:"; void main() {char *str=f(); }
what is meant for variable not found?
errors are known as?
3 Answers EX, State Bank Of India SBI,