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...
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...
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
Write an application that allows a user to enter the names and birthdates of up to...
Write an application that allows a user to enter the names and birthdates of up to 10 friends. Continue to prompt the user for names and birthdates until the user enters the sentinel value ZZZ for a name or has entered 10 names, whichever comes first. When the user is finished entering names, produce a count of how many names were entered, and then display the names. In a loop, continuously ask the user to type one of the names...
Write a C++ program that reads numbers from the user until the user enters a Sentinel....
Write a C++ program that reads numbers from the user until the user enters a Sentinel. Use a Sentinel of -999. Ignore all negative numbers from the user input. Do the following: Output the sum of all even numbers Output the sum of all odd numbers Output the count of all even numbers Output the count of all odd numbers You must use loops and numbers to do this. You must not use any arrays or vectors for this program.
Develop a GUI to get unique names from the user.
in JAVADevelop a GUI to get unique names from the user. . In the first frame use a label ("Name") a textfield and 2 buttons (ext' and 'inished") . In the second frame there should be a list and a scrollpane as the components . Use the components on the first frame to get the name value from the user. . When the user enters a name make sure it is not empty and has no spaces and dicks the next' button, reset the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT