Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Seeking great god c language programming, the topic requirements are as follows
Seeking great god c language programming, the topic requirements are as follows
Question 1: The key is to avoid carriage returns and space characters when inputting characters and strings. You can solve it here with getchar.

Question 2: Just let your function call.

Question 3: It is still a function call, but the function 1 is required to return a value or pass an address. As for the conversion from numeric characters to integers and case conversion, the conversion is made by using the difference between ascii codes.

Here is my code, and the three functions correspond to three questions respectively.

# include & ltstdio.h & gt

# Defines the maximum length of MLEN 20// string.

char fun 1();

void fun 2();

void fun 3();

int main(void)

{

fun 1();

fun 2();

fun 3();

Returns 0;

}

char fun 1()

{

int nI

Floating point nf;

char c;

char str[MLEN];

Printf ("Please enter 1 integer, 1 floating point number, 1 character, 1 string (less than %d)\n", mlen);

Scanf("%d ",&ni);

scanf("%f ",& ampnF);

getchar();

scanf("%c ",& ampc);

getchar();

scanf("%s ",str);

Printf ("The four items entered are: %d, %.2f, %c, %s\n\n", nI, nF, c, str);

Return to c;

}

void fun2()

{

int I = 2;

printf(" loop two fun 1:\ n ");

When (I-)

fun 1();

}

void fun3()

{

int I = 2;

char c;

Printf ("Run fun 1 twice, and input characters (numeric characters are converted into shapes, letters are converted into case: \ n") each time;

When (I-)

{

c = fun 1();

if(c & gt; =' 0'& &

if(c & gt; =' a'& &

if(c & gt; =' a' & ampc & lt =' z') printf ("input capital letter %c, output lowercase: %c\n\n", c, c+32);

}

}