473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Structured Array

33
hi
my question goes like this


Write a program that can store stidents' marks into a structured array.the array will store the test marks for 10 students.Each student is required to take 3 tests..

Student No Test1 Test2 Test3
1 50 60 70
2 80 30 70
3 100 50 40
.
.
.
.
.
.

this goes like this for 10 students


the program should be able to ;
(1) Print out all data
(2)Print out data for test 2
(3)Print out the address for array 3
(4)Print out the address for test3

thanks
Sep 26 '06 #1
11 3235
godsent
33
Urgent
plxz
Sep 26 '06 #2
godsent
33
urgent...plz reply
Sep 27 '06 #3
risby
30
urgent...plz reply
You haven't asked a question.
Sep 27 '06 #4
godsent
33
You haven't asked a question.
i got to write this program in C++..

the questions are :
1. Print out all the data
2.Print out the data for test 2
3.Print out the address for the array
4.Print out the address for test 3
Sep 27 '06 #5
Banfa
9,065 Expert Mod 8TB
i got to write this program in C++..

the questions are :
1. Print out all the data
2.Print out the data for test 2
3.Print out the address for the array
4.Print out the address for test 3
These are not questions they are statements, and statements 2 and 4 are not complete and make no sense.

Please ask actual questions, we are not going to guess at what you wish to know and we are not going to write your code for you.


