You are on page 1of 8

S.B.I.T. & HCL Infosys ltd.

C Projects

Submitted By:

Submitted To:

VAIBHAV JAIN HCL TRAINER ECE/09/152
1|Page

NO.INDEX TOPIC  OBJECTIVE  DESCRIPTION o No. of variables used with their data types and range o Looping constructs used o Decision making statements used  CODING  OUTPUT WINDOW P. 3 4 6 8 HCL PROJECT Page 2 .

OBJECTIVE AN ELECTRICITY BILL CALCULATOR HCL PROJECT Page 3 .

float .3. Data. amnt. puc2.4e +/. total. Variables No used 1 ch. num 4 bytes to input and output the numeral in decimals Looping Constructs Used---While--Here in this program while loop is used to check the condition on *s mean the loop will go till the value of *s reaches null HCL PROJECT Page 4 . unt.38 (~7 digits) Size 4 bytes Its use in program to input the numeral 2 puc1. ch1 .DESCRIPTION Description of variables---S. puc3.Range type int signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295 +/.

which tests the condition after the loop has executed. The while construct consists of a block of code and a condition. or if there is no Else branch. and if the condition is true. The condition is evaluated. it expects a boolean condition .either in the Else block (which is usually optional).A while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. the control structure is often also known as a pre-test loop. Compare with the do while loop. The while loop can be thought of as a repeating if statement. HCL PROJECT Page 5 . which means “the variable x contains a number that is greater than zero” . Otherwise. This repeats until the condition becomes false. If the condition is true. the statements following the Then are executed. x > 0.and evaluates that condition. then after the End If. the code within the block is executed. Because while loops check the condition before the block is executed. the execution continues in the following branch . Decision Making statement used---if— In this program if statement is used to check the condition on n when an interpreter finds an If.for example.

&puc2).tax(amnt)).\n"). if(ch==1) { printf("\nNow enter the per unit charge for 1st 200 units:\t"). printf("\n\nTotal payable amount is Rs. total=amnt+tax(amnt).%f". printf("\n\nyour total charges for the used units is Rs.puc3). printf("ELECTRICITY BILL CALCULATOR. amnt). printf("\n\n\nNow enter 1 to calculate your bill or any other integer to exit\n").&puc1). printf("\nNow enter the per unit charge for remaining units:\t"). float puc1. float puc1. float total. void main() { int ch.ch1. float unt. scanf("%f". printf(“\n\n\nNow to continue with different value of unit usage type 1\n\t\t\tOR\nType any other integer to exit”). scanf("%f". float puc2. printf("This is the program to calculate your electricity bill as per your unit usage\n").puc1. printf("\nNow enter the per unit charge for 2nd 200 units:\t").%f".&unt).h> float chrgs(float num.5%").. scanf(“%d”. printf("\nNow enter your total unit usage").puc2.&ch). scanf("%f".h> #include<conio. amnt= chrgs(unt.amnt.puc3. while(ch1==1) { printf("\nNow enter another value of unit usage"). HCL PROJECT Page 6 . printf("\n\n Your total tax will be Rs. printf("In this program 1st u have to enter the per unit charge for the electricity\nfor 1st 200 units\n then for the 2nd 200 units\n n then for the rest of the units\nby default the value of tax is taken to be 7.total).&ch1).. clrscr().&puc3).CODING #include<stdio. scanf("%f".puc2. scanf("%f". scanf("%d".%f ". float tax(float num).&unt). float puc3).

%f ". scanf(“%d”. } HCL PROJECT Page 7 . printf("\n have a nice day. amnt).5)/100). amnt=(puc1*200)+(puc2*200)+(puc3*num). Good bye!!!! :-)"). VAIBHAV JAIN").puc3). amnt=(puc1*200)+(puc2*num). getch().0.amnt= chrgs(unt.%f". if(num<200) { amnt=(puc1*num). float puc1. } if(num>200 && num<400) { num=num-200. float puc2.puc2. float puc3) { float amnt=0.puc1. } return(amnt). } } printf("\n \n \n This program was made by Mr.&ch1). } float tax(float num) { return((num*7.total).%f". } if(num>400) { num=num-400. printf("\n\nTotal payable amount is Rs. printf("\n\n Your total tax will be Rs. printf("\n\nyour total charges for the used units is Rs.tax(amnt)). } float chrgs(float num. printf("\n Thank you for spending your precious time in using it"). total=amnt+tax(amnt). printf("\n\n\nNow to continue with different value of unit usage type 1\n\t\t\tOR\nType any other integer to exit").

OUTPUT WINDOW HCL PROJECT Page 8 .