<repo_name>Jla2001/_Structural-Programming-C-L.1<file_sep>/โปรแกรมweek5/price.cpp
#include <iostream>
using namespace std;

int main(){
    if(people <= 2){
        then "Price room 85";
    }
    if(people == 2){
        then "Price room 90";
    }
    if(people == 3){
        then"Price room 95";
    }
    if(people > 4){
        then"Price room + 6per person" ;
    }
    if(business == true){
        then "Discount 20%";
    }
    if(Overyear > 60 ){
        then "Discount 15%"
    }
}<file_sep>/ทวนตั้งแต่บท1/6406021420034.cpp
#include <iostream>
using namespace std;

int main(){
    int Salary, OT;
    char late;
    cout << "Enter Salary : ";
    cin >> Salary;

    while(late != 'Y' && late != 'N' ){
        cout << "Late (Y/N) : ";
        cin >> late;
        if(late == 'Y'){
        Salary += 1000;
        }
    }

    cout << "Enter OT Hours : ";
    cin >> OT;

    cout << "Salary : " << Salary+OT*200;
    return(0);
}<file_sep>/test/test.cpp
#include <iostream>
#include <string>
using namespace std;

int main(){
int num = 0 ; while(num <= 0){ num++ ; cout << num-- ; }
    return(0);
}<file_sep>/บท6/ท้ายบท6/last3.cpp
#include <iostream>
#include <iomanip>
using namespace std;

void getdata();
void average();
void displaydata();

int count = 3,id[20],i,j;
double total[20],score[20][3],test[3],TT;
string name[20];

int main(){
    getdata();
    average();
    displaydata();

    return(0);
}

void getdata(){
    for(i=0;i<count; i++){
        cout << "Enter id : ";
        cin >> id[i];
        cout <<"Enter name : ";
        cin >> name[i];
        for(j=0;j<3;j++){
            do{
                cout <<"Enter Score "<<j+1<<" : ";
                cin >> score[i][j];
            }while(score[i][j] > 100);
        }
    }

}

void average(){
    //loop หาคะแนนจริง
    for(i=0;i<3;i++){
        for(j=0;j<count;j++){
            if(i < 2){
                score[j][i] /= 4;
            }else{
                score[j][i] /= 2;
            }
            test[i] += score[j][i];
        }
    }
    //loopหาคะแนนรวมจริง
    for(i=0;i<count;i++){
        for(j=0;j<3;j++){
            total[i] += score[i][j]; 
        }
        TT += total[i];
    }
}

void displaydata(){
    cout <<"--------------------------------------------------------------------------------------\n";
    cout <<"No.    Id        Name      Test1(25%)   Test2(25%)   Test3(50%)    Total(100%)\n";
    cout <<"--------------------------------------------------------------------------------------\n";
    for(i=0;i<count;i++){
            cout << i+1<<".     "<< id[i] <<"       "<<name[i];
        for(j=0;j<3;j++){
            cout <<"        "<< fixed << setprecision(2)<< score[i][j];
        }
        cout  <<"       "<< total[i] <<endl;
    }
    cout <<"--------------------------------------------------------------------------------------\n";
    cout << "Average  of  mark        ";
    for(i=0;i<3;i++){
        cout <<"       "<< test[i] / count;
    }
    cout <<"       "<< TT<<endl;
}<file_sep>/บท6/tempCodeRunnerFile.cpp
//6_6
#include <iostream>
#include <iomanip>
using namespace std;
void Sort(int temp[], const int max);
void Swap(int &n1, int &n2);
int main()
{
    const int Max = 10;
    int Data[Max] = {50, 0, 44, 7, 3, 100, 12, 36, 72, 23};
    cout << "\nData before sort in array ...\n";
    for (int n = 0; n < Max; n++)
        cout << setw(5) << Data[n];
    cout << "\n\nStart  Sort ...\n";
    Sort(Data, Max);
    cout << "\n\nEnd Sort ...\n";
    cout << "\nData after sort finish.\n";
    for (int n = 0; n < Max; n++)
        cout << setw(5) << Data[n];
    cout << "\n";
    return (0);
}

