Home > Back-end >  Question for help
Question for help

Time:09-19

Experiment 3-2] input characters, press the return key input end, statistics the number of English letters, programming requirements:

(1) the while loop is used to implement the required functionality,

(2) using a for loop to achieve the required functionality,

#include

Int main ()

{unsigned char ch, n=0;

For (ch=getchar (); Fill in the blanks with the [[4]]. Fill in the blanks with the [[5]])

{

Fill in the blanks if ([[6]] | | ch>=97 & amp; & Ch<=122) n++;

}

Printf (" n=% d \ n ", n);

Return 0;

}
Is there a big know this how to do?

CodePudding user response:

#include

Int main ()
{
Unsigned char ch, n=0;

While ((ch=getchar ())!='\ r')
{
If ((ch & gt;='a' & amp; & Ch & lt;='z') | | (ch & gt;='A' & amp; & Ch & lt;='Z'))
{
n++;
}
}
Printf (" n=% d \ n ", n);

Return 0;

}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include

Int main ()

{unsigned char ch, n=0;

For (ch=getchar (); Ch!='\ r'; Ch=ch)

{

If ((ch & gt;=65 & amp; & Ch & lt;=90) | | ch>=97 & amp; & Ch<=122) n++;

}

Printf (" n=% d \ n ", n);

Return 0;

}

CodePudding user response:

reference 1st floor xws245925587 response:
# include & lt; Stdio. H>

Int main ()
{
Unsigned char ch, n=0;

While ((ch=getchar ())!='\ r')
{
If ((ch & gt;='a' & amp; & Ch & lt;='z') | | (ch & gt;='A' & amp; & Ch & lt;='Z'))
{
n++;
}
}
Printf (" n=% d \ n ", n);

Return 0;

}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include

Int main ()

{unsigned char ch, n=0;

For (ch=getchar (); Ch!='\ r'; Ch=ch)

{

If ((ch & gt;=65 & amp; & Ch & lt;=90) | | ch>=97 & amp; & Ch<=122) n++;

}

Printf (" n=% d \ n ", n);

Return 0;

}


Enter as' \ n ', the '\ r \ n' replace ' '
  • Related