Friday 30 March 2012

Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to convert this temperature into Centigrade degrees.

Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to convert this temperature into Centigrade degrees.



#include<stdio.h>
#include<conio.h>
void main(void)
{
float fahr, centi;
printf("Please enter temperature in Fahrenheit : ");
scanf("%f", &fahr);
centi=5.0*(fahr-32.0)/9.0;
printf("The temperature in Centigrade would be %f", centi);
getch();
}




If the marks obtained by a student in five different subjects are input through the keyboard, find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject is 100.

If the marks obtained by a student in five different subjects are input through the keyboard, find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject is 100. 



#include<stdio.h>
#include<conio.h>
void main(void)
{
int maths, phy, chem, eng, urdu, aggr;
float per;


printf("Enter Marks for Maths, Physics, Chemistry, English and Urdu respectively: ");
scanf("%d%d%d%d%d", &maths, &phy, &chem, &eng, &urdu );
aggr = maths + phy + chem + eng + urdu ;
per= aggr*100.0/500.0;
printf("\nAggregate Marks are %d", aggr);
printf("\nPercentage of the Marks is %f", per);
getch();
}


Saturday 24 March 2012

Let Us C by Yashwant Kanetkar

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.


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.  
#include<stdio.h>
#include<conio.h>
void main(void)
{
int km;
long int meters, feet, inches, centimeters;
clrscr();
printf("Please enter distance between two cities: ");
scanf("%d", &km);
meters=km*1000;
feet=meters*3;
inches=feet*12;
centimeters=meters*100;
printf("\n\nMeters=%ld", meters);
printf("\nFeet=%ld", feet);
printf("\nInches=%ld", inches);
printf("\ncentimeters=%ld", centimeters);
getch();
}


Chapter-01 Getting Started

1-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.


v  If the marks obtained by a student in five different subjects are input through the keyboard, find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject is 100.

v  Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to convert this temperature into Centigrade degrees.

v  The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle.

v  Two numbers are input through the keyboard into two locations C and D. Write a program to interchange the contents of C and D.

v  If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits.
v  (Hint: Use the modulus operator ‘%’)

v  If a five-digit number is input through the keyboard, write a program to reverse the number.

v  If a four-digit number is input through the keyboard, write a program to obtain the sum of the first and last digit of this number.

v  In a town, the percentage of men is 52. The percentage of total literacy is 48. If total percentage of literate men is 35 of the total population, write a program to find the total number of illiterate men and women if the population of the town is 80,000.

v  A cashier has currency notes of denominations 10, 50 and 100. If the amount to be withdrawn is input through the keyboard in hundreds, find the total number of currency notes of each denomination the cashier will have to give to the withdrawer.

v  If the total selling price of 15 items and the total profit earned on them is input through the keyboard, write a program to find the cost price of one item.

v  If a five-digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits. For example if the number that is input is 12391 then the output should be displayed as 23402.

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.

Q: 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>
#include<conio.h>
void main(void)
{
int bas_sal;
float med_al, h_rent, gross_sal;
clrscr();
printf("Please enter Ramesh basic Salary : ");
scanf("%d", &bas_sal);
med_al = 40*bas_sal/100;
h_rent = 20*bas_sal/100;
gross_sal= bas_sal + med_al + h_rent;
printf("\nRameshs Gross Salary = %f ", gross_sal);
getch();
}




Let Us C by Yashwant Kanetkar (Solved Exercise)


Chapter-02 The Decision Control Structure
Chapter-03 The Loop Control Structure
Chapter-04 The Case Control Structure
Chapter-05 Functions and Pointers
Chapter-06 Data Types Revisited
Chapter-07 The C Preprocessor
Chapter-08 Arrays
Chapter-09 Puppetting On Strings
Chapter-10 Structures
Chapter-11 Console Input/Output
Chapter-12 File Input/Output
Chapter-13 More Issues In Input/Output
Chapter-14 Operations On Bits
Chapter-15 Miscellaneous Features
Chapter-16 C Under Windows
Chapter-17 Windows Programming
Chapter-18 Graphics Under Windows
Chapter-19 Interaction With Hardware
Chapter-20 C Under Linux
Chapter-21 More Linux Programming