void Sort(int temp[], const int Max)
{
    int
        i,
        j, n;
    for (i = 0; i < Max - 1; i++)
    {
        n = i;
        for (j = i; j < Max; j++)
            if (temp[n] > temp[j])
                n = j;
        if (n != i)
            swap(temp[i], temp[n]);
        cout << "\n"
             << i + 1 << " : ";

        for (j = 0; j < Max; j++)
            cout << setw(5) << temp[j];
    }
}

void Swap(int &n1, int &n2)
{
    int temp;
    temp = n1;
    n1 = n2;
    n2 = temp;
}<file_sep>/ทวนตั้งแต่บท1/loopnum.cpp
#include <iostream>
using namespace std;

int main(){
    for(int i = 1; i<=100; i++){
        cout << i << "\t";
        if(i%10 == 0){
            cout << "\n";
        }
    }
    return(0);
}<file_sep>/โปรแกรมบท6/6_1.cpp
#include <iostream>
using namespace std;

int main(){
    float gallon,miles;
    cin >> gallon;
    cin >>miles;

    cout << miles/gallon <<endl;
    gallon *= 4.5461;
    miles *= 1.6093;
    cout << gallon/miles <<endl;
    cout << miles/gallon;


    return(0);

}<file_sep>/test/tempCodeRunnerFile.cpp
 cout << i ;<file_sep>/โปรแกรมบท6/6_2.cpp
#include <iostream>
using namespace std;

int main(){
    int area;
    char insize;
    char size;
    int sumA = 0,sumM = 0;
    cout << "Enter area : ";
    cin >> area;
    cout << "Enter size : ";
    cin >> insize;

    if(area >= 20 && area <=40){                     //small
        sumA = 200000;
        size = 's';
    }else if(area >= 41 && area <=100){               //medium
        sumA = 200000 +((area-40)*3000);
        size = 'm';
    }else if(area >= 101){              //large
        sumA = 350000 + ((area-60)*2000);
        size = 'l'; 
    }

    if(insize == 'b' && size == 's'){
        sumA += (area*5000);
        cout << sumA << endl;
    }else if(insize == 'b'&& size == 'm'){
        sumA += (area*7500);
        cout << sumA << endl;
    }else if(insize == 'b' && size == 'l'){
        sumA += (area*15000);
        cout << sumA << endl;
    }else if(insize == 'G' && size == 'm'){
        sumA += (area*10000);
        cout << sumA << endl;
    }else if(insize == 'G'&& size == 'l'){
        sumA += (area*20000);
        cout << sumA << endl;
    }else if(insize == 'G'&& size == 'm'){
        sumA += (area*15000);
        cout << sumA << endl;
    }else if(insize == 'G'&& size == 'l'){
        sumA += (area*30000);
        cout << sumA << endl;
    }else{
        cout << "error";
    }
    return(0);
}<file_sep>/README.md
# _Structural-Programming-C-L.1<file_sep>/โปรแกรมบท 4/check.cpp
#include <iostream>
using namespace std;

int main(){
    int GPA;
    cout << "enter your GPA : ";
    cin >> GPA;
    if(GPA >= 80){
        cout << " A ";

    }else if(GPA >= 70){
        cout << "B";
    }else if(GPA >= 60){
        cout << "C";
    }else if(GPA >= 50){
        cout << "D";
    }else if(GPA < 50){
        cout << "F";
    }
    return(0);
}<file_sep>/บท5/homwork.cpp
#include <iostream>
//นำเข้าไลบรารี่มาตฐานของภาษา C++
using namespace std;
//ประกาศเพื่อใช้ฟังก์ชันในไลบรารี่ของ namespace std
void demo(int v, int &r);
//สร้างฟังชั่น ชื่อ demo รับ ค่า v,&r

