Thursday, January 6, 2011

Program to convert Celsius to Farenheit

/*  Name: Program to convert Celsius to Farenheit

Author: Parveen Malik

Date: 06/01/11 15:36*/


#include<stdio.h>

#include<conio.h>

void main()

{

int lower,upper,steps;

int celsius;

float farn;

lower=0;

upper=100;      //you can chanage these parameters like lower,upper and steps

steps=5;

celsius=lower;

printf("Celsius\t\tFarenheit\n\n");         //   /t tab

while(celsius<=upper)

{

farn=((9.0/5.0)*celsius)+32.0;       // formula to Celsius to Farenheit

printf("%d\t==>\t%.2f\n",celsius,farn);

celsius+=steps;

}

getch();

}



[caption id="attachment_156" align="aligncenter" width="655" caption="OUTPUT"]Program to convert Celsius to Farenheit[/caption]


Wednesday, January 5, 2011

Program to find out roots of a quadratic equation

/*  Name: Program to find out roots of a quadratic equation

Author: Parveen Malik

Date: 05/01/11 21:00*/


#include<stdio.h>

#include<conio.h>

#include<math.h>
void main()

{

int a,b,c;

float disc; // Discriminant

float root1,root2;

printf("Enter the value of a,b and c respectively\n");

printf("a = ");

scanf("%d",&a);

printf("b = ");

scanf("%d",&b);

printf("c = ");

scanf("%d",&c);

disc=b*b-4*a*c;

root1=-b+sqrt(disc)/2*a;

root2=-b-sqrt(disc)/2*a;

if(disc==0)

{

printf("Roots are real and equal\n");

printf("First Root :%.2f = Second Root: %.2f\n",root1,root2);

}

else if(disc<0)

{

printf("Roots are imaginary");

printf("First root = %.2f\n",root1);

printf("Second root = %.2f\n",root2);

}

else

{

printf("Roots are real and distinct\n");

printf("First root = %.2f\n",root1);

printf("Second root = %.2f\n",root2);

}

getch();

}

[caption id="attachment_82" align="aligncenter" width="655" caption="OUTPUT"]Program to find out roots of a quadratic equation[/caption]

Tuesday, January 4, 2011

Program to convert Farenheit to Celsius


/*Name: Program to convert Farenheit to Celsius

Author: Parveen Malik

Date: 05/01/11 10:37

*/


#include<stdio.h>

#include<conio.h>


void main()

{

int lower,upper,steps;

int farn;

float celcius;


lower=0;

upper=100; //you can chanage these parameters like lower,upper and steps

steps=5;


farn=lower;

printf("Fareneit\tCelcius\n");                 //   \t is used to give tab

while(farn<=upper)

{

celcius=5.0/9.0*(farn-32.0);                   // formula to convert Farenheit to Celcius

printf("%d\t\t%.2f\n",farn,celcius);

farn+=steps;

}

getch();

}




 Program to convert Farenheit to Celsius[/caption]





Monday, January 3, 2011

Program to calculate simple interest.

/*
Name: Program to find out Simple interest
Author: Parveen Malik
Date: 03/01/11 18:45
*/

#include<stdio.h>
#include<conio.h>


void main()
{
float rate,time,prin; // declaring rate, time and principle
float si; // simple interest

printf("Enter the value of\n\nPrinciple : "); // taking user
scanf("%f",&prin); //principle
printf("Rate : ");
scanf("%f",&rate);
printf("Time : ");
scanf("%f",&time);


si=prin*rate*time/100; //formula of finding simple interest
printf("\nSimple Interest : %.2f",si); // printing simple interest to the console

getch();
}




[caption id="attachment_55" align="aligncenter" width="800" caption="OUTPUT:"]program to find out simple interest[/caption]



Program to calculate area of a circle

/*
Name: Program to calculate area of a circle
Author: Parveen Malik
Date: 03/01/11 19:46
*/

#include<stdio.h>
#include<stdio.h>
#define PI 3.141 // to define value of pi


void main()
{
int radius;
float area;

printf("Enter the radius of the Circle : ");
scanf("%d",&radius);

area=PI*radius*radius; // formula to find the area of a circle
printf("\nArea of the Circle is : %.2f",area);

getch();
}
OUTPUT:



[caption id="attachment_12" align="aligncenter" width="656" caption="OUTPUT"]Program to calculate area of a circle[/caption]



Sunday, January 2, 2011

Program to find out sum of any two integers.

/*
Name:  Program to find out sum of any two integers.
Author: Parveen Malik
Date: 02/01/11 16:05
*/

#include<stdio.h>
#include<conio.h>   // preprocessor section


void main()
{
int n1,n2,sum; //declare integers

printf("Enter any two integers \n");
scanf("%d%d",&n1,&n2); // for the user input

sum=n1+n2;

printf("\n\n%d + %d = %d",n1,n2,sum); // to print the sum


getch();
}


[caption id="attachment_11" align="aligncenter" width="655" caption="OUTPUT"]Program to find out sum of any two integers.[/caption]

First Program "hello world"

Here is the first program from which you can start your programming as i did. C is a general purpose programming language developed by Dennis Ritchie at Bell Laboratories(1972).
C is the one of the most popular language of all the time. C is  influenced by B, BCPL, CPL, ALGOL, Assembly, FORTRAN, PL/I and it has influenced many languages like C++, C--, C#, Objective C, BitC, D, Java, JavaScript, PHP, Perl, Pike , LPC and Python etc.
Look at the program below and try to understand it.



/*  Name: hello world
Author: Parveen Malik,,
Date: 02/01/11 15:11      // comment section
*/


#include<stdio.h> // header section
#include<conio.h>


void main() //program starts from here
{
printf("hello world"); // Prints the "hello world" on console screen

getch();

} //exit





[caption id="attachment_8" align="aligncenter" width="662" caption="OUTPUT"]First Program "hello world"[/caption]