student@ubuntu:~$
c 1/5 20 XP

C Basics

0%

Quick Reference

Essential format specifiers:

Specifier Type Example
%d int printf("%d", 42);
%f double printf("%.2f", 3.14);
%c char printf("%c", 'A');
%s string printf("%s", "hello");
%p pointer printf("%p", &x);

Variable declaration:

int count = 0;          // Always initialize
double gpa = 3.5;
char letter = 'A';      // Single quotes for chars

Common Pitfalls

  • Uninitialized variables – Local variables contain garbage. Always assign before reading.
  • Missing & in scanfscanf("%d", x) is wrong. Use scanf("%d", &x).
  • Wrong format specifier%d for a double gives garbage. Use %f.
  • Missing newline – Output may not appear until \n flushes the buffer.

Unlocks

Complete this skill to see what it unlocks.