int main(){
// ฟังชั่นการทำงานหลัก
    int v = 7;
    //สร้างตัวแปล v เก็บค่า 7
    int r = 7;
    //สร้างตัวแปล r เก็บค่า 7 
    cout << "inside main() " << endl;
    //ส่งออกค่า inside main() แล้วขึ้นบรรทัดใหม่
    cout << "v = " << v << ", address = " << &v << endl;
    //ส่งออกค่า v = ค่าv, address = ที่อยู่ของค่า v แล้วขึ้นบรรทัดใหม่
    cout << "r = " << r << ", address = " << &r << endl;
    //ส่งออกค่า r = ค่าr, address = ที่อยู่ของค่า r แล้วขึ้นบรรทัดใหม่
    demo(v, r);
    //ส่งค่า v,r ไปที่ฟังชั่น demo
    cout << "inside main()--after calling demo()" << endl;
    //ส่งออกค่า inside main()--after calling demo() แล้วขึ้นบรรทัดใหม่
    cout << "v = " << v << ", address = " << &v << endl;
    //ส่งออกค่า v = ค่าv, address = ที่อยู่ของค่า v แล้วขึ้นบรรทัดใหม่
    cout << "r = " << r << ", address = " << &r << endl;
    //ส่งออกค่า r = ค่าr, address = ที่อยู่ของค่า r แล้วขึ้นบรรทัดใหม่
    return 0;
}
void demo(int v, int &r) {
// ฟังชั่น demo
    cout << "inside demo()" << endl;
    //ส่งออกค่า inside main() แล้วขึ้นบรรทัดใหม่
    cout << "v = " << v << ", address = " << &v << endl;
    //ส่งออกค่า v = ค่าv, address = ที่อยู่ของค่า v แล้วขึ้นบรรทัดใหม่
    cout << "r = " << r << ", address = " << &r << endl;
    //ส่งออกค่า r = ค่าr, address = ที่อยู่ของค่า r แล้วขึ้นบรรทัดใหม่
    v = v + 10;
    //ค่า V บวกอีก 10
    r = r + 10;
    //ค่า r บวกอีก 10
    cout << "inside demo()--after changing values " << endl;
    //ส่งออกค่า inside main()--after calling demo() แล้วขึ้นบรรทัดใหม่
    cout << "v = " << v << ", address = " << &v << endl;
    //ส่งออกค่า v = ค่าv, address = ที่อยู่ของค่า v แล้วขึ้นบรรทัดใหม่
    cout << "r = " << r << ", address = " << &r << endl;
    //ส่งออกค่า r = ค่าr, address = ที่อยู่ของค่า r แล้วขึ้นบรรทัดใหม่
}<file_sep>/โปรแกรมบท 4/ten.cpp
#include <iostream>
#include <string>
using namespace std;

int main(){
    int money;
    cout << "enter your money Per year : ";
    cin >> money;

    if(money <= 100000){
        cout << 0.05*money;

    }else if(money >= 100001){
        cout << 0.1*money;

    }else if(money >= 500001){
        cout << 0.2*money;

    }else if(money >= 1000001){
        cout << 0.3*money;

    }else if(money > 4000000){
        cout << 0.37*money;

    }else{
        cout << "No";

    }
    return(0);
}<file_sep>/บท7 pointer/7_1.cpp
#include <iostream>
using namespace std;

int main(){

    int x = 5, y, z = 4;
    int *xptr, *yptr, *zptr;
    xptr = &x;
    yptr = &y;
    zptr = &z;
    y = *xptr;
    cout << "\nx = " << x << "  &x = " << &x;
    cout << "  xptr = " << xptr << "  *xptr = " << *xptr;
    cout << "\ny = " << y << "  &y = " << &y;
    cout << "  yptr = " << yptr << "  *yptr = " << *yptr;
    cout << "\nz = " << z << "  &z = " << &z;
    cout << "  zptr = " << zptr << "  *zptr = " << *zptr;
    x = 2 * (z + 5);
    y = 2 * (*zptr + 5);
    cout << "\nx = " << x << "  y =  " << y << "  z = " << z << endl;
    return (0);
}<file_sep>/บท6/ท้ายบท6/last2.cpp
#include <iostream>
#include <iomanip>
using namespace std;