I suggest you start by working out what structure (or may be class since it's C++) you will use, and how you will get the data into the program.

Once you are there you can decided how to interface with the user and how you will print the data.
Sep 27 '06 #6
godsent
33
These are not questions they are statements, and statements 2 and 4 are not complete and make no sense.

Please ask actual questions, we are not going to guess at what you wish to know and we are not going to write your code for you.


I suggest you start by working out what structure (or may be class since it's C++) you will use, and how you will get the data into the program.

Once you are there you can decided how to interface with the user and how you will print the data.
heya thankx
IT WORKED....
Sep 28 '06 #7
godsent
33
helo
i've done this in a one dimensional array..all are working perfectly.... I wana know if i can do it in other way...for eg, using files or 2 dimensional array...
Oct 4 '06 #8
Banfa
9,065 Expert Mod 8TB
Probably but it's hard to tell without seeing what you have already done
Oct 4 '06 #9
godsent
33
Probably but it's hard to tell without seeing what you have already done

Expand|Select|Wrap|Line Numbers
  1.  #include<iostream.h> 
  2.  
  3.  
  4. void main()
  5. {
  6.  
  7.     int stud_id [10]={1,2,3,4,5,6,7,8,9,10}; 
  8.  
  9.  
  10.     int test1[10]={50,80,100,90,70,70,30,60,50,100}; 
  11.  
  12.  
  13.     int test2[10]={60,30,50,80,70,80,20,70,60,100};
  14.  
  15.  
  16.     int test3[10]={70,70,40,90,70,80,50,50,70,90};
  17.  
  18.  
  19.     int * mypointer; 
  20.  
  21.  
  22.     mypointer=stud_id;
  23.  
  24.     mypointer=test1;
  25.  
  26.     mypointer=test2;
  27.  
  28.     mypointer=test3;
  29.  
  30.  
  31. //    cout<<"The address of array student id 1 is "<<&stud_id[0]<<endl;
  32. //    cout<<"The address of array student id 2 is "<<&stud_id[1]<<endl;
  33.  
  34.  
  35. cout<<"Student ID"<<"\t"<<"Test 1"<<"\t"<<"Test 2"<<"\t"<<"Test 3"<<endl;
  36.  
  37. for (int i=0;i<10;i++)
  38.     {
  39.  
  40.         cout<<stud_id[i]<<"\t"<<"\t"<<test1[i]<<"\t"<<test2[i]<<"\t"<<test3[i]<<endl;
  41.  
  42.     }
  43.  
  44. cout<<endl;
  45. cout<<endl;
  46.  
  47.  
  48. cout<<"Student ID for test 2"<<"\t"<<"Test 2"<<endl;
  49.  
  50. for (int t=0;t<10;t++)
  51.     {
  52.  
  53.         cout<<stud_id[t]<<"\t"<<"\t"<<test2[t]<<endl;
  54.  
  55.     }
  56.  
  57. cout<<"The address for test 3 is "<<&test3<<endl;
  58.  
  59. }
  60.  
  61. its as simple as that
  62. ..
  63.  
i want 2 use 2 arrays,one for "test" and one for "student Id"..
please guide me on how to go about

thanks
Oct 5 '06 #10
Banfa
9,065 Expert Mod 8TB
#include<iostream.h>
i want 2 use 2 arrays,one for "test" and one for "student Id"..
please guide me on how to go about
Obviously the array stud_id doesn't change, you can change the test array to something like

Expand|Select|Wrap|Line Numbers
  1. int test[3][10]={
  2.     {50,80,100,90,70,70,30,60,50,100},
  3.     {60,30,50,80,70,80,20,70,60,100},
  4.     {70,70,40,90,70,80,50,50,70,90}
  5.   };
  6.  
  7. this
  8.  
  9.     cout<<stud_id[t]<<"\t"<<"\t"<<test2[t]<<endl;
  10.  
  11. becomes
  12.  
  13.     cout<<stud_id[t]<<"\t"<<"\t"<<test[1][t]<<endl;
  14.  
Personally I would be inclined to use a array of structures

Expand|Select|Wrap|Line Numbers
  1. typedef struct student {
  2.     int stud_id;
  3.     int test_results[3];
  4. } STUDENT;
  5.  
  6. STUDENT students[10] = {
  7.     {1, {50, 60, 70}},
  8.     {2, {80, 30, 70}},
  9.     {3, {100,50, 40}},
  10.     {4, {90, 80, 90}},
  11.     {5, {70, 70, 70}},
  12.     {6, {70, 80, 80}},
  13.     {7, {30, 20, 50}},
  14.     {8, {60, 70, 50}},
  15.     {9, {50, 60, 70}},
  16.     {10,{100,100,90}}
  17.   };
  18.  
Oct 5 '06 #11
you will have to use 2D array for test
Oct 5 '06 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Edmond Neo | last post by:
I use structured storage to store large amounts of data in various streams. I realize that I can call structured storage through a wrapper in .NET, but I'm concerned that there is a performance...
2
by: Ganesh | last post by:
Hi, I have some general questions about structured programming. I am trying to understand how the programs look like without structured programming? What constitute a structured program? How has...
3
by: _link98 | last post by:
Running DB2 ESE V8.1.8 on WinXP. This is Fixpak 8. Have a structured-type and some methods for that type. One of my methods needs to do insert / update on tables. The type specification...
3
by: ambika | last post by:
Hello, I have a very basic doubt. Why is C called a structured programming language??why structured? C++ is called a Object Oriented language 'cos it obeys the OOP's concepts..Why is C called a...
2
by: Cary | last post by:
This may reveal my poor programming skills, but here goes... I'm building a pricing tool for my business. I'm nearing the end of the project, and I've been asked to be able to save quotes in some...
2
by: coolindienc | last post by:
I got the program below and now I want to put this in a structured module. Andy suggestions? Andy from numarray import * n=input("Enter number of elements: ") x=zeros(n,Int) for i in...
12
by: einsanic | last post by:
Dear everyone, I am new to this forum and I am realitevely new to C programming so please forgive me for any basic mistakes I'll be making. I am trying to dynamically allocate the space for...
4
by: rhino | last post by:
I've been looking at the information on Structured Types in the certifcation guide and have previously read it in the DB2 manuals. As neat as Structured Types are, I'm very curious to know if they...
1
AmberJain
by: AmberJain | last post by:
HELLO, First of all, I accept that this is a too simple question but I got different opinions in different books and so I'm posting it here...... The question is simple.....Is C a block...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.