Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Help with c program for class!!!

exslax2exslax2 Member Posts: 7
I have to write a c program for class. It is an interactive survey that asks 5 questions, supplies 4 possible responses and stores all of this in an array to output a summary report. I'm not sure where to even start. I have created some arrays: one to store the user's name when prompted( char *name[20];) One to store all of the questions to be asked( char *questions[] = {"question1","question2",....}; One to store all of the possible responses( char *responses[] = {"response1","response2",...};

It should look like this:

Do you attend class consistently?
1. Never
2. Occasionally
3. Usually
4. Frequently

Enter the number for your response: _

My instructor mentioned using function prototypes. Please help!!!!


  • BriballBriball Member Posts: 265
    Okay first off, don't use char *szText[20] typed arrays. They are dangerous! You could easily over run arrays this way. Use the STL array prototypes. I believe the header file is vector.h or just simply vector.
    It is prototyped as follows:

    vector ResponseArray;
    vector ...

    Not sure about the second one, but that should get you going on the arrays. Just search for STL, Standard Template Library.

    Now, function prototypes just means that you break down what the program does into smaller parts. This way you don't get spaghetti code like in BASIC.

    void PrintNextQuestion(int i)
    cout << QuestionArray[i] << endl;
    cin >> answer;

    And PrintPossibleResponses() would be another function prototyped in the program. Remember, a function must at least be declared before using it. So you would at least need void PrintPossibleRespsonses(int);
    before PrintNextQuestion(int i). Hope this starts you out.
  • Andre YoungAndre Young USAMember Posts: 0

    _______ { } free video tutorials and ebooks about { Swift C# Go Ruby MATLAB R Visual Basic .NET Perl C PL/SQL Objective-C Visual Basic Python Java Assembly C++ Delphi JavaScript PHP Scratch Logo ML FoxPro Julia Fortran ABAP D Bash Lisp Rust Ada LabVIEW Dart F# Lua Apex Crystal Erlang Hack Awk SAS Scheme VBScript Scala Kotlin Transact-SQL Prolog COBOL Alice Clojure } __

Sign In or Register to comment.