int main(){
    double chairman,student = 500,Votes,NVotes,setVotes,pvotes,pnvotes,point,ppoint,lpoint,lper;
    cout << "Enter number student chairman : ";
    cin >> chairman;
    cout <<"Number of right student : " << student <<endl;
    srand(time(nullptr));
    Votes = rand()%500;
    pvotes = (Votes / student)*100;
    pnvotes = ((500-Votes) / student)*100;
    cout <<"Number of Votes : " <<Votes<<" = "<< pvotes <<"%" <<endl << "Number of not Votes : "<< student-Votes<<" = "<< pnvotes <<"%";
    cout <<"\n\nResult of election chairman\n";
    cout <<"------------------------------------------"<<endl;
    cout <<"NO.     " << "Votes     " << "Percent(%)" <<endl;
    cout <<"------------------------------------------"<<endl;
    setVotes = Votes;
    for(int i = 0; i < chairman; i++){
        if(i < chairman-1){
            do{
                point = rand();
            }while(point > Votes);
            Votes = Votes - point;
            ppoint = (point/setVotes)*100;
            cout << i+1 <<".      ";
            cout << fixed << setprecision(0) << point <<"         ";
            cout << fixed << setprecision(2) << ppoint <<endl;
        }else{
            point = Votes;
            ppoint = (Votes/setVotes)*100;
            cout << i+1 <<".      ";
            cout << fixed << setprecision(0) << point <<"         ";
            cout << fixed << setprecision(2) << ppoint <<endl;
        }
        lpoint += point;
        lper += ppoint;
    }
    cout <<"------------------------------------------"<<endl;
    cout <<"Total   "<< fixed << setprecision(0) <<lpoint<<"       "<< fixed << setprecision(2) << lper <<endl;
    return(0);
}<file_sep>/ทวนตั้งแต่บท1/forgrade.cpp
#include <iostream>
using namespace std;

int main(){
    int P,M,F,sum;
    for(int i = 0;i < 3;){
        do{
            cout << "Enter Project Score : ";
            cin >> P;
            cout << "Enter Midterm Score : ";
            cin >> M;
            cout << "Enter Final Score : ";
            cin >> F;
            if(P > 20 || P < 0){
                cout << "Project Score Error !!!\n";
            }
            if(M > 30 || M < 0){
            cout << "Midterm Score Error !!!\n";
            }
            if(F > 50 || F < 0){
                cout << "Final Score Error !!!\n";
            }
        }while(P > 20 ||P < 0||M > 30||M < 0||F > 50 || F < 0);
        i++;
        sum = P+M+F;
        cout << "Total Score : "<< sum << endl;
        if(sum < 50 ){
            cout <<"Grade : F\n";
        }else if(sum >=80){
           cout <<"Grade : A\n";
        }else if(sum >=70 ){
            cout <<"Grade : B\n";
        }else if(sum >=60 ){
            cout <<"Grade : C\n";
        }else if(sum >= 50 ){
            cout <<"Grade : D\n";
        }
    }
    return(0);

}<file_sep>/บท6/newCalGrade.cpp
#include <iostream>
#include <string>
using namespace std;

template <class T>
T calGrade1(T total);
template <class T>
T calGrade2(T total);
template <class T>
T calGrade3(T total);

