[H]write C programs for the following:
(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.
click here for Answer!!!
Answer:
main()
{
float bs,gs;
printf("\nInput Basic Salary");
scanf("%f",&bs);
gs=bs*(16.0/10.0);
printf("\nGross Salary is %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.
click here for Answer!!!
Answer :
main()
{
float distance,distancem,distancefeet,distanceinches,distancecm;
printf("\nInput distance in km");
scanf("%f",&distance);
distancem= distance*1000.0;
distancefeet= distancem*3.2808;
distanceinches= (distance*100000.0)/2.54;
distancecm = distance*100000.0;
printf("\n Distance in metres = %fm\n Distance in feet = %fft\n Distance in inches = %finches\n Distance in cm = %fcm",distancem,distancefeet,distanceinches,distancecm);
}
(c) 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.
click here for Answer!!!
main()
{
float a,b,c,d,e,t,am,pm;
printf("\nInput the 5 test marks followed by total obtainable marks");
scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&t);
am=(a+b+c+d+e)/5;
pm=(am/t)*100.0;
printf("\nThe aggregate marks is %f\nThe percentage marks is %f",am,pm);
}
(d)Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to convert this temperature into Centigrade degrees.
click here for Answer!!!
Answer:
main()
{
float c,f;
printf("\nInput the temperate(Fahrenheit)");
scanf("%f",&f);
c= (f-32)*(100.0/180.0);
printf("\nThe temperature in Celsius is %f",c);
}
(e) 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.
click here for Answer!!!
void main()
{
float l,b,r,arear,perimeterr,areac,perimeterc;
printf("\nInput the length and breadth of rectangle and radius of circle respectively");
scanf("%f%f%f",&l,&b,&r);
arear=l*b;
perimeterr=2*l+2*b;
areac=3.141592654*r*r;
perimeterc=2*3.141592654*r;
printf("\nThe area of rectangle is %f\nThe perimeter of rectangle is %f\nThe area of circle is %f\nThe circumference of the circle is %f",arear,perimeterr,areac,perimeterc);
}
(f) Two numbers are input through the keyboard into two locations C and D. Write a program to interchange the contents of C and D.
click here for Answer!!!
void main()
{
float c,d,e,f;
printf("\nInput values of C and D");
scanf("%f%f",&c,&d);
e=c;
f=d;
c=f;
d=e;
printf("\nNow C is %f\nD is %f",c,d);
}
(g) If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits.
(Hint: Use the modulus operator ‘%’)
click here for Answer!!!
Answer:
void main()
{
float number,a,b,c,d,e;
int a1,b1,c1,d1,e1,t;
printf("\nKey in a five digit number");
scanf("%f",&number);
a=number/10000.0;
a1=a/1;
b=(number-(a1*10000.0))/1000;
b1=b/1;
c=(number-(a1*10000.0)-(b1*1000))/100;
c1=c/1;
d=(number-(a1*10000.0)-(b1*1000)-(c1*100))/10;
d1=d/1;
e=(number-(a1*10000.0)-(b1*1000)-(c1*100)-(d1*10))/1;
e1=e/1;
t=a1+b1+c1+d1+e1;
printf("\nThe sum of the five digits is %d",t);
}
(h) If a five-digit number is input through the keyboard, write a program to reverse the number.
click here for Answer!!!
Answer:
void main()
{
float a,b,c,d,e,t,a2,b2,c2,d2,e2,s;
int a1,b1,c1,d1,e1;
printf("\nInput a 5 digit number");
scanf("%f",&t);
a=t/10000.0;
a1=a;
b=(t-(a1*10000.0))/1000;
b1=b;
c=(t-(a1*10000.0)-(b1*1000))/100;
c1=c;
d=(t-(a1*10000.0)-(b1*1000)-(c1*100))/10;
d1=d;
e=t-(a1*10000.0)-(b1*1000)-(c1*100)-(d1*10);
e1=e;
a2=e1*10000.0;
b2=d1*1000.0;
c2=c1*100.0;
d2=b1*10.0;
e2=a1*1.0;
s=a2+b2+c2+d2+e2;
printf("\nThe required result is %f",s);
}
(i) 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.
click here for Answer!!!
Answer:
void main()
{
float a,d,t;
int a1,d1,t1,u;
printf("\nInput a 4 digit number");
scanf("%f",&t);
a=t/1000.0;
u=t;
a1=a;
d=u%10;
d1=d;
t1=a1+d1;
printf("\nThe Sum f %d",t1);
}
(k) 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.
click here for Answer!!!
Answer:
Note: So if its $900 the input value is 9 and if its $1970 input is 19.7
void main()
{
float t,_10,_50,_100;
int _11,_51,_101;
printf("\nInput notes in hundreds");
scanf("%f",&t);
_100=t/100;
_101=_100;
_50=(t-_101*100.0)/50;
_51=_50;
_10=(t-(_101*100.0+_51*50.0))/10;
_11=_10;
printf("\n_100 is %f\n_101 is %d",_100,_101);
printf("\nThe no of $100 notes is %d\nThe no of $50 notes is %d\nThe no of $10 notes is %d",_101,_51,_11);
}
(l) 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.
click here for Answer!!!
Answer:
void main()
{
float sp,tp,cp,cps;
printf("\nInput the total selling price of 15 itmes and total profit earned respectively");
scanf("%f%f",&sp,&tp);
cps=sp-tp;
printf("\nThe cost price of one item is %f",cp=cps/15.0);
}
(m) 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.
click here for Answer!!!
void main()
{
float s,t;
int a,b,c,d,e;
printf("\nInput a 5 digit number");
scanf("%f",&t);
a=t/10000.0;
b=(t-(a*10000.0))/1000;
c=(t-(a*10000.0)-(b*1000))/100;
d=(t-(a*10000.0)-(b*1000)-(c*100))/10;
e=(t-(a*10000.0)-(b*1000)-(c*100)-(d*10))/1;
a+=1;
b+=1;
c+=1;
d+=1;
e+=1;
if (a==10)
a=0;
if (b==10)
b=0;
if (c==10)
c=0;
if (d==10)
d=0;
if (e==10)
e=0;
s=(a*10000.0)+(b*1000.0)+(c*100.0)+(d*10.0)+(e);
printf("\nThe required result is %f",s);
}
why have you used gs=bs*(16.0/10.0);in the solution of the first question?
ReplyDeletesir j question no answer
ReplyDelete#include
ReplyDeleteint main()
{
float bsc_salary;
float dearness_allownes;
float house_rent;
float gross;
printf("enter the basic sallary\n");
scanf("%f",&bsc_salary);
dearness_allownes=(40*(bsc_salary/100));
house_rent=(20*(bsc_salary/100));
gross=(bsc_salary+dearness_allownes+house_rent);
printf("gross salary is %f\n",gross);
return 0;
}
then draw a flowchart for this program
Deletewrite program that takesa sentence as an input from the file,file name taken input from user then sorts the sentence and output on other file coding
ReplyDeletewhere i can get a flowchart
ReplyDeleteThis will help you to alter the quantity of blur easily and allow
ReplyDeletecamera make other critical decisions when you are shooting.
However, if you face a data loss situation, in absence of a valid backup,
no need to worry. It is owner by Matt Furer who has been fixing cameras
for 22 years.
My web site - d7100
It is also enabled with 4G LTE, 3G HSPA and NFC Connectivity.
ReplyDeleteAnother deal offering LCD as gift item covers a tariff offering.
Then it was dragged by a string and the results are there in front of
you.
Feel free to surf to my weblog: samsung s4
Only use your AC or Heater if it is absolutely necessary.
ReplyDeleteI found the car at a truck dealership for $7000 dollars.
Look for bargains, when buying expensive things that you need.
My webpage - nest learning thermostat
Is it an advantage or disadvantage to save everything on the web.
ReplyDeleteIf you are using a DSL modem, are tethering through
a cell phone, or are still on dial-up, you probably have a static IP address, and
will actually have to enter in information to this device to
get connected to the Internet. Properly, it has every
little thing to try and do with on the web storage.
My web-site; samsung chromebook review
Decide what you want in terms of features, processing power, memory and hard drive capacity,
ReplyDeletenever forgetting graphics cards, size and quality of display and the weight and battery life.
It has all the extra features that the i - Pad has too, just fewer apps because it's fairly new compared to the i - Pad. Apple products include the Iphones, Ipads and Ipods all at competitive prices.
Here is my web blog :: playbook review
But certainly it's also not the easiest place in the body and to clear up acne killer. As a result of the caramelization process. Listening to average folks used to be a cure-all. By the time she was on Napoleon's list as a starting point for many people, both inside and out.
ReplyDeleteSome forms of birth control pills.
Here is my web page the acne killer
all programs are working fine
ReplyDeleteI have solved almost all the problems of the book. Come to my blog for solutions. http://www.letuscalllessons.blogspot.in/
ReplyDeletethanxxxxx alot
ReplyDeleteh
ReplyDeleteramesh basic salary is input through the keyboard his dearness allowance
ReplyDelete