0% found this document useful (0 votes)
17 views2 pages

CC1202 - Prelimtask - Module3 - Velasco Keiden Draco

The document contains code for two C++ programs. The first program defines a function to calculate the cube of a number entered by the user. The second program defines variables to store the radius, diameter, circumference, and area of a circle, calculates these values based on a user-entered radius, and prints the results. Both programs include necessary header files and return statements.

Uploaded by

scribd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

CC1202 - Prelimtask - Module3 - Velasco Keiden Draco

The document contains code for two C++ programs. The first program defines a function to calculate the cube of a number entered by the user. The second program defines variables to store the radius, diameter, circumference, and area of a circle, calculates these values based on a user-entered radius, and prints the results. Both programs include necessary header files and return statements.

Uploaded by

scribd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

CC 1202 – Intermediate Programming 2

PRELIM
Name: Keiden draco Velasco
Course: BSCS-DS
Section: 1A

Module 3
Format: Calibri, Size 9
Source Code:

Number 1:

#include <stdio.h>

/* Function declaration */
double cube(double num);

int main()
{
int num;
double c;

/* Input number to find cube from user */


printf("put any number: ");
scanf("%d", &num);

c = cube(num);

printf("Cube of %d is %.2f", num, c);

return 0;
}

/**
* Function to find cube of any number
*/
double cube(double num)
{
return (num * num * num);
}

Number 2:

#include <iostream>
using namespace std;

int main() {
float r, d = 0, c = 0, a = 0;

// r = radius
// d = diameter
// c = circumference
// a = area

cout << "Enter the radius of the circle::\n";


cin >> r;

/* Calculation of diameter, circumference and area */


d = 2 * r;
c = 2 * 3.14 * r;
a = 3.14 * (r * r);

/* Print output */
cout << "\n";
cout << "Diameter :: = " << d << " units\n";
cout << "Circumference :: = " << c << " units\n";
cout << "Area :: = " << a << " sq. units";

return 0;
}

OUTPUT:

Number 1:

Number 2:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy