Exforsys
+ Reply to Thread
Results 1 to 7 of 7

Array

This is a discussion on Array within the C and C++ forums, part of the Programming Talk category; Can somebody help me with code that will accept 5 student names and scores in 3 courses and sum up ...

  1. #1
    Shyner is offline Junior Member Array
    Join Date
    Jul 2009
    Answers
    1

    Array

    Can somebody help me with code that will accept 5 student names and scores in 3 courses and sum up the score, then grade them accordingly?


  2. #2
    ba7ora's Avatar
    ba7ora is offline Junior Member Array
    Join Date
    Jul 2009
    Location
    Oman
    Answers
    5
    i think u have 2 use STRICTER 2 do this so .... i dont know maybe it will help u

    this is an example of STRICTER WITH POINTERS mybe will help 2

    #include<iostream>
    using namespace std;
    struct stu,*a;
    void main()
    {
    int id;
    char name[20];
    };
    struct stu *a,b;
    cout<<"Enter the ID"<<endl;
    cin>>b.id;
    cout<<"Enter the name"<<endl;
    cin>>b.name;
    a=&b;
    cout<<"The student diteils are"<<endl;
    cout<<a->id<<"\t"<<a->name;
    }


  3. #3
    SelahJadenCald is offline Junior Member Array
    Join Date
    Apr 2010
    Answers
    4
    An array is a systematic arrangement of objects, usually in rows and columns. Specifically, it may refer to several things.


  4. #4
    sujeet.varshney is offline Junior Member Array
    Join Date
    Jul 2010
    Answers
    7
    Quote Originally Posted by Shyner View Post
    Can somebody help me with code that will accept 5 student names and scores in 3 courses and sum up the score, then grade them accordingly?

    #include<iostream.h>

    struct student
    {
    char nm[20];
    float m1,m2,m3;
    };


    void main()
    {

    student s[5];

    for(int i=0;i<5;i++)
    {
    cout<<"\nEnter the name ";
    cin>>s[i].nm; //input names without spaces
    cout<<"\nEnter the marks ";
    cin>>s[i].m1>>s[i].m2>>s[i].m3;
    }

    for(i=0;i<5;i++)
    {
    cout<<s[i].nm<<" Your grade is ";
    int s=0;

    s=s[i].m1+s[i].m2+s[i].m3;

    if(s>=270)
    cout<<"\nGrade A";
    else if(s>=150 && s<270)
    cout<<"\nGrade B";
    else
    cout<<"\nGrade C ";
    }
    }


  5. #5
    dwayne is offline Junior Member Array
    Join Date
    Dec 2010
    Answers
    1
    Can someone please help me write a code for this program. PLEASE i really need help..i think ur suppose to use array but i'm not sure how to do it!

    As part of a global warming analysis, a research facility tracks outdoor temperatures at the North Pole once a day, at noon, for a year. At the end of each month, these temperatures are entered into the computer and processed. The operator will enter 28, 29, 30, or 31 data items, depending on the month. You may use -500 as a sentinel value after the last temperature, since that is lower than absolute 0. Your main program should call the read_temps(), hot_days(), and print_temps() functions described here:

    1. Write a function, read_temps(), that has one parameter, an array called temps, in which to store the temperatures. Read the real data values for one month and store them into the slots of an array. Return the actual number of temperatures read as the result of the function.
    2. Write a function, hot_days(), that has two parameters: the number of temperatures for the current month and an array in which the temperatures are stored. Search through the temperature array and count all the days on which the noon temperature exceeds 32 F. Return this count.
    3. Write a function, print_temps(), with the same two parameters plus the count of hot days. Print a neat table of temperatures. At the same time, calculate the average temperature for the month and print it at the end of the table, followed by the number of hot days.


  6. #6
    Manyamanas is offline Member Array
    Join Date
    Dec 2010
    Answers
    32
    #include<iostream.h>
    #include<conio.h>
    #include<string.h>
    #include<stdio.h>
    struct student //structure
    {
    char nm[20];
    float s,s2,s3;
    }s[5];

    void main()
    {

    for(int i=0;i<5;i++)
    {
    cout<<"\nEnter the name ";
    gets(s[i].nm);
    cout<<"\nEnter the marks ";
    cin>>s[i].2>>s[i].s2>>s[i].s3;
    }

    for(i=0;i<5;i++)
    {
    cout<<s[i].nm<<" Your grade is ";
    int s=0;

    s=s[i].s+s[i].s2+s[i].s3;

    if(s>=270)
    cout<<"\nGrade A";
    else if(s>=150 && s<270)
    cout<<"\nGrade B";
    else
    cout<<"\nGrade C ";
    }
    getch();
    }


  7. #7
    Manyamanas is offline Member Array
    Join Date
    Dec 2010
    Answers
    32

    pointer

    what is the difference between array of pointer and array as a pointer????plz help


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...