Skip to content

Instantly share code, notes, and snippets.

View mahata's full-sized avatar
💭
On parenting...

Yasunori MAHATA mahata

💭
On parenting...
View GitHub Profile
@mahata
mahata / hello.c
Created March 15, 2011 13:19
Hello World! (C)
#include <stdio.h>
int main()
{
printf("Hello, World!\n");
return 0;
}
@mahata
mahata / 3.1.cpp
Created September 11, 2011 16:52
C++ Primer 3.1
#include <iostream>
const int inchInFeet = 12;
int main()
{
using namespace std;
cout.setf(ios_base::fixed, ios_base::floatfield);
int inch;
cout << "Please input your hight in inches: ";
@mahata
mahata / 3.3.cpp
Created September 13, 2011 00:00
C++ Primer 3.3
#include <iostream>
int main() {
using namespace std;
cout.setf(ios_base::fixed, ios_base::floatfield);
int degree, minute, second;
cout << "Enter a latitude in degrees, minutes, and seconds:" << endl;
cout << "First, enter the degrees: ";
@mahata
mahata / 3.4.cpp
Created September 13, 2011 05:02
C++ Primer 3.4
#include <iostream>
const int hours_in_a_day = 24;
const int minutes_in_an_hour = 60;
const int seconds_in_a_minute = 60;
int main()
{
using namespace std;
long second;
long remain;
@mahata
mahata / 3.5.cpp
Created September 13, 2011 05:31
C++ Primer 3.5
#include <iostream>
int main()
{
using namespace std;
double mile;
double gallon;
cout << "Enter how many miles you have driven: ";
@mahata
mahata / 7.1.cpp
Created September 13, 2011 20:36
C++ Primer 7.1
#include <iostream>
double harmonic_mean(double x, double y);
int main()
{
using namespace std;
double x, y;
cout << "Please input x and y: ";
@mahata
mahata / 7.2.cpp
Created September 16, 2011 04:41
C++ Primer 7.2
#include <iostream>
void inputScore(int * score_card, int score_size);
void displayScore(int * score_card, int score_size);
double getAverageScore(int * score_card, int score_size);
int main()
{
using namespace std;
cout.setf(ios_base::fixed, ios_base::floatfield);
@mahata
mahata / 7.3.cpp
Created September 16, 2011 18:48
C++ Primer 7.3
#include <iostream>
struct box
{
char maker[40];
float height;
float width;
float length;
float volume;
};
@mahata
mahata / 7.4.cpp
Created September 18, 2011 21:10
C++ Primer 7.4
#include <iostream>
long double probability(unsigned numbers, unsigned picks, unsigned mega);
int main()
{
using namespace std;
// cout.setf(ios_base::fixed, ios_base::floatfield);
double total, choices, mega;
@mahata
mahata / 7.5.cpp
Created September 18, 2011 21:25
C++ Primer 7.5
#include <iostream>
long factorial(int n);
int main()
{
using namespace std;
int n;
cout << "Please input a number(n): ";