Posts

Showing posts from November, 2016

Chapter 4: Case Control Structure (Let Us C)

Write a menu driven program which has following options: 1. Factorial of a number. 2. Prime or not 3. Odd or even 4. Exit // Let Us C (Chapter 4 : Case Control Structure) : Program-1 /* Write a menu driven program which has following options: 1. Factorial of a number. 2. Prime or not 3. Odd or even 4. Exit*/ #include<stdio.h> void main() { int choice,N,Fact,i; clrscr(); while(1) { printf("\n------------------------------------------------------"); printf("\nChoices are as below\n"); printf("1:Factorial\t"); printf("2:Prime\t\t"); printf("3:Odd/Even\t"); printf("4:Exit"); printf("\nEnter your choice:"); scanf("%d",&choice); switch(choice) { case 1 : printf("Enter the No.: "); scanf("%d",&N); Fact=1;

Chapter 3: The Loop Control Structure (Let Us C)

(a) Write a program to calculate overtime pay of 10 employees. Overtime is paid at the rate of Rs. 12.00 per hour for every hour worked above 40 hours. Assume that employees do not work for fractional part of an hour. // Let Us C (Chapter 3 : The Loop Control Structure) : Program-1 /* Write a program to calculate overtime pay of 10 employees. Overtime is paid at the rate of Rs. 12.00 per hour for every hour worked above 40 hours. Assume that employees do not work for fractional part of an hour */ #include<stdio.h> int i,T,OT=0,Total_OT,OT_Pay; void main() { clrscr(); for(i=1;i<=10;i++) { printf("\nEnter Total hours worked by Employee-%d: ",i); scanf("%d",&T); if(T>40) { OT = T-40; printf("OT pay for employee %d is Rs.%d/-",i,OT*12); } else { OT=0; printf("OT pay for employee %d is Rs.%d/-",i,OT*12); }

Chapter 2: The Decision control Structure (Let Us C)

(a) If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred. // Let Us C (Chapter 2 : The Decision control Structure) : Program-1 /* If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred */ #include<stdio.h> double C,S,P,L; void main() { clrscr(); printf("Enter cost price of an item: "); scanf("%lf",&C); printf("Enter Selling price of the same: "); scanf("%lf",&S); if(S>C) { P=S-C; printf("Seller made profit of Rs. %0.2lf",P); } else if(C>S) { L=C-S; printf("Seller incurred loss of Rs. %0.2lf",L); } else if(S==C)

Chapter 1 : Getting Started (Let us C)

(a) Ramesh's basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary. // Let Us C Chapter-1:Program-1 /*(a) Ramesh's basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary.*/ #include<stdio.h> float BASIC,DA,HRA,GS; void main() { clrscr(); printf("Enter BASIC salary: "); scanf("%f",&BASIC); DA = BASIC*0.4; HRA = BASIC*0.2; GS = BASIC + DA + HRA; printf("\nGross Salary = %f",GS); } (b) The distance between two cities (in km.) is input through the keyboard. Write a program to convert and print this distance in meters, feet, inches and centimeters. // Let Us C Chapter-1:Program-2 /* The distance between two cities (in km.) is input through the key