Welcome!!

Hey!
Welcome to my blog "xplor"

Monday, October 29, 2012


C PROGRAMMING
This program is written in window platform using DEV C++ compiler other users are shall make some modification.


/* Program ADDITION line-1  */
/* Written by EBG line-2  */
#include <stdio.h> /* line-3  */
# include <conio.h>
#include<stdlib.h>
 main() /* line-4  */
{ /* line-5  */
  int   number; /* line-6  */
  float amount; /* line-7  */
/* line-8  */
  number = 100; /* line-9  */
/* line-10  */
  amount = 30.75 + 75.35; /* line-11 */
  printf("%d\n",number); /* line-12 */
  printf("%5.2f",amount); /* line-13 */
  getch();                      /* line-14 */
  system("pause");   /* line-15 */
}                      /*line-16*/



************************************************************************




/*--------------------- INVESTMENT PROBLEM --------------------*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define PERIOD 10
#define PRINCIPAL 5000.00
/*-------------------- MAIN PROGRAM BEGINS --------------------*/
 main()
{ /*------------------- DECLARATION STATEMENTS ----------------*/
int year;
float amount, value, inrate;
/*------------------- ASSIGNMENT STATEMENTS -------------------*/
amount = PRINCIPAL;
inrate = 0.11;
year = 0;
/*------------------ COMPUTATION STATEMENTS -------------------*/
/*--------------- COMPUTATION USING While LOOP ----------------*/
while(year <= PERIOD)
{ printf("%2d %8.2f\n",year, amount);
value = amount + inrate * amount;
year = year + 1;
amount = value;
}
/*----------------------- while LOOP ENDS ---------------------*/
        getch();
        system("pause");
}
/*------------------------ PROGRAM ENDS -----------------------*/


*******************************************************************************



/*------------------- PROGRAM USING FUNCTION ------------------*/
# include <stdio.h>
# include <conio.h>
#inluce<stdlib.h>
int mul (int a, int b);      /*------- DECLARATION ------------*/

/*-------------------- MAIN PROGRAM BEGINS --------------------*/
main ()
{
int a, b, c;

a = 5;
b = 10;
c = mul (a,b);

printf ("multiplication of %d and %d is %d",a,b,c);
getch();
}

/* ---------------- MAIN PROGRAM ENDS
MUL() FUNCTION STARTS -----------------*/

int mul (int x, int y)
{
 int p;

 p = x*y;

 return(p);
 system("pause");
}
/* -------------------- M () FUNCTION ENDS ------------------*/



**************************************************************************



/*--------------- PROGRAM USING COSINE FUNCTION -------------- */
 #include <stdio.h> 
 #include <math.h>
 #include<conio.h>
 #inluce<stdlib.h>

 #define   PI      3.1416
 #define   MAX     180

 main ( )
 {

int angle;
float x,y;

angle = 0;
printf("        Angle     Cos(angle)\n\n");

while(angle  <= MAX)
{
x = (PI/MAX)*angle;
y = cos(x);
printf("%15d %13.4f\n", angle, y);
angle = angle + 10;
}
       getch();
       system("pause");
 }

*******************************************************************************
ref: PROGRAMMING IN ANSI - E BALAGURUSAMY

No comments:

Post a Comment