Home > Back-end >  The second the scanf can't input values, Daniel will look at the great god, thank you.
The second the scanf can't input values, Daniel will look at the great god, thank you.

Time:10-04

//the program calculating the hight of 2.17 a tree
#include

Int main (void)
{
Long shorty=0 l;//shorty 's hight in inches
Long lofty=0 l;//lofty 's hight in inches
Long feet=0 l;
Long inches=0 l;
Long shorty_to_lofty=0 l;//short from shorty to lofty in inches
Long lofty_to_tree=0 l;//short from lofty tree in inches to
Const long inches_per_foot=12 l;
Long tree_height=0 l;

//get lofty 's height
Printf (" Enter lofty 's height to the top of his/its ehrs head, in whole feet: ");
The scanf (" % ld ", & amp; Feet);
Printf ("... And then inches: ");
The scanf (" % ld ", & amp; Inches);
Lofty=... * inches_per_foot + inches;

//get shorty 's height up to his eyes
Printf (" enter short 's height up to his eyes, in whole feet: ");
The scanf (" % ld ", & amp; Feet);
Printf ("... And then inches: ");
The scanf (" ld ", & amp; Inches);
Shorty=... * inches_per_foot + inches;

//get the short from shorty to lofty
Printf (" enter the short between shorty and lofty, in whole feet: ");
The scanf (" % ld ", & amp; Feet);
Printf ("... And then inches: ");
The scanf (" ld ", & amp; Inches);
Shorty_to_lofty=... * inches_per_foot + inches;

//get the short from lofty to the tree
Printf (" finally enter the short from lofty to the tree to on foot: ");
The scanf (" % ld ", & amp; Feet);
Lofty_to_tree=... * inches_per_foot;

//the code to calculate the height of the tree will go here
//the code to display the result will go here

Tree_height=(lofty - shorty) * (shorty_to_lofty + lofty_to_tree)/shorty_to_lofty + shorty.
Printf (" The height of The tree is % ld feet and % ld inches. \ n ",
Tree_height/inches_per_foot tree_height % inches_per_foot);

return 0;
}

CodePudding user response:

Ask for to ah, is really no way out,

CodePudding user response:

This line of code, it ourselves,
the scanf (" % ld ", & amp; Feet);

CodePudding user response:

After every the scanf add a getchar ()
  • Related