int main() {
    int total;
    int text;
    int score;
    cout << "1.Calgrade A/B+/B/C+/C/D+/D/F " << endl;
    cout << "2.Calgrade 4/3.5/3/2.5/2/1.5/1 " << endl;
    cout << "3.Calgrade PASS/FAIL " << endl;
    cout << "(Choose your choice (1)(2)(3)) : " ;
    cin >> text;
    if (text == 1){
        cout << "Enter your total score : ";
        cin >> score;
        calGrade1<char>(score);
    }
    else if (text == 2) {
        cout << "Enter your total score : ";
        cin >> score;
        calGrade2<double>(score);
    }
    else if (text == 3){
        cout << "Enter your total score : ";
        cin >> score;
        calGrade3<char>(score);
    }

    return 0;
}

template <class T>
T calGrade1(T total){
    if (total >= 80){
        cout << "This is your grade : " << 'A';
    }else if (total >= 75) {
        cout << "This is your grade : " << 'B+';
    }else if (total >= 70) {
        cout << "This is your grade : " << 'B';
    }else if (total >= 65) {
        cout << "This is your grade : " << 'C+';
    }else if(total >= 60){
        cout << "This is your grade : " << 'C';
    }else if(total >= 55){
        cout << "This is your grade : " << 'D+';
    }else if(total >= 50){
        cout << "This is your grade : " << 'D';
    }else{
        cout << "This is your grade : " << 'F';
    }
    return 0; 
}

template <class T>
T calGrade2(T total){
    if (total >= 80){
        cout << "This is your grade : " << 4; 
    }
    else if (total >= 75) {
        cout << "This is your grade : " << 3.5;
    }
    else if (total >= 70) {
        cout << "This is your grade : " << 3; 
   }
    else if (total >= 65) {
        cout << "This is your grade : " << 2.5;
    }
    else if (total >= 60) {
        cout << "This is your grade : " << 2;
    }
    else if (total >= 55) {
        cout << "This is your grade : " << 1.5;
    }
    else {
        cout << "This is your grade : " << 1;
    }
    return 0;
}

template <class T>
T calGrade3(T total){
    if (total >= 50) {
        cout <<"This is your grade : PASS ";
    }
    else {
        cout << "This is your grade : FAIL ";
    }
    return 0;
}



<file_sep>/บท5/5_1.cpp
#include <iostream>
#include <string>
using namespace std;

int main(){
    char Ch;
    string Message;
    cout << "Enter character : ";
    cin >> Ch;
    if((Ch >= 48 && Ch <= 57) || (Ch >= 65 && Ch <= 90) || (Ch >= 97 && Ch <= 122)){
        if((Ch >= 65 && Ch <= 90) || (Ch >= 97 && Ch <= 122)){
            if((Ch >= 97 && Ch <= 122)){
                Message = "Lower character";
            }else{
                Message = "upper character";
            }
        }else if((Ch >= 48 && Ch <= 57)){
                Message ="digit";
        }
    }else{
        Message = "special character";
    }
    cout <<"\'" << Ch << " is " << Message << endl;
    if((Ch >= 65 && Ch <= 90) || (Ch >= 97 && Ch <= 122)){
        if((Ch >= 97 && Ch <= 122)){
            cout <<  "\'" << Ch << "\'" << " convert to upper \'"; 
            Ch = Ch-32;
            cout << Ch << "\'";
        }else{
            cout <<  "\'" << Ch << "\'" << " to lower \'";
            Ch = Ch+32;
            cout << Ch <<  "\'"; 
        }
        cout << endl;
    }
    return(0);
}<file_sep>/บท6/6_3.cpp
//6_3
#include <iostream>
#include <iomanip>
#include <time.h>
using namespace std;

