C programmes consist of a sequence of declarations of functions and variables --- this must include a function named main:
/* Programme to display the least of three integer values read from the input. */ #include <stdio.h> /* Function to compare two given integers and return the least, or the second if they are the same : */ int min(int a, int b) { if (a < b) return a; else return b; } /* Main function --- prompts for and reads in three integers, calls min to determine the least and displays this : */ main(void) { int n1, n2, n3, least; printf("Enter three numbers each separated by a space:\n "); scanf("%d %d %d", &n1, &n2, &n3); least=min(n1,n2); least=min(least,n3); printf("Least is %d\n",least); } |
...previous | cont's... |