0% found this document useful (0 votes)
8 views

Programming Quiz1

This document contains code for 3 separate C++ programs. The first program calculates the area and circumference of a circle given the radius. The second program calculates the area of a triangle given the base and height. The third program reverses a first and last name by printing the last name followed by the first name.

Uploaded by

Patrick Garcia
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Programming Quiz1

This document contains code for 3 separate C++ programs. The first program calculates the area and circumference of a circle given the radius. The second program calculates the area of a triangle given the base and height. The third program reverses a first and last name by printing the last name followed by the first name.

Uploaded by

Patrick Garcia
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <iostream>

#define PI 3.14159

using namespace std;

int main()

float radius, area, circum;

cout << "\n\n Area And Perimeter of a Circle \n";

cout<<" Enter The Diameter : ";

cin>>radius;

circum = 2*PI*radius;

area = PI*(radius*radius);

cout<<" Enter the area of a circle: "<< area << endl;

cout<<" The area of the circle is : "<< area << endl;

cout<<" The Perimeter of a cicle is : "<< circum << endl;

cout << endl;

return 0;

}
#include<iostream>

using namespace std;

int main()

float base, height, area;

cout << "Area of TRIANGLE: "<< endl;

cout << "Enter height: "<< endl;

cout << "Enter base: "<< endl;

cin >> base >> height;

area = (base * height) / 2;

cout << "Area = " << area << endl;

return 0;

}
# include <iostream>
# include <string>
using namespace std;
int main()

{
char fname[30], lname [30];
cout << "\n\n Print the name in reverse where last name comes first:\
n";
cout << "-----------------------------------------------------------\
n";
cout << " Enter your First Name: ";
cin >> fname;
cout << " Enter your Last Name: ";
cin >> lname;

cout << " Name in reverse is: "<< lname << " "<< fname <<endl;
cout << endl;
return 0;
}

You might also like