8 Nov 2013

c program for programmers - 2



using math .h 

#include "stdio.h"
#include "math.h"
void main ( )
{
int a,b,c;
a= 10;
b=20;
c=a+b;
printf("sum=%d\n",c);
getchar( );
}
output
sum=30

note : 
  1. you  can  change  the  operator  symbol  like + : add , - :subtract ,  / : divide ,                                    * :  multiplication ; ^:exportation.
  2. if you want to write the numbers in decimals write for int write float in printf for %d write %f

c basic for programmers

c basic program for programmers

#include "stdio.h" 

void main ( )

 { 

printf("hello world");

 getchar ( ); 

}

output

hello world

caution:don't forget to put semicolon(;) and download turbo c++ for writing this program