Question

In: Computer Science

in c, write a probram thats will read from the user: id, names, and marks for...

in c, write a probram thats will read from the user: id, names, and marks for a chosen number of students. the program should he able to read the total number of students from the user. Then should be able to read the id, name, and marks for each student and store it into three arrays, where each record is given in a line of text, with id, name, and marks seperated by a comma.
The use of scanf is NOT allowed

Solutions

Expert Solution

#include<stdio.h>
#include<stdlib.h>
int main()
{
   //VARIABLE DECLARATIONS
   char names[1000][30],temp[30];
   int userID[1000],mark[1000];
   int i,n;
   //ASK USER FOR NUMBER OF STUDENTS TO INPUT
   printf("\n Enter the number of students want to enter");
   gets(temp); //read the nu,mber using gets()
   n=atoi(temp); //assign it to n by using atoi(), which converts string to integer
   //loop to read n number of students
   for(i=0;i<n;i++)
   {
       printf("\n Enter the name of student %d:",i+1);
       gets(names[i]); //read the name
              
       printf("\n Enter ID for student %d:",i+1);
       gets(temp); //read the student is
       userID[i]=atoi(temp); //convert to integer using atoi()
      
       printf("\n Enter mark for student %d:",i+1);
       gets(temp);//read the mark
       mark[i]=atoi(temp); //convert to integer wsing atoi()
   }
  
   printf("\n NAME\t\tUSERID\tMARKS");
   //display the details
   for(i=0;i<n;i++)
   printf("\n%s\t%d\t%d",names[i],userID[i],mark[i]);
}

OUTPUT


Related Solutions

C++ Vector Write a program that allows the user to enter the last names of the...
C++ Vector Write a program that allows the user to enter the last names of the candidates in a local election and the votes received by each candidate. The program should then output each candidate's name, votes received by that candidate, and the percentage of the total votes received by the candidate. Assume a user enters a candidate's name more than once and assume that two or more candidates receive the same number of votes. Your program should output the...
C++. Write a program that will read in id numbers and place them in an array.The...
C++. Write a program that will read in id numbers and place them in an array.The array is dynamically allocated large enough to hold the number of id numbers given by the user. The program will then input an id and call a function to search for that id in the array. It will print whether the id is in the array or not. Sample Run: Please input the number of id numbers to be read 4 Please enter an...
Using OOP, write a C++ program that will read in a file of names. The file...
Using OOP, write a C++ program that will read in a file of names. The file is called Names.txt and should be located in the current directory of your program. Read in and store the names into an array of 30 names. Sort the array using the selection sort or the bubblesort code found in your textbook. List the roster of students in ascending alphabetical order. Projects using global variables or not using a class and object will result in...
Write a program in python to read from a file the names and grades of a...
Write a program in python to read from a file the names and grades of a class of students to calculate the class average, the maximum, and the minimum grades. The program should then write the names and grades on a new file identifying the students who passed and the students who failed. The program should consist of the following functions: a) Develop a getGrades() function that reads data from a file and stores it and returns it as a...
C++ programming language. Write a program that will read in id numbers and place them in...
C++ programming language. Write a program that will read in id numbers and place them in an array.The array is dynamically allocated large enough to hold the number of id numbers given by the user. The program will then input an id and call a function to search for that id in the array. It will print whether the id is in the array or not. Sample Run: Please input the number of id numbers to be read 4 Please...
Please code C# 10. Write a program that allows a user to input names and corresponding...
Please code C# 10. Write a program that allows a user to input names and corresponding heights (assumed to be in inches). The user can enter an indefinite number of names and heights. After each entry, prompt the user whether they want to continue. If the user enters true, ask for the next name and height. If the user enters false, display the name of the tallest individual and their height. Sample run: “Name?” James “Height?” 50 “Continue?” True “Name?”...
Write a C++ program using dynamic arrays that allows the user to enter the last names...
Write a C++ program using dynamic arrays that allows the user to enter the last names of the candidates in a local election and the number of votes received by each candidate. The program must ask the user for the number of candidates and then create the appropriate arrays to hold the data. The program should then output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should...
Write a program using C to read a list of your friend names which ends by...
Write a program using C to read a list of your friend names which ends by the word end. The program builds a linked list using these names and prints the names in the order stored into the linked list The list can be created using insertion at the beginning or insertion at the end; Use switch case to select the type of insertion; Case 1:insertion in the beginning; Case2:insertion in the end. Once the list is printed after insertion;...
write a program i java that ask the user to enter salary, user ID and username...
write a program i java that ask the user to enter salary, user ID and username and out put them
write a c++ program that prompts a user to enter 10 numbers. this program should read...
write a c++ program that prompts a user to enter 10 numbers. this program should read the numbers into an array and find the smallest number in the list, the largest numbers in the list the sum of the two numbers and the average of the 10 numbers PS use file I/o and input error checking methods
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT