67 007
Assignments Done
99,2%
Successfully Done
In November 2018

Answer to Question #2872 in C++ for Fawaz

Question #2872
A C program that contain conditional statement, loop statement, and functions.
Make it simple plz
Expert's answer
#include <stdio.h>
#include <conio.h>

// Function that prints "Hello World" on console
void print_hello();

// Function that computes the cube of the integer
long cube(int pNumber);

// Function that defines is the integer positive
// (uses the condition statement)
int is_positive(int pNumber);

int main()
{
int i;

print_hello();

// Using the condition define is zero positive number
if (is_positive(0) == 1)
& printf("Zero is positive\n");
else
& printf("Zero isn't positive\n");

// Using the cycle print the cubes of integers from 0 to 9
for (i = 0; i < 10; i++)
& printf("The cube of %d is %d\n", i, cube(i));

getch(); // Waiting for user's action
return 0;
}

// Function that prints "Hello World" on console
void print_hello()
{
printf("Hello world!\n");
}

// Function that computes the cube of the integer
long cube(const int pNumber)
{
return pNumber * pNumber * pNumber;
}

// Function that defines is the integer positive
// (uses the condition statement)
int is_positive(int pNumber)
{
if (pNumber > 0)
& return 1;
else
& return -1;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions