UCLA · CS31 · Introduction to Computer Science I

CS31: nail every assessment, not just read the notes

Your complete guide to University of California, Los Angeles's introduction to computer science i course. See where the marks are, work real practice questions, and study with an AI tutor that knows CS31.

4 credit points Lower division undergrad Offered Fall 2025 ~35% exams Computer Science Department

Sia generates CS31 practice questions, walks through introduction and control flow step by step, and quizzes you on the material the heaviest assessments weight most heavily.

Spot the bug

Find what is wrong

Multiple choice · the fix is revealed after you answer

What does this C++ fragment print?

    int a[3] = {10, 20, 30};
    int* p = a;
    p++;
    *p = *p + 5;
    cout << a[1] << ' ' << *(p + 1);
The fix

p starts at a[0]; p++ moves it to a[1].

*p = *p + 5 changes a[1] from 20 to 25.
*(p + 1) is a[2], which is 30.
Output: 25 30. Option B forgets the write through the pointer; option C adds to the wrong element.

The trap: Thinking p++ changes the array's value rather than which element the pointer refers to. classic slip!

your whole grade
Where your grade comes from Coursework 65% · Exams 35%

One exam decides 35% of your grade. A score below 40 may fail the course. This whole page is built around that.

Overview

What CS31 is, and where it sits

CS 31 Introduction to Computer Science I is UCLA's first programming course in C++ and the gateway to the computer science and engineering majors. The offering documented here is Fall 2025, taught in two lecture sections by David Smallberg with six discussion-section teaching assistants; the Fall 2026 site was not yet published when this guide was written, but the course site shows the same three-exam structure with midterms on 28 October and 17 November 2026 and a final on 5 December 2026.

Ten weeks move from the basics of the language through control flow, functions and program development, arrays and strings, then pointers, structs and classes, constructors and function overloading. Lectures expand on the interactive zyBook; Friday discussion sections with a TA and a learning assistant work problems collaboratively.

The grade is 33% programming projects, 6% zyBook activities, 1% responsibility assignments, 9% Midterm 1, 16% Midterm 2 and 35% final. The total assignment score is capped at 30 points above the mean exam score, and a final below 40 may fail the course regardless of total.

How it differs from its first-year siblings. The 30-point cap is the rule that catches people: assignment marks do not count fully unless the exams show you learned what the projects taught. The course site also says plainly that students without prior programming experience should take CS 30 first; more than half who ignore that do not finish with a C.

Always treat your own course outline and the exam timetable as authoritative.

Difficulty & time commitment

Is CS31 hard, and how much time does it take?

CS31 is manageable if you keep a weekly rhythm and treat the back half as the main event. The pattern is consistent: it starts gently and steepens, and the heaviest assessment is the part that separates grades.

Difficulty
3.3 / 5
Moderate. Gentle early, demanding back half. Hard to fail with steady work; a top grade takes consistent practice.
Coursework
65%
Coursework carries most of the grade. The heaviest single component is the exam at 35%.
Weekly time
~12 hrs
Around 12 hours per week including class, across lectures, study and assessment.
Basics and control flowsteady
Functions, arrays and stringsrising
Pointers, structs, classes and constructorssteep

The difficulty curve and the assessment weighting point the same way: the back half is harder and worth more. Front-loading effort there is the highest-return decision in the course.

Is this course for you

Who tends to do well, and who tends to struggle

You will likely do well if

  • You have already written a program with arrays and your own functions.
  • You start projects the day they are posted; the late penalty is hourly.
  • You test your code on both required compilers before submitting.
  • You can sit evening exams in weeks 5 and 8 without conflicts.

You may struggle if

  • You are learning to program from zero; take CS 30 first.
  • You rely on projects to carry weak exams; the cap and the 40-point final rule prevent it.
  • You submit a project that compiles on one compiler only.
  • You skip discussion; the collaborative problems are exam practice.
do this ↘
What top students do differently
  • Trace pointer and array code by hand on paper before running it.
  • Rewrite each project's hardest function from memory a week later.
  • Treat Midterm 2 (16%) as the exam that predicts the final; the material from week 6 on is where grades separate.
  • Use the learning-assistant workshops for problem solving, not just debugging.

Syllabus

The 9 topics, week block by week block

The exam-weight marker on each topic shows where the marks concentrate. The amber topics carry the highest exam weight.

1

T1 · Introduction and basics

Weeks 1-2

Computer history, variables, types, input and output, expressions.

2

T2 · Control flow

Week 3

if, switch, loops, boolean logic.

3

T3 · Functions and program development

Week 4

Parameters, return values, scope, incremental development.

High exam weightQuiz me on functions →
4

T4 · Arrays

Week 5

Fixed arrays, indexing, passing arrays to functions.

High exam weightQuiz me on arrays →
5

T5 · Strings

Week 6

C++ strings and C strings.

High exam weightQuiz me on strings →
6

T6 · Pointers

Weeks 6-7, 9

Addresses, dereferencing, pointer arithmetic, arrays and pointers.

High exam weightQuiz me on pointers →
7

T7 · Structs and classes

Weeks 7-8

Members, encapsulation, member functions.

High exam weightQuiz me on structs →
8

T8 · Constructors and function overloading

Weeks 9-10

Object initialisation, overloaded functions and operators.

9

T9 · Review

Week 10

Integrating the course for the cumulative final.

High exam weightQuiz me on review →

How it's assessed

Assessment structure

ComponentWeightFormat & timing
Programming projects (seven, excluding zyBook assignments)33%Seven C++ programming projects graded on correctness by automated testing; must compile on two specified compilers. Roughly weekly, due 11pm. 12.5% per hour late; worthless after 7am next day.
zyBook interactive assignments6%Interactive activities in the required zyBook. Through the quarter. Online.
Responsibility assignments (brief online forms)1%Brief online forms completed on time. Occasional. Small credit for completion.
Midterm 1 (about one hour, evening of week 5)9%About one hour, evening sitting, lecture material to date. Tuesday of week 5, 6-7:30pm window. Mandatory; no conflicts allowed.
Midterm 2 (about one hour, evening of week 8)16%About one hour, evening sitting, lecture material to date. Tuesday of week 8, 6-7:30pm window. Mandatory.
Final exam (3 hours, Saturday end of week 10)35%Three-hour cumulative final. Saturday at the end of week 10, 11:30am-2:30pm. A score below 40 may fail the course.
Programming projects (seven, excluding zyBook assignments)33%
Seven C++ programming projects graded on correctness by automated testing; must compile on two specified compilers.
zyBook interactive assignments6%
Interactive activities in the required zyBook.
Responsibility assignments (brief online forms)1%
Brief online forms completed on time.
Midterm 1 (about one hour, evening of week 5)9%
About one hour, evening sitting, lecture material to date.
Midterm 2 (about one hour, evening of week 8)16%
About one hour, evening sitting, lecture material to date.
Final exam (3 hours, Saturday end of week 10)35%
Three-hour cumulative final.
  • The six components sum to 100. Two hurdles apply: a final exam score below 40 may fail the course regardless of total, and the combined assignment score (scaled to 100) is capped at 30 points above the mean of the three exam scores. Regrade requests must be made within one week.
  • Two mandatory evening midterms of about one hour in weeks 5 and 8 on lecture material to date, and a three-hour cumulative final on the Saturday ending week 10. Exam dates are fixed before enrolment and conflicts are not accommodated.
read this! If you read nothing else

This is a coursework course. Coursework carries 65% of the grade and the final exam (3 hours, saturday end of week 10) is the single heaviest piece at 35%, so steady work across the semester decides your result more than any one sitting. A score below 40 may fail the course.

Final exam timing: During the examination period. Confirm the exact date and venue on your exam timetable.

How to actually pass it

A weekly rhythm, two checklists, and the traps to avoid

The course rewards consistency over cramming, and practice over re-reading. Here is the loop that works, then what to have nailed before each exam.

