Question

In: Computer Science

I need to write a program in C with the following specification * ​​​​​​​Line one of...

I need to write a program in C with the following specification

* ​​​​​​​Line one of the standard input will have the total number of people which must not be greater than 10

* Each of the subsequent lines of input will be the first name of a person and their number (ex. "Adam 85") one space between name and number

* Each name must be a maximum of 14 characters

* Put the first names into an array called names

* Put the numbers into an array called numbers

* This task must be done in a function (named getNumbers) invoked in the main

Solutions

Expert Solution

follow is the program as per your requirements if you have to need any help then comment it below...

Given:

* Line one of the standard input will have the total number of people which must not be greater than 10

* Each of the subsequent lines of input will be the first name of a person and their number (ex. "Adam 85") one space between name and number

* Each name must be a maximum of 14 characters

* Put the first names into an array called names

* Put the numbers into an array called numbers

* This task must be done in a function (named getNumbers) invoked in the main

The program here:-

#include<stdio.h>           

void getNumbers(int numbers[],int number,int i)      //this function gives number and put into numbers[] array...
{                                                      
  numbers[i]=number;
}



int main()
{
    int totalpeople,number;                  //variables for program that is total number of people ...

    printf("enter total number of people must not greater than 10\n");
    scanf("%d",&totalpeople);              //give input total number of peoples which is less than 10...

    char names[totalpeople][14];           //array for store the name of every person ...
    int numbers[totalpeople];             //array for store the number of each person...

    for(int i=0;i<totalpeople;i++)
    {
        printf("enter firstname and number of person\n");
        scanf("%s", names[i]); 
        scanf("%d",&number);

        getNumbers(numbers,number,i);         //function is invoked from main function to store number into array...
        number=0;
    }

printf("here you can show both arrays firstname and numbers\n");

   for (int i = 0; i < totalpeople; i++)       //display all value of both array ....
   {
        printf("%s", names[i]);
        printf("  ");
        printf("%d\n", numbers[i]);
    } 

 

return(0);
}



program:-

Output:-


Related Solutions

Need the correct line of code for c program to solve  this equation . i is a...
Need the correct line of code for c program to solve  this equation . i is a value that the program all ready calculates from user imput. t i = (x*1000)+(y*500)+(z*250
I need specific codes for this C program assignment. Thank you! C program question: Write a...
I need specific codes for this C program assignment. Thank you! C program question: Write a small C program connect.c that: 1. Initializes an array id of N elements with the value of the index of the array. 2. Reads from the keyboard or the command line a set of two integer numbers (p and q) until it encounters EOF or CTL - D 3. Given the two numbers, your program should connect them by going through the array and...
I need to write a C++ program that appends "not" into the string without using the...
I need to write a C++ program that appends "not" into the string without using the append method or any standard libraries. It should return the string if there isn't an "is" in it. Examples: is is = is not is not This is me = This is not me What is yellow? = What is not yellow? The sky is pink = The sky is not pink isis = isis What happened to you? = What happened to you?
*Need in C language also need full documentation/explanation of each line* Thank you! Write a program...
*Need in C language also need full documentation/explanation of each line* Thank you! Write a program that records high-score data from a simulated FIFA soccer game available online. The program will ask the user to enter the number of scores, create two dynamic arrays sized accordingly, ask the user to enter the indicated number of names and scores, and then print the names and scores sorted by score in descending order. The output from your program should look exactly like...
1. Specification Write a C program to implement a simple calculator that accepts input in the...
1. Specification Write a C program to implement a simple calculator that accepts input in the following format and displays the result of the computation: calc [operand_1] [operator] [operand_2] The operands operand_1 and operand_2 are non-negative integers. The operator is one of the following: addition (+), subtraction (-), multiplication (x), division (/) and modulo (%). Note: For the multiplication operator, use letter ‘x’. If you use the asterisk ‘*’, your program will not work properly 2. Implementation • The program...
I need write a small "c" program that has locations of items on a shelving unit....
I need write a small "c" program that has locations of items on a shelving unit. Im not familiar with this language. Can you guys give me some hint so I could start writing one or as example. This is my first time learning programming C. Specifically, your program should: Contain a struct representing an item on the shelf. It needs only contain the item's name and price. Ask the user for the number of shelves in the unit, and...
I need C++ program that Read an input file of text.txt one word at a time....
I need C++ program that Read an input file of text.txt one word at a time. The file should consist of about 500 words. The program should remove all punctuations,keep only words. Store the words in a built-in STL container, such as vector or map.Can someone help with any additional comments that I can understand the logic?thank you
I need assistance translating a custom C++ program to MIPS. My C++ code is the following:...
I need assistance translating a custom C++ program to MIPS. My C++ code is the following: I have made numerous attempts on my own to no avail, any assistance is appreciated. Also, template code for this solution is provided below: #include int moveRobots(int *, int *, int, int ); int getNew(int, int); int main() { int x[4], y[4], i, j, myX = 25, myY = 25, move, status = 1; // initialize positions of four robots x[0] = 0; y[0]...
For this assignment, I need to write a c program named stick which plays a matchstick-picking...
For this assignment, I need to write a c program named stick which plays a matchstick-picking game. Given an initial number of sticks, players take turns picking either 1, 2, 3 or 4 sticks from a pile. Whoever picks the last stick wins. Usage The user can run stick with or without command line arguments. i.e. somebody can enter the number of sticks to begin play when the program is launched or they can be prompted after the program begins...
For this assignment, I need to write a c program named stick which plays a matchstick-picking...
For this assignment, I need to write a c program named stick which plays a matchstick-picking game. Given an initial number of sticks, players take turns picking either 1, 2, 3 or 4 sticks from a pile. Whoever picks the last stick wins. Usage You run stick with or without command line arguments. i.e. somebody can enter the number of sticks to begin play when the program is launched or they can be prompted after the program begins running. Print...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT