1 like 0 dislike
1.3k views

Please write a simple program that can detect 4 country codes: 886 = Taiwan, 976 = Mongolia, 62 = Indonesia, and 66 = Thailand by using if... else condition. If the code doesn't match any of those four, the program must show No

Example

#include <stdio.h>

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

int country_code;
printf("Input your country code:\n");
scanf ("%d", &country_code);

//Your condition starts from here

else 
	printf("No");

    return 0;
}

Example Input 1

Input your country code:

886

Example Output 1

Taiwan

 

Example Input 2

Input your country code:

976

Example Output 2

Mongolia

 

Example Input 3

Input your country code:

62

Example Output 3

Indonesia

 

Example Input 4

Input your country code:

66

Example Output 4

Thailand

 

Example Input 5 (else case)

Input your country code:

696969696969

Example Output 5 (else case)

No

 

Explanation

You might be wondering why your result is wrong even you have the same result, that's because an online judge is strict and sensitive; here some cases:

1. Your result MUST be the same as the fixed output, even dot(.), space( ), printf, misspelling, etc. make the result to be wrong.

2. An online judge works the same as a compiler installed in your computer, you don't need to put anything except the code there.

3. For more information and practice, please visit --> http://www.pipls.net/27431/must-read-an-example-program-for-online-judge

[Exercise] Coding (C) - asked in Chapter 3: Branching, Looping and Functions by (5.9k points)
ID: 28130 - Available when: Unlimited - Due to: Unlimited

edited by | 1.3k views

23 Answers

1 like 0 dislike
Hidden content!
* *** *****
****** ** *** ** *

/* run this **** ** the * * or add * own **** *** * ** * *** or * loop */

int ** * char **** {
* **** ***** int * *
* **** ** * * * * * ** the * * * * * ***
* ** * ** *
* *** * * ** ** * * ** *** ** * *** * * * *
* *** if * * == 886)
* * * **** * *** ** * ** ** * ***
** * * ** * else if * ** ==
** *** * * * *** ** * * ***** ***
* ** * * * else if == 62)
*** * *** * * * ** ******** *** *****
** * * ** ** * else if ***** == 66)
*** ** * ** ** *** * ** * ** * ** ***
** * **** else
*** **** * ** * * * *** * ***** * ** *
* * * * ** 0;
}
100/100 answered by (252 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Great job. But the output expects only a name of those countries. The output didn't expect as follow:
printf("Please enter the Country code: ");
Taiwan code -> could be changed into 'Taiwan' only.
1 like 0 dislike
Hidden content!
#include **** * * **
#include * ** * * ** *

/* run this program using the console pauser or add your own getch, **** ** * * * * or input loop */

int main(int argc, char *argv[]) {
** * *** int cc;
*** **** *** ** printf * *** *** * input your country code = * *** *
* * * * * scanf * *** * ** ** ******
* ** ** * * if( cc == 886 ) {
*** * ** ** * * *** **** *
** * ** * * ****** * * * * * * * ** * * ** **
** * ** * *** *
* *** ****** *** * if(cc == 62) {
* * **** * * * * * ** ** **** *
** * * *** ** *** ** * ** * * * * *** ** * ** *
* ** * *****
* ** * * * * * * * if(cc == 976) {
* ** ** * * * *** * * * *
** * ** * * ***** ***** * * ** * * * *** **
* * *** ******* *
*** ** * * * ** * if(cc == 66) {
** * * * * * **** ***
*** * * ** ** * * *** * ** ** ** ** * ** * *** * * ** * *
* ** * * *****
* ** ** * **** * **
* * *** * * * ** *** **** * *
* ** *** * * return 0;
}
100/100 answered by (268 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
I hate you
0 0
printf ("please input your country code = ");
why did u print this line??? The question never ask you to print it out :(((
0 0
But the program would be so cold and impolite :( it needs some human warmth and niceness so the user feels more comfortable :)
0 like 0 dislike
Hidden content!
*** ** * ** **

int * * argc, char * ** {

int *** *
scanf ** * ** * * ** **** ****

if ** ** * * ***
******* * *** * ** **** * *
}

else if * * * **
***** ** * * * **** * * * **
}

else if *** * ** * *
* * *** * * * ** *** * * ** * ***
}

else if *** *** **
** * * * * * ** * * *** * *
}

else
** ** ** * * ** * * **

* * ** ** ** ** * 0;
}
answered by (5.9k points)
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.71.194.92
©2016-2024

Related questions

0 like 0 dislike
24 answers
[Exercise] Coding (C) - asked Nov 2, 2017 in Chapter 3: Branching, Looping and Functions by nat236919 (5.9k points)
ID: 30241 - Available when: Unlimited - Due to: Unlimited
| 953 views
0 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Oct 27, 2017 in Chapter 3: Branching, Looping and Functions by nat236919 (5.9k points)
ID: 29618 - Available when: Unlimited - Due to: Unlimited
| 924 views
0 like 0 dislike
14 answers
[Exercise] Essay (Open question) - asked Nov 2, 2017 in Chapter 3: Branching, Looping and Functions by nat236919 (5.9k points)
ID: 30244 - Available when: Unlimited - Due to: Unlimited
| 486 views
0 like 0 dislike
20 answers
[Exercise] Coding (C) - asked Nov 2, 2017 in Chapter 3: Branching, Looping and Functions by nat236919 (5.9k points)
ID: 30222 - Available when: Unlimited - Due to: Unlimited
| 872 views
12,783 questions
183,443 answers
172,219 comments
4,824 users