int main(){
    int Data[10];
    srand((unsigned int)time(0));
    for (int i = 0; i < 10; i++){
        Data[i] = rand() % 30 + 1;
    }
    cout << "Element Value Histogram " << endl
         << endl;
    for (int i = 0; i < 10; i++){
        cout << setw(5) << i << "   " << setw(4) << Data[i] << "  ";
        for (int k = 1; k <= Data[i]; k++){
            cout << "*";
        }
        cout << endl;
    }

    return (0);
}<file_sep>/บท5/5_4.cpp
#include <iostream>
#include <string.h>
using namespace std;
int main(){

    char Str1[30], Str2[30];
    cout << "Enter string 1 : ";
    cin >> Str1;
    cout << "Enter string 2 : ";
    cin >> Str2;
    cout << endl;
    cout << "strcat(Str1,Str2) = " << strcat(Str1, Str2);
    cout << endl;
    cout << "strchr(Str1,'s') = " << strchr(Str1, 's') << endl;
    cout << "strcmp(Str1,Str2) = " << strcmp(Str1, Str2);
    cout << endl;
    cout << "strcpy(Str1,Str2) = " << strcpy(Str1, Str2);
    cout << endl;
    cout << "strlen(Str1) = " << strlen(Str1) << endl;
    cout << "strlen(Str2) = " << strlen(Str2) << endl;
    cout << "String 1 : " << Str1 << endl;

    cout << "String 1 reverse : ";
    for (int N = strlen(Str1)-1; N >= 0; N--){
        cout << Str1[N];
    }
    cout << endl << endl;
    return (0);
}<file_sep>/ทวนตั้งแต่บท1/threeC.cpp
//ข้อที่ 2

#include <iostream>
#include<cmath>
using namespace std;

int main(){
    float circum, area, volume, r, num;
    float pi = 3.14;
    cout << "Enter the numbber of radious : ";
    cin >> r;
    
    cout << "Calculate the circumference of circle\n";
    circum = 2.0*pi*r;

    cout << "Calculate the area of circle\n";
    area = pi*pow(r,2);

    cout << "Calculate the volume phere\n";
    volume =(4.0/3.0)*pi*pow(r,3);

    cout << "Enter the choice : ";
    cin >> num;

    if(num == 1){
        cout <<"circumference is " << circum <<endl;

    }else if(num == 2){
        cout <<"area is " << area <<endl;

    }else if(num == 3){
        cout <<"volume is " << volume <<endl;
    }

    return(0);
}<file_sep>/โปรแกรมบท6/t.cpp
#include <iostream>
using namespace std;

int main()
{
    float gallon, mileage;
    cout << "Input petroleum used : "; 
    cin >> gallon;
    cout << "Input mileage : "; 
    cin >> mileage;
    cout << "1. Fuel economy  = " << mileage / gallon << " Miles per gallon (MPG)" << endl ;
    gallon *= 4.5461;
    mileage *= 1.6093;
    cout << "2. The car will use " << gallon / mileage << " Liter per kilometer" << endl;
    cout << "3. Fuel economy = " << mileage / gallon << " Kilometer per Liter (km/L)" << endl;
    return (0);
}<file_sep>/โปรแกรมบท6/6_2t.cpp
#include <iostream>
using namespace std;

int main(){
    int stdScore,BestScore,i;
    while(stdScore != -1){
        cin >> stdScore;

        if(stdScore > BestScore){
            BestScore = stdScore;
        }
    }
    cout << "BestScore :" << BestScore;
    return(0);
}<file_sep>/สอบ/6406021420034-3.cpp
#include <iostream>
using namespace std;

int main(){
    int day = 0,month = 0,year = 0;
    int sumday,summonth,sumyear,calday;

    cout << "Enter day month and year : ";
    do{
        cin >> day;
        if(day > 30 || day < 1){
            cout << "Error Day !!!\n";
            cout << "pla Enter Day again : ";
        }
    }while(day > 30 || day < 1);

    do{ 
        cin >> month;
        if(month > 12 || month < 1){
            cout << "Error month !!!\n";
            cout << "pla Enter month again : ";
        }
    }while(month > 12 || month < 1);

    do{
        cin >> year;
        if(year > 2559 || year < 2513){
            cout << "Error year !!!\n";
            cout << "pla Enter year again : ";
        }
    }while(year > 2559 || year < 2513);

    sumday = day-1;
    summonth = month-1;
    sumyear = year-2513;
    calday = sumday+(summonth*30)+(sumyear*360);
    cout << "\nThe difference is about " << calday <<" days";

    return(0);
}<file_sep>/สอบ/6406021420034-2.cpp
//ข้อที่2
#include <iostream>
using namespace std;

