Write a program which prints "Hello!", using a
function:
#include <stdio.h>
void printHello(); // function declaration: line ended with semicolon!
int main() // main function
{
printHello(); // call the function printHello
return 0;
}
// definition of the function printHello
void printHello() // function header: contains return type and name
{ // function opening bracket
printf("Hello!");
} // function closing bracketModify the program by adding three new functions. The first function
should increment the global (meaning defined outside of the
main function) variable Number by \(5\), e.g.:
The second function should decrement the variable Number
by 3. The third function should print the current value of variable
Number. The variable should be declared as global
(e.g. after declaration of the functions but before the beginning of the
main function) and initialized with \(10\). Remember about proper declaration of
the functions. Inside main, call the functions according to
the following pattern:
Number;Number by 5 and repeat it three
times;Number;Number by 3; do it two
times;Number by 5;Number;Create a new program which solves the quadratic equation. Here is a suggestion for the program layout:
#include <math.h>
#include <stdio.h>
// declaration of functions
void ReadData();
void SolveQuadEq();
void PrintSolution();
// declaration of global variables
double a, b, c, delta;
double x1, x2;
// main function
int main()
{
ReadData();
SolveQuadEq();
PrintSolution();
return 0;
}
// definitions of other functions
void ReadData()
{
// fill the function with proper code
}
void SolveQuadEq()
{
// fill the function with proper code
}
void PrintSolution()
{
// fill the function with proper code
}