Input state and print capital of that state.
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main ( )
{
char nm[80];
char state[6][20] = { "WEST BENGAL", "BHIHAR", "ORISHA", "ASSAM",
"GUJARAT", "RAJASTHAN" };
char cap[6][20] = { "kolkata", "patna", "bhubaneswar", "dispur",
"gandhinagar", "jaipur" };
int c, i = 1;
clrscr ( );
printf("\n\n\n\t NAME OF STATE \n\t_______________\n\t");
for ( c = 0; c < 6; c++)
{
printf("\n\n\t %s", state[c] );
}
printf("\n\n\n\t Enter the name of state....:"); gets(nm);
for ( c = 0; c <= 5; c++)
{
if ( strcmp( nm, state[c] ) == 0 )
{
printf("\n\n\n\t Capital.....: %s", cap[c] );
i = 0;
break;
}
}
if ( i == 1 )
{
printf("\n\n\n\t\t NOT FOUND!");
}
getch ( );
}
Click here to contact us
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main ( )
{
char nm[80];
char state[6][20] = { "WEST BENGAL", "BHIHAR", "ORISHA", "ASSAM",
"GUJARAT", "RAJASTHAN" };
char cap[6][20] = { "kolkata", "patna", "bhubaneswar", "dispur",
"gandhinagar", "jaipur" };
int c, i = 1;
clrscr ( );
printf("\n\n\n\t NAME OF STATE \n\t_______________\n\t");
for ( c = 0; c < 6; c++)
{
printf("\n\n\t %s", state[c] );
}
printf("\n\n\n\t Enter the name of state....:"); gets(nm);
for ( c = 0; c <= 5; c++)
{
if ( strcmp( nm, state[c] ) == 0 )
{
printf("\n\n\n\t Capital.....: %s", cap[c] );
i = 0;
break;
}
}
if ( i == 1 )
{
printf("\n\n\n\t\t NOT FOUND!");
}
getch ( );
}
Click here to contact us
No comments:
Post a Comment