C Program to reverse a given number !

C Program to reverse a given number !

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

void main()
{
int num,rem,rev=0;
clrscr();

printf("nEnter any no to be reversed : ");
scanf("%d",&num);

 while(num>=1)
    {
    rem = num % 10;
    rev = rev * 10 + rem;
    num = num / 10;
    }

printf("nReversed Number : %d",rev);
getch();
}
Output :
Enter any no to be reversed : 123
Reversed Number : 321
C Program to calculate gross salary of a person.

C Program to calculate gross salary of a person.

C Program to calculate gross salary of a person.

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

void main()
{
int gross_salary,basic,da,ta;
clrscr();

printf("Enter basic salary : ");
scanf("%d",&basic);

da = ( 10 * basic ) / 100;
ta = ( 12 * basic ) / 100;

gross_salary = basic + da + ta;

printf("Gross salary : %d",gross_salary);
getch();
}
Output :
Enter basic Salary : 1000
Gross Salart : 1220
C Program to find greatest in 3 numbers

C Program to find greatest in 3 numbers

C Program to find greatest in 3 numbers

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

void main()
{
int a,b,c;
clrscr();

printf("nEnter value of a, b & c: ");
scanf("%d %d %d",&a,&b,&c);

if((a>b)&&(a>c))
    printf("na is greatest");

if((b>c)&&(b>a))
    printf("nb is greatest");

if((c>a)&&(c>b))
    printf("nc is greatest");

getch();
}
Output :
Enter value for a,b & c : 15 17 21
c is greatest
C program to reads customer number and power consumed and prints amount to be paid

C program to reads customer number and power consumed and prints amount to be paid

An electric power distribution company charges its domestic consumers as follows

  Consumption   Rate of
  Units  Charge
  ------------------------------------------------------
  0-200       Rs.0.50 per unit
  201-400     Rs.100 plus Rs.0.65 per unit excess 200
  401-600     Rs.230 plus Rs.0.80 per unit excess of 400.
  -------------------------------------------------------

Write a C program that reads the customer number and power consumed and prints the amount to be paid by the customer.

#include<stdio.h>
#include<conio.h>
void main()
{
int n, p;
float amount;
clrscr();
printf("Enter the customer number: ");
scanf("%d",&n);
printf("Enter the power consumed: ");
scanf("%d",&p);

 if(p>=0 && p<=200)
    amount=p*0.50;
 else if(p>200 && p<400)
    amount = 100+((p-200) * 0.65);
 else if(p>400 && p<=600)
    amount = 230 + ((p-400) * 0.80);
printf("Amount to be paid by customer no. %d is Rs.:%5.2f.",n,amount);

getch();
}
Output :
Enter the customer number: 1
Enter the power consumed: 100
Amount to be paid by customer no. 1 is Rs.:50.00.
C program to read the values of x, y and z and print the results expressions in one line.

C program to read the values of x, y and z and print the results expressions in one line.

Problem Statement : Write a program to read the values of x, y and z and print the results of the following expressions in one line.
  1. (x+y+z) / (x-y-z)
  2. (x+y+z) / 3
  3. (x+y) * (x-y) * (y-z)
#include<stdio.h>
#include<conio.h>

void main()
{
int x,y,z;
float a,b,c;
clrscr();

printf("nEnter the values of x,y and z : ");
scanf("%d %d %d",&x,&y,&z);
a = (x+y+z) / (x-y-z);
b = (x+y+z) / 3;
c = (x+y) * (x-y) * (y-z);

printf("a = %fnb = %fnc = %f",a,b,c);
getch();
}
Output:
Enter the values of x,y and z : 1.1 2.5 5.5
a = -1.000000
b = 2010.000000
c = 27939.000000
C Program to find exponent Power Series !!

C Program to find exponent Power Series !!

Program :
A program to evaluate the power series
           x2      x3            xn
ex  =  1 + x + ---  +  --- + ..... + ---- , 0 < x < 1
                2!      3!            n!
It uses if……else to test the accuracy.
The power series contains the recurrence relationship of the type
        Tn   =  Tn-1  (---)   for n > 1

        T1   =  x             for n = 1

        T0   =  1
If Tn-1 (usually known as previous term) is known, then Tn (known as present term) can be easily found by
multiplying the previous term by x/n. Then
  ex   =  T0 +  T1  +  T2 + ...... +  Tn  =  sum

C Program for Exponent Series :

#include<stdio.h>
#define ACCURACY 0.0001                                     

main()
{
 int n, count;
 float x, term, sum;

 printf("Enter value of x:");
 scanf("%f", &x);

 n = term = sum = count = 1;

 while (n <= 100)
     {
     term = term * x/n;
     sum = sum + term;
     count = count + 1;
       if (term < ACCURACY)
           n = 999;
       else
           n = n + 1;
    }

 printf("Terms = %d Sum = %fn", count, sum);
 }
Output :
Enter value of x:0
   Terms = 2 Sum = 1.000000

   Enter value of x:0.1
   Terms = 5 Sum = 1.105171

   Enter value of x:0.5
   Terms = 7 Sum = 1.648720

   Enter value of x:0.75
   Terms = 8 Sum = 2.116997

   Enter value of x:0.99
   Terms = 9 Sum = 2.691232

   Enter value of x:1
   Terms = 9 Sum = 2.718279