int main(){
    int book, toy, model, pen;
    int Calbook, Caltoy, Calmodel, Calpen;

    cout << "Input nimber 0f Book : ";
    cin >> book;
    cout << "Input nimber 0f Toy : ";
    cin >> toy;
    cout << "Input nimber 0f Model : ";
    cin >> model;
    cout << "Input nimber 0f Stationery : ";
    cin >> pen;

    Calbook = book*120;
    Caltoy = toy*80 ;
    Calmodel = model*50;
    Calpen = pen*15;

    float sum = Calbook+Caltoy+Calmodel+Calpen;

    if(sum <= 0 ){
        cout << "payment : " << 500 <<endl;
    }else if(sum >=1 && sum <= 4999){
        cout << "payment : " << 1000-(sum*0.10) <<endl;
    }else if(sum >= 10000 && sum <= 99999){
        cout << "payment : " << 1000+(sum*0.05) <<endl;

    }else if(sum >=100000){
        cout << "payment : " << 1000+(sum*0.10) <<endl;
    }

    return(0);
}<file_sep>/โปรแกรมweek5/5_1.cpp
#include <iostream>
using namespace std;

int main(){
    int num,i,j,k;
    int c;
    cout << "Enter number : ";
    cin >> num;
    for (i=1; i<=num; ++i){
        for(j=0; j<=i; ++j){
            if(i % j == 0){
                cout << i;
            }
        }

    }
    return(0);
}<file_sep>/บท6/ท้ายบท6/test.cpp
#include <iostream>
using namespace std;
int main()
{
 char k,arr[10];
 int i,j,n;
 cout<<"Enter the size of array\n";
 cin>>n;
 cout<<"Enter the element of array\n";
    for (i=0;i<n;i++)
    {
     cin>>arr[i];
 }
 cout << i;
 j=i-1;
 for(i=0;i<j;i++)
 {
  k=arr[i];
  arr[i]=arr[j];
  arr[j]=k;
  j--;
 }
 cout<<"After reverse the array Elements\n";
 for(i=0;i<n;i++)
 {
  cout<<"\t"<<arr[i]<<endl;
 }
 return 0;
}<file_sep>/โปรแกรมบท3/pakapong.cpp
#include <iostream>
using namespace std;

int main(){
    int fish, tometo;
    int xfish, xtometo, lfish, ltometo;
    int usefish, usetometo;
    cout << "fish : ";
    cin >> fish;
    cout << "tometo : ";
    cin >> tometo;
    cout << "fish use : ";
    cin >> usefish;
    cout << "tometo use : ";
    cin >> usetometo;

    xfish = fish / usefish;
    xtometo = tometo / usetometo;

    if(xfish <= xtometo){
        cout << "fish : " << fish << "  tometo : " << tometo << endl;
        cout << "fish use : " << usefish << "  tometo use : "<< usetometo << endl;
        cout << "Can : " << xfish << endl;
        lfish = fish -(xfish*usefish);
        cout << "fish r : " << lfish;
        ltometo = tometo -(xtometo*usetometo);
        cout << "  tometo r :" << ltometo;
    }else{
        cout << "Can : " << xtometo << endl;
        lfish = fish -(xfish*usefish);
        cout << "fish r : " << lfish;
        ltometo = tometo -(xtometo*usetometo);
        cout << "  tometo r :" << ltometo;
    }
    return(0);
}<file_sep>/โปรแกรมบท 4/4_11.cpp
#include <iostream>
using namespace std;

int main()
{
    unsigned long Sum = 0L;
    int n, i = 1;
    cout << "Please enter value n to find sumation of n*n : ";
    cin >> n;
    do
    {
        Sum += i * i;
      
    } while (i <= n);
    cout << "Sum = " << Sum << endl;
    return (0);
}<file_sep>/โปรแกรมบท 4/char.cpp
#include <iostream>
using namespace std;

