Store information of 5 students using Structure
Given details (like roll number, name and marks) of 5 students as an input, read all the details into Student structure and display the content.
Input:
1 Jack 72.12
2 Tom 42.42
3 Robert 72.12
4 Michael 72.12
5 James 72.12
where:
Output:
1 Jack 72.12
2 Tom 42.42
3 Robert 72.12
4 Michael 72.12
5 James 72.12
not sure what to do here.
not sure where i'm going wrong with my code.
#include <stdio.h>
struct student
{
char name[30];
int roll;
float marks;
} s[10];
int main()
{
int i;
for(i=0; i<5; i++)
{
s[i].roll = i;
scanf("%s",s[i].name);
scanf("%f",&s[i].marks);
}
for(i=0; i<5; i++)
{
puts(s[i].name);
printf(" %.2f",s[i].marks);
}
return 0;
}
`Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
#include <stdio.h>
struct student
{
char name[30];
int roll;
float marks;
} s[10];
int main()
{
int i;
for(i=0; i<5; i++)
{
s[i].roll = i;
scanf("%d",&s[i].roll);
scanf("%s",s[i].name);
scanf("%f",&s[i].marks);
}
for(i=0; i<5; i++)
{
printf("%d ",s[i].roll);
printf("%s ",s[i].name);
printf("%.2f\n",s[i].marks);
}
return 0;
}
Kindly revert for any queries
Thanks.
Store information of 5 students using Structure Given details (like roll number, name and marks) of...
Given details (like roll number, name and marks) of 5 students as an input, read all the details into Student structure and display the content. Input: 1 Jack 72.12 2 Tom 42.42 3 Robert 72.12 4 Michael 72.12 5 James 72.12 where: All lines represent Roll number, Name and Marks respectively. Output: 1 Jack 72.12 2 Tom 42.42 3 Robert 72.12 4 Michael 72.12 5 James 72.12 not sure why my output is off. #include <stdio.h> struct student {...
Hello, I am having trouble with a problem in my C language class. I am trying to make a program with the following requirements: 1. Use #define to define MAX_SIZE1 as 20, and MAX_SIZE2 as 10 2. Use typedef to define the following struct type: struct { char name[MAX_SIZE1]; int scores[MAX_SIZE2]; } 3. The program accepts from the command line an integer n (<= 30) as the number of students in the class. You may assume that the...
****Using C and only C****
I have some C code that has the function addRecord, to add a
record to a linked list of records. However, when I run it, the
program exits after asking the user to input the address. See
picture below:
Here is my code:
#include<stdio.h>
#include<stdlib.h>
struct record
{
int accountno;
char name[25];
char address[80];
struct record* next;
};
void addRecord(struct record* newRecord) //Function For Adding
Record at last in a SinglyLinkedList
{
struct record *current,*start,*temp;...
Write the functions needed to complete the following program as described in the comments. Use the input file course.txt and change the mark of student number 54812 to 80. /* File: course.cpp A student's mark in a certain course is stored as a structure (struct student as defined below) consisting of first and last name, student id and mark in the course. The functions read() and write() are defined for the structure student. Information about a course is stored as a...
struct student { char name[10]; int rank; }; Using the student structure given above, create an array of size 5 students.. Then write a complete C program to sort the students array based on the students rank. Use the following sorting techniques in your code. Don’t forget to print initial array and final (sorted) array. a. Selection sort b. Insertion sort c. Merge sort / Quick sort.
C++ program that reads students' names followed by their test scores (5 scores) from the given input file, students.txt. The program should output to a file, output.txt, each student's first name, last name, followed by the test scores and the relevant grade. All data should be separated by a single space. Student data should be stored in a struct variable of type StudentType, which has four components: studentFName and studentLName of type string, an array of testScores of type int...
// READ BEFORE YOU START:
// You are given a partially completed program that creates a list of students for a school.
// Each student has the corresponding information: name, gender, class, standard, and roll_number.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the directions carefully.
// If you modify any of the given code, the return types, or the parameters, you...
C programming The program will require the following structure: struct _data { char *name; long number; }; The program will require command line arguments: int main(int argv, char **argc) { Where argv is the number of arguments and argc is an array holding the arguments (each is a string). Your program must catch any case where no command line arguement was provided and print a warning message (see below). You MUST include/use the following functions, defined as follows: int SCAN(FILE...
Within this C program change the input to a file instead of individual input from the user. You must take the input file name on the command line. Be sure to have simple error checking to be sure the file exists and was successfully opened. The input file will have the following format: First line: Number of students Second Line: Number of grades Third Line: Student Names, space delimited Fourth+ Line(s): Grades for all students for one assignment, space delimited....
c program Your teacher want to find out who is the most hardworking student in class! They want to input the names according to the order they fell asleep, then print their names in the reverse order. Although you can create an array large enough to store all names, your teacher don’t want to waste our precious memory! The first line of the input is an integer x, which indicate the number of students in class. Then there are x...