The weekly loop

Before lecture
Complete the assigned zyBook sections.
Lecture
Note every case where the instructor says behaviour is undefined or a common bug.
Project day
Read the spec twice, then build in small compiling steps.
Friday
Work the discussion problems with the TA and LA.

Before the mid-semester checklist

  • Predict the output of loops with nested conditions.
  • Write a function with reference and value parameters correctly.
  • Manipulate arrays passed to functions.
  • Handle string comparison and indexing edge cases.

Before the final heaviest topics

  • Trace pointer arithmetic and dereferencing without running code.
  • Write a class with private data, constructors and member functions.
  • Explain when a copy is made and when a reference is used.
  • Debug a short program by reading it.

The mistakes that cost marks

01

Off-by-one array access. Reading past the end of an array is undefined behaviour and a favourite exam question.

02

Ignoring the second compiler. Code that only compiles on one of the two required compilers is not accepted.

03

Cramming the final. It is 35% and cumulative; a score below 40 can fail the course.

Teaching team

Who teaches CS31

The bios below are factual. We do not rate lecturers; any star ratings are submitted by students who have taken CS31.

Instructor (Lectures 1 and 2)

David Smallberg

Student ratingNo student ratings yet
Teaching Assistant

Jui-Nan Yen

Student ratingNo student ratings yet
Teaching Assistant

Parshan Teimouri

Student ratingNo student ratings yet
Teaching Assistant

Auguste Hirth

Student ratingNo student ratings yet
Teaching Assistant

Alex Hung

Student ratingNo student ratings yet
Teaching Assistant

Bronson Jeong

Student ratingNo student ratings yet
Teaching Assistant

Yunqi Hong

Student ratingNo student ratings yet

Teaching team as listed in the course materials reviewed. AskSia does not rate lecturers; star ratings are submitted by students who have taken CS31.

Formula & concept sheet

The vocabulary and formulas you must own

Variable
A named storage location with a type.
Reference parameter
A parameter that aliases the caller's variable.
Array
A fixed-size sequence of same-type elements.
Pointer
A variable holding a memory address.
Dereference
Accessing the value a pointer points to.
Struct
A compound type grouping named members.
Class
A struct with member functions and access control.
Constructor
The function that initialises a new object.
Function overloading
Several functions with one name and different parameter lists.

Set texts

The prescribed reading

The syllabus references map straight onto these.

CS 31 zyBook

.

Where it fits

Prerequisites, related courses & why it matters

Prior programming experience with arrays and user-written functions; otherwise CS 30 first. 4 units; lecture 4 hours, discussion 2 hours, outside study 6 hours per week.

Why it matters beyond the grade. C++ fundamentals, correctness testing and working to a spec are the base of every later systems course and of software-engineering interviews.

FAQ

Frequently asked questions

Is CS 31 hard?

Moderate on the six-factor rubric, but with real fail risk: a final below 40 can fail you and the course site says more than half of students without prior programming experience do not finish with a C or better.

What is the assessment breakdown?

Projects 33%, zyBook assignments 6%, responsibility assignments 1%, Midterm 1 9%, Midterm 2 16%, final 35%, per the Fall 2025 syllabus.

Who teaches it?

David Smallberg taught both Fall 2025 lecture sections, with teaching assistants Jui-Nan Yen, Parshan Teimouri, Auguste Hirth, Alex Hung, Bronson Jeong and Yunqi Hong.

Should I take CS 30 first?

If you have never written a program using an array and a function you wrote with parameters, the course site says yes.

How strict is the late policy?

Projects lose 12.5% per hour after the 11pm deadline and are worth nothing after 7am the next morning.

What is the 30-point cap?

Your assignment average cannot exceed the mean of your exam scores by more than 30 points; strong projects with weak exams are scaled down.

Study CS31 with Sia

Work through introduction, control flow, functions and the rest of the course with a tutor that knows it and quizzes you on the topics the assessments weight most heavily.

Start studying with Sia