int main(){
    char K;
    cout << "enter your Key :";
    cin >> K;
    if(K <= '9'){
        cout << K <<" : Is Number\n";
    }else{
        cout << K << " : Is Not Number";
    }
}<file_sep>/บท6/6_1.cpp
//6_1

#include <iostream>
#include <iomanip>
using namespace std;
int main(){

    int X[10];
    int Y[] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
    const int Array_Size = 10;
    int Z[Array_Size];

    for (int i = 0; i < 10; i++){
        X[i] = 0;
    }
    for (int i = 0; i < Array_Size; i++){
        Z[i] = 2 + 2 * i;
    }

    cout << ": Subscript : Array X : Array Y : Array Z :\n";
    cout << setfill('=') << setw(43) << "=" << endl;
    cout << setfill(' ');

    for (int i = 0; i < Array_Size; i++){
        cout << ": " << setw(6) << i << "    : ";
        cout << setw(6) << X[i] << "  : ";
        cout << setw(6) << Y[i] << "  : ";
        cout << setw(6) << Z[i] << "  :";
        cout << endl;
    }

    cout << setfill('=') << setw(43) << "=" << endl;

    return (0);
}<file_sep>/บท6/ท้ายบท6/last1.cpp
#include <iostream>
using namespace std;

bool isPalindrome(char Temp[]);

int main(){
    char text[5];
    cout << "Enter text :";
    for(int i = 0; i < 5; i++){
        cin >> text[i];
    }
    cout << endl;
    if(isPalindrome(text) == true){
        cout << "Your text is Palindrome."<<endl;
    }else{
        cout <<"Your text is not Palindrome."<<endl;
    }

    return(0);
}

bool isPalindrome(char Temp[]){
    char p,re[5];
    int i = 5,j;
    bool Palindrome;
    j=i-1;
    for(int i=0;i<5;i++){
        re[i]=Temp[i];
    }
    for(i=0;i<j;i++){
        p=Temp[i];
        Temp[i]=Temp[j];
        Temp[j]=p;
        j--;
    }
    for(i=0;i<5;i++){
        if(re[i] == Temp[i]){
            for(i=0;i<5;i++){
                cout << re[i] << " = " << Temp[i] << endl;
            }
            Palindrome = true;
            return(Palindrome);
        }else{
            cout << re[i] << " = " << Temp[i] << endl;
            Palindrome = false;
            return(Palindrome);
        }
    }
}<file_sep>/บท6/ท้ายบท6/tempCodeRunnerFile.cpp
<< fixed << setprecision(2)<file_sep>/บท6/6_4.cpp
//6_4
#include <iostream>
using namespace std;
void ModifyArray(char Temp[]);
void ModifyElement(int Temp);

int main()
{
    char Data[5];
    for(int i = 0; i < 5; i++){
        cin >> Data[i];
    }
    cout << "Effects of passing entrie array pass-by-reference.\n";
    cout << "Original array's value : ";
    for (int i = 0; i < 5; i++)
        cout << Data[i] << "  ";
    cout << endl;
    ModifyArray(Data);
    cout << "Modified array's value : ";
    for (int i = 0; i < 5; i++){
        cout << Data[i] << "  ";
    }
    cout << endl
         << endl;
    cout << "Effects of passing array element pass-by-value.\n";
    cout << "Data[3] before modify element : ";
    cout << Data[3] << endl;
    ModifyElement(Data[3]);
    cout << "Data[3] after modify element : ";
    cout << Data[3] << endl
         << endl;

    return (0);
}

void ModifyArray(char Temp[])
{
    char p;
    int i,j;
    j=i-1;
    for(i=0;i<j;i++){
        p=Temp[i];
        Temp[i]=Temp[j];
        Temp[j]=p;
        j--;
    }
}

void ModifyElement(int Temp)
{
    Temp *= 2;
}