Using string functions write a program that will accept the
name of the capital as input value and will display the
corresponding country.

------------------------
Capitals Countries
------------------------
Capitals Countries
Ottawa Canada
Moscow Russia
Rome Italy

I can't not get it to run properly



Using string functions write a program that will accept the name of the capital as input value and ..

Answer / roxy

this is my code:

#include<stdio.h>
#include<string.h>

main()
{
char cc1[]={"OTTAWA"},
{"MOSCOW"},
{"ROME"};
char cc2[]={"CANADA"}
{"RUSSIA"}
{"ITALY"};
char a;

clrscr();

printf("Enter Capital: ");
scanf("%s",&cc1);

a=strcmpi(cc1,cc2);
strncpy(cc2,cc1,[1]);

if(a==0)
{
printf("\nThe capital of %s is %s",cc1,cc2);
}
if(a==1)
{
printf("\nThe capital of %s is %s",cc1,cc2);
}
else(a==2)
printf("\nThe capital of %s is %s",cc1,cc2);

getch()
}

Is This Answer Correct ?    13 Yes 84 No

Post New Answer

More C C++ Errors Interview Questions

how to convert decimal to hexadecimal without using arrays just loops

2 Answers  


Assume that the int variables i and j have been declared, and that n has been declared and initialized. Write code that causes a "triangle" of asterisks of size n to be output to the screen. Specifically, n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consistings of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be * ** *** You should not output any space characters. Hint: Use a for loop nested inside another for loop.

2 Answers   HCL,


How to develop a program using C language to convert 8-bit binary values to decimals. TQ

1 Answers   Amazon,


what is syntax error?

3 Answers  


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,






what is run time error?

7 Answers  


char* f() return "hello:"; void main() {char *str=f(); }

1 Answers  


quoroum of computer languages?

0 Answers   Infosys,


errors are known as?

3 Answers   EX, State Bank Of India SBI,


#include"stdio.h" #include"conio.h" void main() { int a; printf("\n enter a number:"); scanf("%c\n"); getch(); }

12 Answers   HCL,


WHAT WILL BE THE OUTPUT OF THE FOLLOWING QUESTION void main() { int x=4,y=3,z; z=x-- -y; printf("%d%d%d",x,y,z); }

25 Answers   HCL,


void main() { int i=7; printf("N= %*d",i,i); }

6 Answers   HCL,


Categories