Chapter at a glance
Complete textbook solutions and programming guide for Class 10 Computer Science Unit 12 Structured Programming in C, covering tokens, data types and format specifiers (%d, %f, %c), control structures (if-else, switch, loops), and solved C programs for primes, palindromes, and greatest number.
- Structure of a C Program: #include, main(), return 0
- C Tokens: Keywords, Identifiers, Operators
- Format Specifiers: %d, %f, %c, %lf
- Control Structures: if-else, switch-case, for, while, do-while
- Solved C Programs: Primes, Palindromes, Factorial
Exam focus: Writing clean, compilable C code with proper syntax and semicolons, contrasting while and do-while loops, and explaining the role of format specifiers in printf and scanf.
Key formulas and definitions
- Digit extraction in C: rem = n % 10; n /= 10
On this page (11 sections)
- The lesson in short
- Section A: C Language Tokens, Data Types, and Structure
- StructureStandard Structure of a C Program
- Data TypesFundamental Data Types and Format Specifiers
- Section B: Control Structures: Selection and Iteration in C
- SelectionDecision Making: if-else and switch-case
- LoopsIterative Loops in C: for, while, and do-while
- Section C: Complete Solved C Programs
- C Program 1Program 1: Find the Largest of Three User-Supplied Numbers
- C Program 2Program 2: Reverse an Integer and Check for Palindrome
- C Program 3Program 3: Check Prime Number
Solutions and answers
The lesson in short
C is a foundational, general-purpose, procedural programming language developed by Dennis Ritchie at Bell Laboratories in 1972 that serves as the bedrock of modern system and software engineering.
Offering low-level hardware memory access alongside high-level structured control statements, C is widely utilized in developing operating systems (Linux, Windows kernel), database engines, embedded microcontrollers, and compilers.
This chapter covers C language tokens (keywords, identifiers, constants, operators), basic input/output functions (printf, scanf), conditional selection (if-else, switch), iterative loops (for, while, do-while), and complete solved programming exercises aligned with the CDC Class 10 curriculum.
Section A: C Language Tokens, Data Types, and Structure
StructureStandard Structure of a C Program
A standard C program consists of preprocessor directives, the `main()` function entry point, variable declarations, executable statements, and return statements.
| C Program Component | Example Code | Purpose and Explanation |
|---|---|---|
| Preprocessor Directive | #include <stdio.h> | Instructs compiler to include Standard Input Output header file before compilation |
| Main Function | int main() { ... } | The mandatory entry point where execution begins in every C application |
| Variable Declaration | int age; float rate; | Allocates memory and specifies data type before use |
| Executable Statements | printf("Hello World\n"); | Performs computations and standard output display |
| Return Statement | return 0; | Returns exit status code 0 to operating system, indicating successful execution |
Data TypesFundamental Data Types and Format Specifiers
| Data Type | Keyword | Storage Size | Format Specifier | Value Range |
|---|---|---|---|---|
| Character | char | 1 byte | %c | -128 to 127 (or ASCII characters) |
| Integer | int | 2 or 4 bytes | %d or %i | -32,768 to 32,767 (in 16-bit) |
| Floating Point | float | 4 bytes | %f | 3.4E-38 to 3.4E+38 (6 decimal precision) |
| Double Precision | double | 8 bytes | %lf | 1.7E-308 to 1.7E+308 (15 decimal precision) |
Section B: Control Structures: Selection and Iteration in C
SelectionDecision Making: if-else and switch-case
| Construct | Syntax Outline | Application Context |
|---|---|---|
| if-else | if (condition) { // true } else { // false } | Two-way conditional branching based on logical boolean evaluation |
| else-if Ladder | if (c1) { ... } else if (c2) { ... } else { ... } | Multi-condition evaluation testing sequential relational conditions |
| switch-case | switch (expression) { case 1: ...; break; default: ...; } | Efficient multi-way branching against discrete integer or character constants |
LoopsIterative Loops in C: for, while, and do-while
| Loop Type | Syntax | Evaluation Nature | Execution Guarantee |
|---|---|---|---|
| for loop | for (init; cond; step) { ... } | Pre-tested entry-controlled loop | Zero or more times |
| while loop | while (cond) { ... } | Pre-tested entry-controlled loop | Zero or more times |
| do-while loop | do { ... } while (cond); | Post-tested exit-controlled loop | At least once, even if condition is initially False |
Section C: Complete Solved C Programs
C Program 1Program 1: Find the Largest of Three User-Supplied Numbers
Write a C program to input three numbers and determine the greatest using nested if-else.
#include <stdio.h>
int main() {
int a, b, c, largest;
printf("Enter three integers: ");
scanf("%d %d %d", &a, &b, &c);
if (a >= b && a >= c) {
largest = a;
} else if (b >= a && b >= c) {
largest = b;
} else {
largest = c;
}
printf("The greatest number is %d\n", largest);
return 0;
}
C Program 2Program 2: Reverse an Integer and Check for Palindrome
Write a C program to reverse an integer and verify whether it is a palindrome.
#include <stdio.h>
int main() {
int n, temp, rev = 0, rem;
printf("Enter a positive integer: ");
scanf("%d", &n);
temp = n;
while (temp != 0) {
rem = temp % 10;
rev = rev * 10 + rem;
temp /= 10;
}
printf("Reversed number = %d\n", rev);
if (n == rev) {
printf("%d is a Palindrome number.\n", n);
} else {
printf("%d is NOT a Palindrome number.\n", n);
}
return 0;
}
C Program 3Program 3: Check Prime Number
Write a C program to determine whether a given integer is Prime or Composite.
#include <stdio.h>
int main() {
int n, i, count = 0;
printf("Enter an integer greater than 1: ");
scanf("%d", &n);
if (n <= 1) {
printf("%d is neither prime nor composite.\n", n);
return 0;
}
for (i = 1; i <= n; i++) {
if (n % i == 0) {
count++;
}
}
if (count == 2) {
printf("%d is a Prime number.\n", n);
} else {
printf("%d is a Composite number.\n", n);
}
return 0;
}
Frequently asked questions
What is Structured Programing in C about?
Complete textbook solutions and programming guide for Class 10 Computer Science Unit 12 Structured Programming in C, covering tokens, data types and format specifiers (%d, %f, %c), control structures (if-else, switch, loops), and solved C programs for primes, palindromes, and greatest number.
Which topics are covered in Structured Programing in C?
Class 10 Computer Science “Structured Programing in C” covers: Structure of a C Program: #include, main(), return 0; C Tokens: Keywords, Identifiers, Operators; Format Specifiers: %d, %f, %c, %lf; Control Structures: if-else, switch-case, for, while, do-while; Solved C Programs: Primes, Palindromes, Factorial.
What should I focus on in Structured Programing in C for the exam?
Writing clean, compilable C code with proper syntax and semicolons, contrasting while and do-while loops, and explaining the role of format specifiers in printf and scanf.
What are the key formulas or definitions in Structured Programing in C?
Digit extraction in C: rem = n % 10; n /= 10.
Where can I read the Class 10 Computer Science “Structured Programing in C” solutions?
Right on this page. They are free and you do not need to sign up. For chapter quizzes and the AI tutor, install the Sikshya Plus app.
Study tips
Do not just read it. Practice it.
You have read the solutions for Structured Programing in C. Now test yourself, ask the AI tutor and keep your streak going.




- AI quizzes for this chapterTest yourself with instant feedback and explanations after every answer.
- AI tutor, free, 24/7Stuck on a question? Ask in your own words and get a step-by-step explanation.
- 14 AI tools in one appSummarizer, grammar checker, flashcards, essay help, math solver and more.
- Past questions and notesPast papers and your own notes organized chapter by chapter.