-->

Write a program to read time in hours and displays different message

//Write a program to read time in hours and displays following message.
//       0 to 12                                                        Good morning
//        12 to 18                                                     Good evening
//        18 to 24                                                     Good night
#include<stdio.h>
#include<conio.h>
void main()
{
float time;
printf("enter value time in 24 hr format\n");
scanf("%f%",&time);
if(time>=0 && time<=12)
{
printf(Good morning man!!!\n");
}
elseif(time>12 && time<=18)
{
printf(Good evening man!!!\n");
}
elseif(time>18 && time<=24)
{
printf("good night");
}
getch();
}                                                                                                                 
            

a program to calculate roots of quadratic equation (ax2+bx+c).

//calculate roots of quadratic equation (ax2+bx+c). Conditions to be taken into account are
// (b2-4ac)>0 and 2a>0
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c;
float x1,x2;
float root_value;
printf("enter value for a,b and c\n");
scanf("%f%f%f",&a,&b,&c);
root_value=pow(b,2)-4*a*c;
if(root_value>0 && a>0)
{
printf("roots are possible\n");
x1=(-b+sqrt(root_value))/2*a;
x2=(-b+sqrt(root_value))/2*a;
printf("first root/value=%f\n",x1);
printf("second root/value=%f",x2);
}
else
{
printf("real roots are not possible\n instead,");
printf("imaginary roots are possible");
}
getch();
}                                                                                                                 
                                                                                                                       

a program to add two times in the format of hrs:minutes:seconds

// a program to add two times.
// e.g.
 // 2:50:20+2:40:12=5:30:32

#include<stdio.h>
#include<conio.h>
void main()
{
int hrs1,mns1,secs1;
int hrs2,mns2,secs2;
int hrs,mns,secs;
int real_hrs,real_mns,real_secs;
printf("enter first time\n");
printf("enter first hrs\n");
scanf("%d",&hrs1);
printf("enter minutes\n");
scanf("%d",&mns1);
printf("enter seconds now\n");
scanf("%d",&secs1);
printf("------------------\n");
printf("enter second time\n");
printf("enter first hrs\n");
scanf("%d",&hrs2);
printf("enter minutes\n");
scanf("%d",&mns2);
printf("enter seconds now\n");
scanf("%d",&secs2);
secs=secs1+secs2;
if(secs<60)
   {
     real_secs=secs1+secs2;
  }
else if(secs>=60)
   {
     real_mns=secs/60;
     real_secs=secs%60;
   }
mns=mns1+mns2;
if(mns<60)
   {
     real_mns=real_mns+mns1+mns2;
  }
else if(mns>=60)
   {
     hrs=mns/60;
     real_mns=mns%60;
   }
real_hrs=hrs1+hrs2+hrs;
printf("hrs=%d\n",real_hrs);
printf("minutes=%d\n",real_mns);
printf("seconds=%d\n",real_secs);
getch();
}

Write a 'C' program to get total amount for used Nepal telecom calls

//Nepal telecom calculates the bill according to following rule.
//minimum charge is Rs. 100 for 100 calls.
//if calls exceed 100 then charge is Rs. 1/call is added with 10% tax and 13% vat cumulatively on total amount. Write a 'C' program for this.

#include<stdio.h>
#include<conio.h>
void main()
{
float total_call,extra_call;
float initial_call=0;
float total_amount;

printf("enter total calls used\n");
scanf("%f",&total_call);
if(total_call<=100)
    {
          printf("total amount to be paid=Rs. 100\n");
    }
elseif(total_call>100)
    {
         extra_call=total_call-100;
          while(initial_call<=extra_call)
          {
           initial_call++:
         total_amount=1+initial_call*0.1+initial_call*0.13;
          }
 
         printf("the total amount=%f\n",total_amount);
      }  
}
printf("thank you!!!!\n");
getch();
}
                 

A program to calculate electricity bill for used hours/units

