For example
, main( ), sum( ), sort( )
Example
22: Write an example program to show functions with no arguments and no return
values.
Solution 22:
The program is as follows:
/*Functions with no arguments and no return values*/
#include
main ( )
{
void hello ( ); /* function declaration */
hello( ); /* invoking function */
}
/*function definition */
void hello( )
{
char name[20];
printf(“Enter your name”);
scanf(“%s”, name);
printf(“%s\n\n”, name);
printf(“Hello %s, good morning”, name);
}
OUTPUT (after running):
Enter your name: Dr. Rajiv
Hello Dr. Rajiv good morning
Example
23: Write a C program to implement a simple calculator that can add, subtract,
Do'stlaringiz bilan baham: |