how to combine two sketch in one

hey there noob here,
I am trying to combine two different sketch in one sketch for obtaining respective output.
Follwing are the code and there output

////***HMR code****////

char message[] = "$PTNTHPR,74.5,N,-2.9,N,3.3,N,*24"; // an example string
  char* next; //pointer to substring (token)
  float value;
  float ans;
float divde;
void setup() {
  Serial.begin(9600);
  
  
}

void loop() {
//  char message[] = "$PTNTHPR,74.5,N,-2.9,N,3.3,N,*24"; // an example string
//  char* next; //pointer to substring (token)
//  float value;
  
  next = strtok(message, ",");  //get first substring (token)
  Serial.println(next); // and print "$PTNTHPR"
  Serial.print("magnitude : ");
  (next = strtok(NULL, ",")); //get and print the string "75.4"
  value = atof(next);  //convert string to float
  
  Serial.println(value, 4); // and print
  Serial.println(ans);
   (next = strtok(NULL, ","));
   Serial.print("magnitude Status : ");
   Serial.println(next);
   
   (next = strtok(NULL, ",")); //get and print the string "-2.9   " 
  value = atof(next);  //convert string to float
   Serial.print("pitch: "); 
  Serial.println(value, 4);
  
   (next = strtok(NULL, ","));
   Serial.print("pitch Status : ");
   Serial.println(next);
   (next = strtok(NULL, ",")); //get and print the string "  3.3   "
  value = atof(next);  //convert string to float
  Serial.print("roll : ");
  Serial.println(value, 4);
  
  (next = strtok(NULL, ","));
  Serial.print("roll Status : ");
   Serial.println(next);
   delay(9000);
   }

   void degree(){

     
     float divide=180/PI;
     ans = value*divde;
   }

////HMR output////
$PTNTHPR
magnitude : 74.5000
0.00
magnitude Status : N
pitch: -2.9000
pitch Status : N
roll : 3.3000
roll Status : N
$PTNTHPR

////**GPGGA string**//

#include<math.h>
float value;
int D;//integerpart    degree
int M;//decimalpart; minutes
int S;// second
void setup(){
  Serial.begin(9600);
   char message[]=" $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47";
  //Serial.println(message); 
  char*next;// pointer to substring(token)
  //float value;// we declared above  it for all 
  next=strtok(message,",");  // get first substring token
  Serial.println(next);     //print GPGGA
  
  Serial.print("UTC: ");   //print universal time UTC
  (next=strtok(NULL,","));//print next string 123519
  value=atof(next);      // convert string to float
  Serial.println(value,0);

  Serial.print("latitude: ");//print latitude
  (next=strtok(NULL,","));//print next string 
  value=atof(next);
  //Serial.println(value,4);
  DMS(float(value));
  Serial.print("Direction: ");// print direction
  (next=strtok(NULL,","));
  Serial.println(next);

  Serial.print("longitude: ");//print longitude
  (next=strtok(NULL,","));
  value=atof(next);
  //Serial.println(value,3);
  DMS(float(value));
  Serial.print("Direction: ");// print direction
  (next=strtok(NULL,","));
  Serial.println(next);

   Serial.print("fix quality: ");
  (next=strtok(NULL,","));
  value=atof(next);
  Serial.println(value,0);

   Serial.print("NO. of Satellites teacked: ");
  (next=strtok(NULL,","));
  value=atof(next);
  Serial.println(value,0);

   Serial.print("Horizontal dilution position: ");//print longitude
  (next=strtok(NULL,","));
  value=atof(next);
  Serial.println(value,2);

   Serial.print("Altitude,meters: ");
  (next=strtok(NULL,","));
  value=atof(next);
  Serial.print(value ,2);
  (next=strtok(NULL,","));
  Serial.print(",");
  Serial.println(next);


   
   Serial.print("Height,meters: ");//
  (next=strtok(NULL,","));
  value=atof(next);
  Serial.print(value ,2);
  (next=strtok(NULL,","));
  Serial.print(",");
  Serial.println(next); 

  Serial.print("check sum : ");//print check sum data
  (next=strtok(NULL,","));
  Serial.println(next);  

}


//convert to  degree minute second ...........

 void DMS(float(value)) {
  // put your main code here, to run repeatedly:
 //value = Serial.parseFloat();//returns the first valid floating point number from the Serial buffer.
   //Serial.print(" DATA: ");
   //Serial.println(value,4);
   D =(int)value; // gets the first part as going from (casting) // cast is used
  //float to int drops the bit after the decimal point
 
  //Serial.print("Degree: ");
  Serial.print(D);// print  degree
 Serial.print("°");// ASCII VALUE FOR °= (ALT +428)
 // Serial.println(" ");
  // get the second part minutes
  M= 10000*(value-D);
  //Serial.print("Minutes: ");
  Serial.print(M);// print minutes
  Serial.print("'");// add minutes (') symbols
  //Serial.println("");
  // Second part
  S=60*(M); 
 // Serial.print("Second: ");
  Serial.print(S);//print second
  Serial.print("''");// add second (") symbols
  Serial.println("");
    
}

void loop(){

}

/// GPGGA OUTPUT//
$GPGGA
UTC: 123519
latitude: 4807°380'22800''
Direction: N
longitude: 1131°0'0''
Direction: E
fix quality: 1
NO. of Satellites teacked: 8
Horizontal dilution position: 0.90
Altitude,meters: 545.40,M
Height,meters: 46.90,M
check sum : *47
///

delay(9000);

Is it OK for both parts of the combined sketch to do nothing for 9 seconds ?

You can't get there from here.

Grab one of the usual GPS libraries and see how it works inside. Modify it to accept the $PTNTHPR sentence.

Thank you @UKHeliBob for your concern .
Yes it is ok for 9 sec delay.

Thanks @MorganS for the suggestion but, the string $PTNTHPR
Is of HMR 3000 digital compass sensor. Will it work in that sense.

Yes it will work.

Ask a better question if you want a better answer. What are you trying to do?

I am just trying to combine this two individuals sketch and get the similar output which we get from two sketch

The two sketches are useless. They have a hardcoded "input" so the result will be the same 100 years from now.

You appear to have a compass and a GPS. How are they hooked up? What else is connected? Are you only printing the results or are you doing more calculation with those values? Any other constraints like battery power or speed or accuracy?

I had just put the string in code and extract it which I m willing to get by GPS and HMR . Latter on I will intilize readstring function for reading data from GPS and HMR.
Yes I am converting the value into degree and Meter for some purpose.
Assuming to hook up GPS and compass by software serial
And trying to send the data from one serial to another serial.

shubhamjoshi:
Assuming to hook up GPS and compass by software serial

Let me pause you right there. You cannot have two SoftwareSerial working at the same time. You can alternate two of them but that really screws up anything useful.

Go back and choose an Arduino with more than 2 hardware Serial. I particularly like the Teensy 3.2. Although it is sold on the Arduino.cc website, you have to look in "Other brands".