Showing posts with label free c source code. Show all posts
Showing posts with label free c source code. Show all posts

August 30, 2009

Functions

====================================================
#include <>
#include <>

int main ()
{
//Local Declarations
int a;
int b;
//Statements
printf("Square root of");
scanf("%d",&a);
b=sqrt(a);
printf("%d is the square root of %d",b,a);
return 0;
}

=================================================================
#include <>
#include <>

//Function Declarations
int square (int x);


int main ()
{
//Local Declarations
int a;
int b;
//Statements
printf("Square root of");
scanf("%d",&a);
b=square(a);
printf("%d is the square root of %d",b,a);
return 0;
}
int square (int x)
{
//Statements
return (sqrt(x));
}
====================================================================

August 24, 2009

Project 62 (Menu-driven program)

62. Write a menu-driven program that allows a user to enter five numbers and then choose between finding the smallest, largest, sum or average. The menu and all the choices are to be functions. Use a switch statement to determine what action to take. Provide an error message if an invalid choice is entered.

OUTPUT PROGRAM

Start of the Program


Option 1

Option 2



Option 3


Option 4

Default message