What's wrong with this program?
Check your output...it's not as per your expectation!!!
#include<stdio.h>
void State_Guj_print(){
printf("State - Gujarat India.\n");
}
void State_Maha_print(){
printf("State - Maharastra India\n");
}
void State_Madhya-Prad_print(){
printf("State - Madhya Pradesh India\n");
}
int main()
{
int num;
printf("Enter the number [1-3]:\n");
scanf("%d",&num);
switch(num)
{
case 1:
State_Guj_print();
break;
case 2:
State_Maha_print();
break;
case 3:
State_Madhya-Prad_print();
break;
default:
printf("Enter only number 1 to 3.\n");
break;
}
return 0;
}
/*
Do share your answer in comments...
*/
Check your output...it's not as per your expectation!!!
#include<stdio.h>
void State_Guj_print(){
printf("State - Gujarat India.\n");
}
void State_Maha_print(){
printf("State - Maharastra India\n");
}
void State_Madhya-Prad_print(){
printf("State - Madhya Pradesh India\n");
}
int main()
{
int num;
printf("Enter the number [1-3]:\n");
scanf("%d",&num);
switch(num)
{
case 1:
State_Guj_print();
break;
case 2:
State_Maha_print();
break;
case 3:
State_Madhya-Prad_print();
break;
default:
printf("Enter only number 1 to 3.\n");
break;
}
return 0;
}
/*
Do share your answer in comments...
*/
In void State_Madhya-Prad_ we are using hyghen in between (madhya-prad).As we are declaring a variable so we are not allowed to have hyghen in variable name
ReplyDeleteExcellent Gaurang !!!
DeleteExecution of this program will give error due to problem in identifier name: void State_Madhya-Prad_print().
Check this Rules for Declaring Variable(Identifier) Name in C language.