Write a function in c program that prints Namaste if user is Indian and Bonjour if the user is French.
Here is a C program in which function is formed that prints Namaste if user is Indian and Bonjour if the user is French.
#include<stdio.h>
#include<conio.h>
void namaste(); // Function declaration
void bonjour();
void main()
{ char ch;
clrscr();
printf(“Enter i if Indian and f if French:”);
scanf(“%c”,&ch);
if(ch==’i’)
{ namaste(); } // Function Call
else
{ bonjour(); }
getch();
}
void namaste()
{ printf(“Namaste\n”); } // Function defination
void bonjour()
{ printf(“Bonjour\n”); }
Output:
How to use Function?
Here the two functions are used named namaste and bonjour.
Before the main function ,both the functions are declared and at the end of the program the both the functions are declared.
And the functions are called in the program when in use.
Points to Remember while using Functions
At the time of Declaration of function,it should be ended by semicolon(;).
At the time of calling the name of function should be same as while the declaration.