Radical Developers welcomes all the visitors to be a member of the team. Come join us. Its all about open-source concept. All Programs are written and tested in MacOS X, Unix, Linux and may not match with the outputs of Turbo C++ in Windows
Showing posts with label If - Else Block (C). Show all posts
Showing posts with label If - Else Block (C). Show all posts

Sunday, January 9, 2011

A library charges a fine for every book returned late. For first 5 days the fine is 50 paise for 6-10 days fine is 1-rupee & above 10 days fine is 5 Rs. If you return the book after 30 days your membership will be cancelled. Write a program to accept the no. of days the member is late to return the book & display the fine or the appropriate message.


Source Code :

#include<stdio.h>
void main()
{
      int n;
      clrscr();
      printf("\nEnter No. of Days : ");
      scanf("%d",&n);

Any year is input through the keyboard. Write a program to determine whether the year is a leap year or not.


Source Code :

#include<stdio.h>
void main()
{
      int n;
      clrscr();
      printf("\nEnter a Year : ");
      scanf("%d",&n);

Tuesday, January 4, 2011

Write a C Program to find the roots of the Quadratic Equation ax2+bx+c

Source Code :

#include<stdio.h>
#include<math.h>
void main()
{
    float a,b,c,dd,d,x,y;
    clrscr();
    printf("Enter the Values of a,b,c of a Quadratic Equation : ");
    scanf("%f %f %f",&a,&b,&c);
    if(a!=0)
    {
        dd=(b*b)-(4*a*c);
        if(dd<0)
        {
            printf("\n\n\t\tThe Roots are Imaginary");
            dd=-dd;
            d=sqrt(dd);
            x=(-b+d)/(2*a);
            y=(-1)*(-b-d)/(2*a);
            printf("\n\nThe two roots of the Quadratic Equation are :
             x=%5.2f(i) and y=%5.2f(i)",x,y);
        }