Professional Documents
Culture Documents
#include <stdio.h>
char evenOrNot(int number);
int main(void) {
int number,i;
printf("Enter 5 numbers: ");
for (i=1;i<=5;i++){
scanf("%d",&number);
evenOrNot(number);
}
}
char evenOrNot(int number){
if (number%2==0)
return printf("%d is Even\n",number);
else return printf("%d is NOT Even\n",number);
}
Write a function that displays at the left margin of the screen a solid square of
asterisks whose side is specified in integer parameter side.
#include <stdio.h>
#include <conio.h>
void squareCustomFill(int size, char chara);
int main(void) {
int size,i,k;
char chara;
printf("Enter size of square and character to be filled with: ");
scanf("%d",&size);
scanf(" %c",&chara);
//Beware the space before %c! This is for flushing
stdin!
squareCustomFill(size,chara);
return 0;
}
void squareCustomFill(int size, char chara){
int i,k;
for (k=1;k<=size;k++){
for(i=1;i<=size;i++)
printf("%c",chara);
printf("\n");
}
}
#include <stdio.h>
02
#include <math.h>
03
04
05
06
07
08
09
10
11
return length;
12
13
14
15
16
{
double side 1, side 2, side 3;
return 0;
24
25
#include
#include
double hypotenuse( double s1, double s2 );
main()
{
int i;
double side1 double side2;
for ( i = 1; i <= 3; i++ )
{
printf( "Enter the sides of the triangle: " );
scanf( "%lf%lf", &side1, &side2 );
This function returns the smallest integral value not less than x.
Example
The following example shows the usage of ceil() function.
#include <stdio.h>
#include <math.h>
int main ()
{
float val1, val2, val3, val4;
val1 = 1.6;
val2 = 1.2;
val3 = 2.8;
val4 = 2.3;
return(0);
}
Let us compile
doubleabs(doubled)
floatabs(floatf)
intabs(inti)
longabs(longlng)
doubleceil(doubled)
doublefloor(doubled)
doublerint(doubled)
longround(doubled)
Description
intround(floatf)
Description
method's return type, to the argument.
doublemin(doublearg1,doublearg2)
floatmin(floatarg1,floatarg2)
Returns the smaller of the two arguments.
intmin(intarg1,intarg2)
longmin(longarg1,longarg2)
doublemax(doublearg1,doublearg2)
floatmax(floatarg1,floatarg2)
Returns the larger of the two arguments.
intmax(intarg1,intarg2)
longmax(longarg1,longarg2)
The following program, BasicMathDemo , illustrates how to use some of these methods: