C Program
C Program
PROGRAM
Ist
#include <stdio.h>
main( )
{
printf(“hello world”)
}
IInd
#include <stdio.h>
int main
{
//64+54=121
int a=64 , b=54 , add;
add= a+b; (“ addition of two numbers:%d” , add);
printf (“%d” , add);
return 0;
}
IIIrd
#include <stdio.h>
int main ( )
{
// 64-54=10
int a=64 , b=54 , subtract;
subtract= a-b; (“ subtract of two numbers:%d” , subtract);
printf (“%d” , subtract);
return 0;
}
IV th
IN C PROGRAM
#include <stdio.h> TYPE “ * ”
int main INSTEAD OF “ x ”
{
//25x2=50
int a=25 , b=2 , multiply;
multiply= axb; (“ multiply of two numbers:%d” , multiply);
printf (“%d” , multiply);
return 0;
}
Vth
#include <stdio.h>
int main
{
//25/5=5
int a=25 , b=5 , divide;
divide= a/b; (“ divide of two numbers:%d” , divide);
printf (“%d” , divide);
return 0;
}
VI th
#include <stdio.h>
int main ( ) {
int n , I , sum = 0;
printf (“Enter a positive integer:”) ;
scanf (“%d” , &n);
for (i = 1 ; i<=n ; ++i) {
sum + = I ;
}
printf (“sum=%d” , sum) ;
Return 0;
}
VII th
#include <stdio.h>
int main ( ) {
int n , i , sum = 0 ;
printf (“Enter a positive integer : “) ;
scanf (“%d” , & n );
i=1;
while (i<=n) {
sum + = 1 ;
++i ;
}
printf (“Sum = %d” , sum) ;
return 0 ;
}