1.

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 bracket

2.

Modify 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.:

void IncNumber()
{
    Number = Number + 5; // or better: Number += 5;
}

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:

  • print value of the variable Number;
  • increment value of the Number by 5 and repeat it three times;
  • print value of the variable Number;
  • decrement value of the Number by 3; do it two times;
  • increment value of the Number by 5;
  • print value of the variable Number;

3.

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
}