C Programming • C Basics, Operators, Loops
C Programming / C Tokens — Exercises

C Tokens — Exercises

Practical 2 C Basics, Operators, Loops

Write a C program and identify the keywords, identifiers, constants and operators used in it.

Practical / Solution

C Tokens — Exercise 1

Problem

Write a C program and identify the keywords, identifiers, constants and operators used in it.

Program

#include <stdio.h> int main() { int a = 10; int b = 20; int sum = a + b; // display the result printf("Sum = %d\n", sum); return 0; }

Explanation

In this program, int and return are keywords, a, b and sum are identifiers, 10 and 20 are constants, and + and = are operators.

Expected Output

Sum = 30