Beyond Verses

My blog that specializes in Space Science and latest news from NASA

Thursday, September 25, 2008

C Solve Problem

// s = 1- 2x + 3xpow2 - 4xpow3 + .........
#include <stdio.h>
#include <math.h>
void main( )
{
float x,s,r ;
int a,b,n ;
int i ;

printf ("enter number of term after ") ;
scanf ("%d",&n) ;
printf ("enter value x = ") ;
scanf ("%f",&x) ;

s = 0 ;

for ( i=1 ; i<=n ; i++ )

{
a = 1 + i ;
b = i ;

r = a * pow(x,b) ;

if ( i % 2 == 0)

s = s + r ;

else

s = s - r ;
//first tirm -2x (s = 0 - 2x)
}



s = 1 + s ;

printf ("sum = %10.2f \n",s) ;

}




Sunday, September 21, 2008

Start Java Pro With Notepad

1-save file as HelloWorld.java  (Like the Class name)

2-open CMD [start>>run>>print CMD>>enter ]

3-Now after open Print : cd C:\Program Files\Java\jdk1.5.0\bin\ 

4-now you can compile the program with print : javac "C:\DocumentsandSettings\ahmed\MyDocuments\ahmed.java\HelloWorld\HelloWorld.java"    < where you save >
                                                     

5-print : cd C:\Documents and Settings\ahmed\My Documents\ahmed.java\HelloWorld\
              

6-now you can run the prog  print : java HelloWorld

                                -----------------------------------

**** the path could be not the same in your P.C so find it and edit my doc.

I try it and it is work