#include stdio.h
#define p printf
#define s scanf
int main() {
float var1, var2, sum, diff, product, dividend;
p( "Enter two numbers : " );
s( "%f%f", &num1, &num2 );
/* Perform floating point */
__asm__ ( "fld %1;"
"fld %2;"
"fadd;"
"fstp %0;" : "=g" (sum) : "g" (num1), "g" (num2) ) ;
__asm__ ( "fld %2;"
"fld %1;"
"fsub;"
"fstp %0;" : "=g" (diff) : "g" (num1), "g" (num2) ) ;
__asm__ ( "fld %1;"
"fld %2;"
"fmul;"
"fstp %0;" : "=g" (product) : "g" (num1), "g" (num2) ) ;
__asm__ ( "fld %2;"
"fld %1;"
"fdiv;"
"fstp %0;" : "=g" (dividend) : "g" (num1), "g" (num2) ) ;
p( "%f + %f = %f\n", num1, num2, sum);
p( "%f - %f = %f\n", num1, num2, diff);
p( "%f * %f = %f\n", num1, num2, product);
p( "%f / %f = %f\n", num1, num2, dividend);
return 0 ;
}
Sunday, November 28, 2010
Tuesday, November 23, 2010
My IF Else Loop Sample in COBOL Programming in LINUX ^_^
PROCEDURE Decimal
Begin.
PERFORM DecimalValue THRU DecimalValueExit
STOP RUN.
DecimalValue.
Statements
Statements
IF ErrorFound GO TO DecimalValueExit
END-IF
Statements
Statements
IF ErrorFound GO TO DecimalValueExit
END-IF
Statements
Statements
Statements
IF ErrorFound GO TO DecimalValueExit
END-IF
Statements
Statements
Statements
Statements
DecimalValueExit
EXIT.
Begin.
PERFORM DecimalValue THRU DecimalValueExit
STOP RUN.
DecimalValue.
Statements
Statements
IF ErrorFound GO TO DecimalValueExit
END-IF
Statements
Statements
IF ErrorFound GO TO DecimalValueExit
END-IF
Statements
Statements
Statements
IF ErrorFound GO TO DecimalValueExit
END-IF
Statements
Statements
Statements
Statements
DecimalValueExit
EXIT.
Wednesday, November 17, 2010
My Sample ABAP Program ALV Grid Control
My Sample ABAP Program ALV Grid Control
create a screen 100 for call it and Element list of screen supploy OK and type Ok inthe output
Then activate modules STATUS_0100 and USER_COMMAND_0100 in the flow logic .
CALL SCREEN 100.
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN'.
IF C_CUSTOM_CONTAINER IS INITIAL.
CREATE OBJECT C_CUSTOM_CONTAINER EXPORTING CONTAINER_NAME = C_CONTAINER
CREATE OBJECT ALV_GRID EXPORTING I_PARENT = C_CUSTOM_CONTAINER.
CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
I_STRUCTURE_NAME = 'bin1'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
* IS_LAYOUT =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
CHANGING
IT_OUTTAB = TAB_DISPLAY
* IT_FIELDCATALOG =
* IT_SORT =
* IT_FILTER =
* EXCEPTIONS
* INVALID_PARAMETER_COMBINATION = 4
* PROGRAM_ERROR = 2
* others = 1
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDMODULE.
MODULE USER_COMMAND_0100 INPUT.
CASE OK_CODE.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
END MODULE.
create a screen 100 for call it and Element list of screen supploy OK and type Ok inthe output
Then activate modules STATUS_0100 and USER_COMMAND_0100 in the flow logic .
CALL SCREEN 100.
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN'.
IF C_CUSTOM_CONTAINER IS INITIAL.
CREATE OBJECT C_CUSTOM_CONTAINER EXPORTING CONTAINER_NAME = C_CONTAINER
CREATE OBJECT ALV_GRID EXPORTING I_PARENT = C_CUSTOM_CONTAINER.
CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
I_STRUCTURE_NAME = 'bin1'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
* IS_LAYOUT =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
CHANGING
IT_OUTTAB = TAB_DISPLAY
* IT_FIELDCATALOG =
* IT_SORT =
* IT_FILTER =
* EXCEPTIONS
* INVALID_PARAMETER_COMBINATION = 4
* PROGRAM_ERROR = 2
* others = 1
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDMODULE.
MODULE USER_COMMAND_0100 INPUT.
CASE OK_CODE.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
END MODULE.
Friday, November 5, 2010
My Sample Embedded C++ program using EC++ compiler
#include
using namespace std;
extern "C" void exit(int);
void johnpaul(const char *msg, int n)
{
cout << msg << n << endl;
exit(1);
}
// The integer array class
class Shit{
private:
// array elements
int *arry;
// array size
int array_counter; public:
// construct a array
Array(int n) : array_counter(n) {
if (n > 0)
elements = new int[array_counter];
else
die("Bad Array size, dumbass try again!!!! ", array_counter);
}
int &operator [](int index_list) const {
// overloaded operator
if (index_list < 0 || index_list >= array_counter)
die("Bad Array index ", index_list);
return arry[index_list];
}
int size() { return array_counter; } // return the size of the array
};
main()
{
Array m(6);
for (int i=0; i a[i] = i;
for (int i=0; i cout << i << ". " << m[i] << endl;
}
using namespace std;
extern "C" void exit(int);
void johnpaul(const char *msg, int n)
{
cout << msg << n << endl;
exit(1);
}
// The integer array class
class Shit{
private:
// array elements
int *arry;
// array size
int array_counter; public:
// construct a array
Array(int n) : array_counter(n) {
if (n > 0)
elements = new int[array_counter];
else
die("Bad Array size, dumbass try again!!!! ", array_counter);
}
int &operator [](int index_list) const {
// overloaded operator
if (index_list < 0 || index_list >= array_counter)
die("Bad Array index ", index_list);
return arry[index_list];
}
int size() { return array_counter; } // return the size of the array
};
main()
{
Array m(6);
for (int i=0; i
for (int i=0; i
}
Subscribe to:
Comments (Atom)