//The minimum charge for Nepal Electricity authority is Rs. 80 for 20 units consumed. If a  person //consumes more than that then s/he has to pay Rs. 7.25 per unit extra up to 100. If the person //consumes //more than 100 units then he has to pay 9.50 per unit. Write a 'C' program to calculate //bill.
#include<stdio.h>
#include<conio.h>
void main()
{
float total_units;
float total_amount;

printf("enter total units consumed\n");
scanf("%f",&total_units);
if(total_unit<=20)
    {
          printf("total amount to be paid=Rs. 80\n");
    }
elseif(total_unit>20 && total_unit<=100)
    {
         total_amount=80+7.25*(total_unit-20);
         printf("the amount=%f\n",total_amount);
      }
elseif(total_unit>100)
    {
         total_amount=80+9.5*(total_unit-20);
         printf("the amount=%f\n",total_amount);
      }  
printf("thank you!!!!\n");
getch();
}
                                                                                               

a program to calculate Income tax based on annual income according to given rules.

//Income tax is calculated on annual income according to following rules.
 //      salary                                  married                   unmarried
//up to 100000                               0%                          0%
//100000... 300000                        5%                          10%
//above    300000                          15%                        20%
#include<stdio.h>
#include<conio.h>
{
float annual_salary,income_tax;
char marital_status;
printf("enter you marital status\n");
printf("married(m) and\n");
printf("unmarried(u)\n");
scanf(" %c",&marital_status);
printf("now enter you annual income ?\n");
scanf("%f",&annual_income);
if((marital_status=='m')||(marital_status=='u)' && annual_salary<=100000)
     {
       income_tax=0*annual_salary;
       printf("tax amount=%f\n",income_tax);
      }
elseif((marital_status=='m') && (annual_salary>100000 && annual_salary<=300000)
     {
       income_tax=0.05*annual_salary;
       printf("tax amount=%f\n",income_tax);
      }
elseif((marital_status=='m') && (annual_salary>300000))
     {
       income_tax=0.15*annual_salary;
       printf("tax amount=%f\n",income_tax);
      }
elseif((marital_status=='u') && (annual_salary>100000 && annual_salary<=300000)
     {
       income_tax=0.10*annual_salary;
       printf("tax amount=%f\n",income_tax);
      }
elseif((marital_status=='u') && (annual_salary>300000)
     {
       income_tax=0.2*annual_salary;
       printf("tax amount=%f\n",income_tax);
      }
getch();
}




program to input number of passenger and destination through air.This program should print name,destination,number of passenger and total fare

//a program to input number of passenger and destination through air.This program should print //name,destination,number of passenger and total fare using following rate.
//Destination                                                                  Rate
//      Pokhara                                                                 Rs. 2400
//    Bharaiwa                                                                 Rs. 2500
//     Biratnagar                                                               Rs. 800
//     Bhadrapur                                                               Rs. 2550
#include<stdio.h>
#include<conio.h>
void main()
{

int no_passenger;
char name[200],destination[200];
float total_fare;
printf("enter total passenger\n");
scanf("%d",&no_passenger);
printf("enter passenger name\n");
gets(name);
printf("enter destination\n");
gets(destination);
if((strcmp(destination,Pokhara))==0)
{
total_fare= 2400*no_passenger;
  printf("%s ,total passenger=%d and destination=%s\n",name,no_passenger,destination);
}
elseif(((strcmp(destination,Bhairawa))==0)
{
total_fare= 2500*no_passenger;
  printf("%s ,total passenger=%d and destination=%s\n",name,no_passenger,destination);

}
elseif(((strcmp(destination,Biratnagar))==0)
{
total_fare= 800*no_passenger;
  printf("%s ,total passenger=%d and destination=%s\n",name,no_passenger,destination);

}
elseif(((strcmp(destination,Bhadrapur))==0)
{
total_fare= 2550*no_passenger;
  printf("%s ,total passenger=%d and destination=%s\n",name,no_passenger,destination);

}
getch();
}