Using visual studios please program this Daniel Martinez Age:20 height: 5’3 11/2
ID: 3742733 • Letter: U
Question
Using visual studios please program this Daniel Martinez Age:20 height: 5’3 11/23/1997 Using 4 printfs &4 output lines, print: (1) Your name, (2) Your exact age (see last slide in Datatypes.ppt), and (3) your height in English and (4) Metric. Integer variables in your program should be initialized to your birthday (as bmo, bda, and byr), the current date (as cmo, cda, and cyr), and your height (as hft & hin). Well examine a more general approach later. Use arithmetic statements to compute your age (considering only years months, and days) and your metric height, both as floating point variables. For now, simply assume every month contains 365.5/12 days; we'll examine greater accuracy later. Show floating-point accuracy to three decimal places. Program output should look like this: My name is: . My age in years is: fff.fff years. My height is: d ft. & dd in, which equals: f.fff meters.Explanation / Answer
HERE IS YOUR SOLUTION HOPE YOU LIKE IT :)
#include<iostream.h>
#include<stdio.h>
int main()
{
char a;
float bmo,bda,byr,cmo,cda,cyr,a,b,c,centimeters,inches;/* HERE WE ARE INITIALISING THE VARIABLES */
int feet;
printf("ENTER YOUR NAME : ");
scanf("%c",&a);
printf(" ");
printf(" _____________________________________________________________");
printf(" CENTIMETER TO FEET AND INCHES CONVERSION ");/* THIS IS FOR CALCULATING YOUR HEIGHT */
printf(" ENTER YOUR HEIGHT IN CENTIMETER : ");
scanf("%f",¢imeters);
inches=centimeters / 2.54;
feet=inches/12;
inches=inches-(feet*12);
printf(" _____________________________________________________________");
printf(" ");
printf("ENTER YOUR BIRTHYEAR :"); /* THIS IS FOR CALCULATING YOUR AGE */
scanf("%f",&byr);
printf("ENTER YOUR BIRTHMONTH :");
scanf("%f",&bmo);
printf("ENTER YOUR BIRTHYEAR :");
scanf("%f",&byr);
printf("ENTER YOUR BIRTHDATE:");
scanf("%f",&bda);
printf("ENTER THE CURRENTYEAR :");
scanf("%f",&cyr);
printf("ENTER THE CURRENTMONTH :");
scanf("%f",&cmo);
printf("ENTER THE CURRENTDAY :");
scanf("%f",&cda);
a=cyr-byr;/* HERE WE ARE SUBTRACTING YOUR BIRTH YEAR FROM THE CURRENT YEAR */
b=12-bmo;/* HERE WE ARE SUBTRACTING YOUR BIRTH YEAR FROM 12 MONTHS */
a=365.5-bda;/* HERE WE ARE SUBTRACTING YOUR BIRTH DAY FROM 365 DAYS */
printf(" ");
printf(" _____________________________________________________________");/* THESE ARE THE COMMANDS TO PRINT YOUR DESIRED OUTPUT */
printf("YOUR NAME IS :",a);
printf(" YOUR Height (In Feet and Inches) :"feet,inches,centimeters);
printf(" YOU AGE IN YEARS MONTHS AND DAYS IS : ",a,b,c);
printf(" _____________________________________________________________");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.