![nini0372](/avatars/31312.jpg)
nini0372
07.07.2020 •
Computers and Technology
Use function GetUserInfo to get a user's information. If user enters 20 and Holly, sample program output is:Holly is 20 years old. #include #include void GetUserInfo(int* userAge, char userName[]) { printf("Enter your age: \n"); scanf("%d", userAge); printf("Enter your name: \n"); scanf("%s", userName); return;}int main(void) { int userAge = 0; char userName[30] = ""; /* Your solution goes here */ printf("%s is %d years old.\n", userName, userAge); return 0;}
Solved
Show answers
More tips
- C Computers and Internet How to Choose a Laptop: Expert Guide and Tips...
- C Computers and Internet How to Choose a Monitor?...
- H Horoscopes, Magic, Divination Where Did Tarot Cards Come From?...
- S Style and Beauty How to Make Your Lips Fuller? Ideas and Tips for Beautiful Lips...
- C Computers and Internet How to Learn to Type Fast?...
- A Art and Culture Who Said The Less We Love a Woman, the More She Likes Us ?...
- F Family and Home How to Get Rid of Your Neighbors?...
- S Society and Politics How Could Nobody Know About the Dead Mountaineers?...
- H Health and Medicine How to Cure Adenoids?...
Answers on questions: Computers and Technology
- C Computers and Technology Members of the public who report on current events true or false...
- M Mathematics Which expression is equivalent to (73)−2? (3 And 2 are exponets) (20 Points) A). 1/7 * 7 * 7 * 7 * 7 * 7 B).7 C).1/7 D). -1/7 * 7 * 7 * 7 * 7 * 7...
- H History How did the cultivation of sugar influence sugar cookies?...
- H History Before the war, atlanta was a growing city along the railroad, then during the war A. its population declined B. it was an important confederate city for storing goods and housing...
- E English Work by yourself in the hall and complete the lesson post mortem of the protagonist please help me...
- E English Hey yall how is yall IM bout to Play Some BlOxBuRg...
- C Chemistry For many purposes we can treat butane (C4H10) as an ideal gas at temperatures above its boiling point of - 1. °C. Suppose the pressure on a 3.0 m3 sample of butane gas at 19.0°C is...
- M Mathematics 5y + 2 – 3(4y) = 0. Solving steps...
- M Mathematics PLEASE PLEASE PLEASE HELP! 19...
- M Mathematics If IK IM, which statement is true?...
Ответ:
Replace
/*Your solution goes here*/
with
GetUserInfo(&userAge, userName);
And Modify:
printf("%s is %d years old.\n", userName, userAge)
to
printf("%s is %d years old.", &userName, userAge);
Explanation:
The written program declares userAge as pointer;
This means that the variable will be passed and returned as a pointer.
To pass the values, we make use of the following line:
GetUserInfo(&userAge, userName);
And to return the value back to main, we make use of the following line
printf("%s is %d years old.", &userName, userAge);
The & in front of &userAge shows that the variable is declared, passed and returned as pointer.
The full program is as follows:
#include <stdio.h>
#include <string.h>
void GetUserInfo(int* userAge, char userName[]) {
printf("Enter your age: ");
scanf("%d", userAge);
printf("Enter your name: ");
scanf("%s", userName);
return;
}
int main(void) {
int* userAge = 0;
char userName[30] = "";
GetUserInfo(&userAge, userName);
printf("%s is %d years old.", &userName, userAge);
return 0;
}
Ответ:
Southeast Indian - Southeast Indian - Subsistence and material culture: The Southeast was one of the more densely populated areas of native North America at the time of European contact. Most groups resided in the piedmont, where they took advantage of extensive game resources, wild plant foods, and an abundance of arable land.
Explanation: