Google analytics

Sunday, August 28, 2011

Find the roots of Quadratic Equation?


/* Program to find the roots of Quadratic Equation */

#include<stdio.h> 
#include<conio.h>
#include<math.h>
int main()
{
int a , b, c, d;
float
x1, x2;
clrscr();
printf("Enter the value of a, b, c:");
scanf("%d%d%d", &a, &b, &c);
d=(b*b)-(4*a*c);
if(d==0)
{
printf("\nRoots are real and equal");
x1= x2=(-b)/(2*a);
printf("\nRoots are: %f \t %f ", x1, x2);
}
else
{
if(d<0)
printf("\nRoots are imaginary");
else
{
x1=((-b)+sqrt(d))/(2*a);
x2=((-b)-sqrt(d))/(2*a);
printf("\nRoots are real");
printf("\nRoots are : %f \t %f", x1, x2);
}
}
getch( );
}


Find the greater between three number

/* Program to find the greater between three number */



#include<stdio.h>
#include<conio.h>
void main()
{
  int a,b,c;
   clrscr();
    printf(“Enter the values of a,b,c”);
    scanf(“%d%d%d”,&a,&b,&c);
 if(a>b)
 {
 if(a>c)
    printf(“a is greater”);
 else
    printf(“c is greater”);
 }
 else if(b>c)
    printf(“b is greater”);
 else
   printf(“c is greater”);
  getch();
}

find out the greatest between two numbers?

/* Program to find the greater between two number */



#include<stdio.h>
#include
<conio.h>
void
main()
{
  int
a,b,g;
   clrscr
();
   printf
(“\n \t \t Finding out the Greatest Value”);
   printf(” \n please enter the any one number”);
   scanf(“%d”, &a);
   printf(” please enter the any number again”);
   scanf(“%d”, &b);
 if
(a>b)
   printf(“the greatest number is :%d”, a);
 
else
   printf(“the greatest number is:%d”,b)
 getch();
}

Saturday, August 27, 2011

Swaping in c


/* Interchange between two integer */

#include <stdio.h>
int main() 
{
   int a = 23, b = 47;
   int t;
    printf("Before. a: %d, b: %d\n", a, b);
     t = a;
     a = b;
     b = t;
    printf("After.  a: %d, b: %d\n", a, b);
   return 0;
}

Sample C Program To Calculate Simple Interest.

/* Program to calculate simple interest*/


#include <stdio.h>
#include
<conio.h>
void main()
{

   int p, r, t, si;
     printf("Enter principle, rate of interest & time to find simple interest: ");
     scanf("%d%d%d",&p, &r, &t);
   
si= ( p * r * t ) / 100;
    printf("Simple interest= %d",si);
  getch
();
}

Area and volume of cone

/* Area & volume of Cone */

#include<stdio.h>
#include<math.h>
int
 main()
{  

     float r,h;
    
 float surface_area,volume;
       printf("Enter size of radius and height of a cone : ");
       scanf("%f%f",&r,&h);
     surface_area = M_PI * r * (r + sqrt(r*r + h*h));
      
volume = (1.0/3) * M_PI * r * r * h;
        printf("Surface area of cone is: %.3f",surface_area);
        printf("\nVolume of cone is : %.3f",volume);
    
 return 
0;
}

Area of Rectangle

/* Area of Rectangle */


#include<stdio.h>
int main()
{

    float l,w;
     float area;
      printf("Enter size of each sides of the rectangle : ");
      scanf("%f%f",&l,&w);
    area = l * w;
      printf("Area of rectangle is: %.3f",area);
     return 0;

}

Thursday, August 18, 2011

Characteristics of "C" language


There are some main characteristics of "C" language which is given below:- 
1. Modularity.
2. Portability.
3. Extendability.
4. Speed.
5. Flexibility.
Modularity: Ability to breakdown a large module into manageable sub modules called as modularity, that is an important feature of structured programming languages.
Advantages: 
1. Projects can be completed in time.
2. Debugging will be easier and faster.
Portability: 
The ability to port i.e. to install the software in different platform is called portability.
Highest degree of portability: ‘C’ language offers highest degree of portability i.e., percentage of changes to be made to the sources code are at minimum when the software is to be loaded in another platform. Percentage of changes to the source code is minimum. The software that is 100% portable is also called as platform independent software or architecture neutral software. Eg: Java.
Extendability: Ability to extend the existing software by adding new features is called as extendability.
SPEED:
‘C’ is also called as middle level language because programs written in ‘C’ language run at the speeds matching to that of the same programs written in assembly language so ‘C’ language has both the merits of high level and middle level language and because if this feature it is mainly used in developing system software.
Flexibility: Key words or reverse words
ANSIC has 32 reverse words
‘C’ language has right number of reverse words which allows the programmers to have complete control on the language.
‘C’ is also called as programmer’s language since it allows programmers to induce creativeness into the programmers.

Introduction to "C" Language


high-level programming language developed by Dennis Ritchie at Bell Labs in the mid 1970s. Although originally designed as a systems programming language, C has proved to be a powerful and flexible language that can be used for a variety of applications, from business programs to engineering. C is a particularly popular language for personal computer programmers because it is relatively small -- it requires less memory than other languages.
The first major program written in C was the UNIX operating system, and for many years C was considered to be inextricably linked with UNIX. Now, however, C is an important language independent of UNIX.
Although it is a high-level language, C is much closer to assembly language than are most other high-level languages. This closeness to the underlying machine language allows C programmers to write very efficient code. The low-level nature of C, however, can make the language difficult to use for some types of applications.