✍️ 24. C Practice Arena
Move from beginner C programming to placement-level problem solving through 12 progressive levels. Each challenge uses an original CodeBhavya story presentation while preserving the intended C concept and programming skill.
🎯 Choose Your Practice Level
Start with Level 1 and move step by step, or jump directly to the topic you want to practice.
Beginner Practice
Build confidence with fundamentals, decisions, loops and pattern logic.
C Foundations
Output, input, arithmetic and everyday calculations.
Open Level →Operators & Decisions
Conditions, comparisons, decisions and switch-based logic.
Open Level →Loops & Number Logic
Iteration, digit logic, prime numbers, Fibonacci and factorial.
Open Level →Pattern Studio
Nested loops through visual star, number and alphabet patterns.
Open Level →Intermediate Practice
Strengthen arrays, strings, functions, recursion, pointers and memory.
Array Challenges
Traversal, searching, duplicates, merging and rotations.
Open Level →String Challenges
Character processing, transformations, searching and text analysis.
Open Level →Functions & Recursion
Reusable functions, recursion and structured decomposition.
Open Level →Pointers & Dynamic Memory
Addresses, pointers, dynamic arrays, strings and matrices.
Open Level →Advanced Practice
Work with records, files, dynamic memory, terminal input and bitwise programming.
Placement Practice
Finish with interview-style coding challenges and algorithmic problem solving.
🧩 Open a Level & Start Solving
Challenge cards stay compact until you open them. Each opened challenge shows the story, task, input/output contract, constraints, example, concepts and the appropriate practice mode.
Level 1 — C FoundationsOutput, input, arithmetic and everyday calculations. • 20 original CodeBhavya challengesOpen 20 Challenges
Every challenge keeps the original C-learning objective from this level, while the story, framing and presentation are newly written for CodeBhavya.
CHALLENGE 01StarterOrientation Welcome Screen
Core Skill: Hello World
View Challenge →
Orientation Welcome Screen
During a beginner lab session, the Orientation Welcome Screen needs a tiny C utility. Build the program so it can print:.
🎯 Your Task
Print:.
📥 Input Format
No runtime input is required for this challenge.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
No input
Hello World
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
printf("Hello World");
return 0;
}
CHALLENGE 02StarterStudent Badge Printer
Core Skill: Print Your Name
View Challenge →
Student Badge Printer
During a beginner lab session, the Student Badge Printer needs a tiny C utility. Build the program so it can produce your name.
🎯 Your Task
Produce your name.
📥 Input Format
No runtime input is required for this challenge.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
No input
Venu
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
printf("Venu");
return 0;
}
CHALLENGE 03BasicToken Number Kiosk
Core Skill: Read and Print an Integer
View Challenge →
Token Number Kiosk
During a beginner lab session, the Token Number Kiosk needs a tiny C utility. Build the program so it can accept an integer from the user and print it.
🎯 Your Task
Accept an integer from the user and print it.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
25
25
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
printf("%d", n);
return 0;
}
CHALLENGE 04BasicCanteen Total Counter
Core Skill: Add Two Numbers
View Challenge →
Canteen Total Counter
During a beginner lab session, the Canteen Total Counter needs a tiny C utility. Build the program so it can determine the sum of two integers.
🎯 Your Task
Determine the sum of two integers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
10 20
30
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d", a + b);
return 0;
}
CHALLENGE 05BasicWorkshop Expense Desk
Core Skill: Subtract Two Numbers
View Challenge →
Workshop Expense Desk
During a beginner lab session, the Workshop Expense Desk needs a tiny C utility. Build the program so it can determine the difference between two integers.
🎯 Your Task
Determine the difference between two integers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
20 8
12
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d", a - b);
return 0;
}
CHALLENGE 06BasicBookstall Quantity Meter
Core Skill: Multiply Two Numbers
View Challenge →
Bookstall Quantity Meter
During a beginner lab session, the Bookstall Quantity Meter needs a tiny C utility. Build the program so it can determine the product of two integers.
🎯 Your Task
Determine the product of two integers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
5 6
30
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d", a * b);
return 0;
}
CHALLENGE 07BasicCafeteria Sharing Board
Core Skill: Divide Two Numbers
View Challenge →
Cafeteria Sharing Board
During a beginner lab session, the Cafeteria Sharing Board needs a tiny C utility. Build the program so it can determine the integer quotient of two numbers.
🎯 Your Task
Determine the integer quotient of two numbers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
20 4
5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d", a / b);
return 0;
}
CHALLENGE 08EasyLab Kit Packing Desk
Core Skill: Quotient and Remainder
View Challenge →
Lab Kit Packing Desk
During a beginner lab session, the Lab Kit Packing Desk needs a tiny C utility. Build the program so it can determine quotient and remainder when one number is divided by another.
🎯 Your Task
Determine quotient and remainder when one number is divided by another.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
17 5
Quotient = 3 Remainder = 2
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("Quotient = %d\n", a / b);
printf("Remainder = %d", a % b);
return 0;
}
CHALLENGE 09EasyThree-Test Score Board
Core Skill: Average of Three Numbers
View Challenge →
Three-Test Score Board
During a beginner lab session, the Three-Test Score Board needs a tiny C utility. Build the program so it can determine the average of three numbers.
🎯 Your Task
Determine the average of three numbers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
10 20 30
20.00
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
float a, b, c;
scanf("%f %f %f", &a, &b, &c);
printf("%.2f", (a + b + c) / 3);
return 0;
}
CHALLENGE 10BasicGarden Circular Bed Planner
Core Skill: Area of a Circle
View Challenge →
Garden Circular Bed Planner
During a beginner lab session, the Garden Circular Bed Planner needs a tiny C utility. Build the program so it can compute the area of a circle.
🎯 Your Task
Compute the area of a circle.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
5
78.50
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
float r;
float pi = 3.14;
scanf("%f", &r);
printf("%.2f", pi * r * r);
return 0;
}
CHALLENGE 11BasicClassroom Floor Planner
Core Skill: Area of a Rectangle
View Challenge →
Classroom Floor Planner
During a beginner lab session, the Classroom Floor Planner needs a tiny C utility. Build the program so it can compute the area of a rectangle.
🎯 Your Task
Compute the area of a rectangle.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
10 5
50
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int length, width;
scanf("%d %d", &length, &width);
printf("%d", length * width);
return 0;
}
CHALLENGE 12EasyStudent Loan Demo
Core Skill: Simple Interest
View Challenge →
Student Loan Demo
During a beginner lab session, the Student Loan Demo needs a tiny C utility. Build the program so it can compute simple interest using:.
🎯 Your Task
Compute simple interest using:.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
10000 5 2
1000.00
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
float p, r, t;
scanf("%f %f %f", &p, &r, &t);
printf("%.2f", (p * r * t) / 100);
return 0;
}
CHALLENGE 13BasicWeather Desk Converter
Core Skill: Celsius to Fahrenheit
View Challenge →
Weather Desk Converter
During a beginner lab session, the Weather Desk Converter needs a tiny C utility. Build the program so it can convert Celsius to Fahrenheit.
🎯 Your Task
Convert celsius to fahrenheit.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
25
77.00
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
float c;
scanf("%f", &c);
printf("%.2f", (c * 9.0 / 5.0) + 32);
return 0;
}
CHALLENGE 14BasicExchange Student Weather Desk
Core Skill: Fahrenheit to Celsius
View Challenge →
Exchange Student Weather Desk
During a beginner lab session, the Exchange Student Weather Desk needs a tiny C utility. Build the program so it can convert Fahrenheit to Celsius.
🎯 Your Task
Convert fahrenheit to celsius.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
77
25.00
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
float f;
scanf("%f", &f);
printf("%.2f", (f - 32) * 5.0 / 9.0);
return 0;
}
CHALLENGE 15EasySports Bib Swap Desk
Core Skill: Swap Using Third Variable
View Challenge →
Sports Bib Swap Desk
During a beginner lab session, the Sports Bib Swap Desk needs a tiny C utility. Build the program so it can swap two integers using a third variable.
🎯 Your Task
Swap two integers using a third variable.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
10 20
20 10
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b, temp;
scanf("%d %d", &a, &b);
temp = a;
a = b;
b = temp;
printf("%d %d", a, b);
return 0;
}
CHALLENGE 16Easy+Locker Number Swap Panel
Core Skill: Swap Without Third Variable
View Challenge →
Locker Number Swap Panel
During a beginner lab session, the Locker Number Swap Panel needs a tiny C utility. Build the program so it can swap two integers without using a third variable.
🎯 Your Task
Swap two integers without using a third variable.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
10 20
20 10
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
a = a + b;
b = a - b;
a = a - b;
printf("%d %d", a, b);
return 0;
}
CHALLENGE 17BasicGeometry Practice Console
Core Skill: Square and Cube
View Challenge →
Geometry Practice Console
During a beginner lab session, the Geometry Practice Console needs a tiny C utility. Build the program so it can determine the square and cube of a number.
🎯 Your Task
Determine the square and cube of a number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
5
Square = 25 Cube = 125
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
printf("Square = %d\n", n * n);
printf("Cube = %d", n * n * n);
return 0;
}
CHALLENGE 18EasyEvent Timer Converter
Core Skill: Convert Seconds
View Challenge →
Event Timer Converter
During a beginner lab session, the Event Timer Converter needs a tiny C utility. Build the program so it can convert seconds into hours, minutes and seconds.
🎯 Your Task
Convert seconds into hours, minutes and seconds.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
3665
Hours = 1 Minutes = 1 Seconds = 5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int total, hours, minutes, seconds;
scanf("%d", &total);
hours = total / 3600;
total = total % 3600;
minutes = total / 60;
seconds = total % 60;
printf("Hours = %d\n", hours);
printf("Minutes = %d\n", minutes);
printf("Seconds = %d", seconds);
return 0;
}
CHALLENGE 19EasyAssessment Summary Desk
Core Skill: Total and Percentage
View Challenge →
Assessment Summary Desk
During a beginner lab session, the Assessment Summary Desk needs a tiny C utility. Build the program so it can accept marks of five subjects and calculate total and percentage.
🎯 Your Task
Accept marks of five subjects and calculate total and percentage.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
80 75 90 85 70
Total = 400 Percentage = 80.00
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
float a, b, c, d, e;
float total, percentage;
scanf("%f %f %f %f %f",
&a, &b, &c, &d, &e);
total = a + b + c + d + e;
percentage = total / 5;
printf("Total = %.0f\n", total);
printf("Percentage = %.2f", percentage);
return 0;
}
CHALLENGE 20Easy+Campus Mini Calculator
Core Skill: Simple Calculator
View Challenge →
Campus Mini Calculator
During a beginner lab session, the Campus Mini Calculator needs a tiny C utility. Build the program so it can perform addition, subtraction, multiplication and division.
🎯 Your Task
Perform addition, subtraction, multiplication and division.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use beginner-friendly values within normal C numeric ranges.
10 + 5
15.00
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
float a, b;
char op;
scanf("%f %c %f", &a, &op, &b);
switch(op)
{
case '+':
printf("%.2f", a + b);
break;
case '-':
printf("%.2f", a - b);
break;
case '*':
printf("%.2f", a * b);
break;
case '/':
if(b != 0)
printf("%.2f", a / b);
else
printf("Division by zero is not allowed");
break;
default:
printf("Invalid operator");
}
return 0;
}
Level 2 — Operators & DecisionsConditions, comparisons, decisions and switch-based logic. • 20 original CodeBhavya challengesOpen 20 Challenges
Every challenge keeps the original C-learning objective from this level, while the story, framing and presentation are newly written for CodeBhavya.
CHALLENGE 01BasicTemperature Safety Gate
Core Skill: Positive, Negative or Zero
View Challenge →
Temperature Safety Gate
The Temperature Safety Gate receives a value and must make the correct decision. Use C conditions so it can determine whether a number is positive, negative or zero.
🎯 Your Task
Determine whether a number is positive, negative or zero.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
-8
Negative
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
if(n > 0)
printf("Positive");
else if(n < 0)
printf("Negative");
else
printf("Zero");
return 0;
}
CHALLENGE 02BasicOdd-Even Token Scanner
Core Skill: Even or Odd
View Challenge →
Odd-Even Token Scanner
The Odd-Even Token Scanner receives a value and must make the correct decision. Use C conditions so it can determine whether an integer is even or odd.
🎯 Your Task
Determine whether an integer is even or odd.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
24
Even
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
if(n % 2 == 0)
printf("Even");
else
printf("Odd");
return 0;
}
CHALLENGE 03BasicScholarship Comparison Desk
Core Skill: Greater of Two Numbers
View Challenge →
Scholarship Comparison Desk
The Scholarship Comparison Desk receives a value and must make the correct decision. Use C conditions so it can determine the greater of two numbers.
🎯 Your Task
Determine the greater of two numbers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
25 18
25
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
if(a > b)
printf("%d", a);
else
printf("%d", b);
return 0;
}
CHALLENGE 04EasyTop Score Selector
Core Skill: Greatest of Three Numbers
View Challenge →
Top Score Selector
The Top Score Selector receives a value and must make the correct decision. Use C conditions so it can determine the greatest among three integers.
🎯 Your Task
Determine the greatest among three integers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
10 35 20
35
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if(a >= b && a >= c)
printf("%d", a);
else if(b >= a && b >= c)
printf("%d", b);
else
printf("%d", c);
return 0;
}
CHALLENGE 05BasicCanteen Coupon Validator
Core Skill: Divisible by 5
View Challenge →
Canteen Coupon Validator
The Canteen Coupon Validator receives a value and must make the correct decision. Use C conditions so it can determine whether a number is divisible by 5.
🎯 Your Task
Determine whether a number is divisible by 5.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
45
Divisible by 5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
if(n % 5 == 0)
printf("Divisible by 5");
else
printf("Not Divisible by 5");
return 0;
}
CHALLENGE 06EasyDual-Rule Entry Gate
Core Skill: Divisible by Both 3 and 5
View Challenge →
Dual-Rule Entry Gate
The Dual-Rule Entry Gate receives a value and must make the correct decision. Use C conditions so it can determine whether a number is divisible by both 3 and 5.
🎯 Your Task
Determine whether a number is divisible by both 3 and 5.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
30
Divisible by both 3 and 5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
if(n % 3 == 0 && n % 5 == 0)
printf("Divisible by both 3 and 5");
else
printf("Not divisible by both 3 and 5");
return 0;
}
CHALLENGE 07Easy+Academic Calendar Checker
Core Skill: Leap Year
View Challenge →
Academic Calendar Checker
The Academic Calendar Checker receives a value and must make the correct decision. Use C conditions so it can determine whether a given year is a leap year.
🎯 Your Task
Determine whether a given year is a leap year.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
2024
Leap Year
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int year;
scanf("%d", &year);
if(year % 400 == 0 ||
(year % 4 == 0 && year % 100 != 0))
printf("Leap Year");
else
printf("Not a Leap Year");
return 0;
}
CHALLENGE 08BasicLanguage Lab Character Gate
Core Skill: Vowel or Consonant
View Challenge →
Language Lab Character Gate
The Language Lab Character Gate receives a value and must make the correct decision. Use C conditions so it can determine whether a character is a vowel or consonant.
🎯 Your Task
Determine whether a character is a vowel or consonant.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
e
Vowel
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char ch;
scanf(" %c", &ch);
if(ch == 'a' || ch == 'e' || ch == 'i' ||
ch == 'o' || ch == 'u' ||
ch == 'A' || ch == 'E' || ch == 'I' ||
ch == 'O' || ch == 'U')
printf("Vowel");
else
printf("Consonant");
return 0;
}
CHALLENGE 09EasyKeyboard Input Classifier
Core Skill: Alphabet, Digit or Special Character
View Challenge →
Keyboard Input Classifier
The Keyboard Input Classifier receives a value and must make the correct decision. Use C conditions so it can determine whether a character is an alphabet, digit or special character.
🎯 Your Task
Determine whether a character is an alphabet, digit or special character.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
7
Digit
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char ch;
scanf(" %c", &ch);
if((ch >= 'A' && ch <= 'Z') ||
(ch >= 'a' && ch <= 'z'))
printf("Alphabet");
else if(ch >= '0' && ch <= '9')
printf("Digit");
else
printf("Special Character");
return 0;
}
CHALLENGE 10BasicElection Eligibility Booth
Core Skill: Eligible to Vote
View Challenge →
Election Eligibility Booth
The Election Eligibility Booth receives a value and must make the correct decision. Use C conditions so it can determine whether a person is eligible to vote.
🎯 Your Task
Determine whether a person is eligible to vote.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
20
Eligible to Vote
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int age;
scanf("%d", &age);
if(age >= 18)
printf("Eligible to Vote");
else
printf("Not Eligible to Vote");
return 0;
}
CHALLENGE 11BasicDistance Error Corrector
Core Skill: Absolute Value
View Challenge →
Distance Error Corrector
The Distance Error Corrector receives a value and must make the correct decision. Use C conditions so it can determine the absolute value without using abs() .
🎯 Your Task
Determine the absolute value without using abs() .
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
-25
25
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
if(n < 0)
n = -n;
printf("%d", n);
return 0;
}
CHALLENGE 12EasyTwo-Offer Selector
Core Skill: Largest Using Conditional Operator
View Challenge →
Two-Offer Selector
The Two-Offer Selector receives a value and must make the correct decision. Use C conditions so it can determine the largest of two numbers using the conditional operator.
🎯 Your Task
Determine the largest of two numbers using the conditional operator.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
40 25
40
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d", (a > b) ? a : b);
return 0;
}
CHALLENGE 13EasyMinimum Resource Selector
Core Skill: Smallest Using Conditional Operator
View Challenge →
Minimum Resource Selector
The Minimum Resource Selector receives a value and must make the correct decision. Use C conditions so it can determine the smallest of two numbers using the conditional operator.
🎯 Your Task
Determine the smallest of two numbers using the conditional operator.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
40 25
25
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d", (a < b) ? a : b);
return 0;
}
CHALLENGE 14Easy+Grade Dispatch System
Core Skill: Student Grade
View Challenge →
Grade Dispatch System
The Grade Dispatch System receives a value and must make the correct decision. Use C conditions so it can accept marks and print the grade.
🎯 Your Task
Accept marks and print the grade.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
85
Grade B
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int marks;
scanf("%d", &marks);
if(marks >= 90 && marks <= 100)
printf("Grade A");
else if(marks >= 80)
printf("Grade B");
else if(marks >= 70)
printf("Grade C");
else if(marks >= 60)
printf("Grade D");
else
printf("Grade F");
return 0;
}
CHALLENGE 15EasyCampus Store Margin Desk
Core Skill: Profit or Loss
View Challenge →
Campus Store Margin Desk
The Campus Store Margin Desk receives a value and must make the correct decision. Use C conditions so it can determine profit or loss using cost price and selling price.
🎯 Your Task
Determine profit or loss using cost price and selling price.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
500 650
Profit = 150
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int cp, sp;
scanf("%d %d", &cp, &sp);
if(sp > cp)
printf("Profit = %d", sp - cp);
else if(cp > sp)
printf("Loss = %d", cp - sp);
else
printf("No Profit No Loss");
return 0;
}
CHALLENGE 16EasyFestival Discount Counter
Core Skill: Discount Calculator
View Challenge →
Festival Discount Counter
The Festival Discount Counter receives a value and must make the correct decision. Use C conditions so it can compute the final price after discount.
🎯 Your Task
Compute the final price after discount.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
1000 10
Final Price = 900.00
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
float price, discount;
scanf("%f %f", &price, &discount);
price = price - (price * discount / 100);
printf("Final Price = %.2f", price);
return 0;
}
CHALLENGE 17Easy+Hostel Energy Billing Desk
Core Skill: Electricity Bill
View Challenge →
Hostel Energy Billing Desk
The Hostel Energy Billing Desk receives a value and must make the correct decision. Use C conditions so it can compute electricity bill based on units.
🎯 Your Task
Compute electricity bill based on units.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
250
Bill = 500.00
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int units;
float bill;
scanf("%d", &units);
if(units <= 100)
bill = units * 1.50;
else if(units <= 200)
bill = 100 * 1.50 +
(units - 100) * 2.00;
else
bill = 100 * 1.50 +
100 * 2.00 +
(units - 200) * 3.00;
printf("Bill = %.2f", bill);
return 0;
}
CHALLENGE 18EasyConstruction Triangle Validator
Core Skill: Valid Triangle
View Challenge →
Construction Triangle Validator
The Construction Triangle Validator receives a value and must make the correct decision. Use C conditions so it can determine whether three sides form a valid triangle.
🎯 Your Task
Determine whether three sides form a valid triangle.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
3 4 5
Valid Triangle
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if(a + b > c &&
b + c > a &&
a + c > b)
printf("Valid Triangle");
else
printf("Invalid Triangle");
return 0;
}
CHALLENGE 19Easy+Triangle Signboard Classifier
Core Skill: Type of Triangle
View Challenge →
Triangle Signboard Classifier
The Triangle Signboard Classifier receives a value and must make the correct decision. Use C conditions so it can determine whether a triangle is Equilateral, Isosceles or Scalene.
🎯 Your Task
Determine whether a triangle is equilateral, isosceles or scalene.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
5 5 3
Isosceles Triangle
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if(a + b <= c ||
b + c <= a ||
a + c <= b)
printf("Invalid Triangle");
else if(a == b && b == c)
printf("Equilateral Triangle");
else if(a == b || b == c || a == c)
printf("Isosceles Triangle");
else
printf("Scalene Triangle");
return 0;
}
CHALLENGE 20Easy+Service Counter Calculator
Core Skill: Simple Calculator Using switch
View Challenge →
Service Counter Calculator
The Service Counter Calculator receives a value and must make the correct decision. Use C conditions so it can perform addition, subtraction, multiplication and division using switch .
🎯 Your Task
Perform addition, subtraction, multiplication and division using switch .
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values within ordinary C integer ranges; marks/percentages use their natural limits.
20 * 5
100.00
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
float a, b;
char op;
scanf("%f %c %f", &a, &op, &b);
switch(op)
{
case '+':
printf("%.2f", a + b);
break;
case '-':
printf("%.2f", a - b);
break;
case '*':
printf("%.2f", a * b);
break;
case '/':
if(b != 0)
printf("%.2f", a / b);
else
printf("Division by zero is not allowed");
break;
default:
printf("Invalid operator");
}
return 0;
}
Level 3 — Loops & Number LogicIteration, digit logic, prime numbers, Fibonacci and factorial. • 20 original CodeBhavya challengesOpen 20 Challenges
Every challenge keeps the original C-learning objective from this level, while the story, framing and presentation are newly written for CodeBhavya.
CHALLENGE 01BasicMorning Roll-Call Counter
Core Skill: Print Numbers from 1 to N
View Challenge →
Morning Roll-Call Counter
The Morning Roll-Call Counter processes repeated numeric steps. Use loop-driven C logic to produce all numbers from 1 to N .
🎯 Your Task
Produce all numbers from 1 to n .
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
5
1 2 3 4 5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
printf("%d ", i);
}
return 0;
}
CHALLENGE 02BasicClosing Countdown Board
Core Skill: Print Numbers from N to 1
View Challenge →
Closing Countdown Board
The Closing Countdown Board processes repeated numeric steps. Use loop-driven C logic to produce numbers from N to 1 .
🎯 Your Task
Produce numbers from n to 1 .
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
5
5 4 3 2 1
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = n; i >= 1; i--)
{
printf("%d ", i);
}
return 0;
}
CHALLENGE 03BasicEven Seat Number Display
Core Skill: Print Even Numbers from 1 to N
View Challenge →
Even Seat Number Display
The Even Seat Number Display processes repeated numeric steps. Use loop-driven C logic to produce all even numbers between 1 and N.
🎯 Your Task
Produce all even numbers between 1 and n.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
10
2 4 6 8 10
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
if(i % 2 == 0)
{
printf("%d ", i);
}
}
return 0;
}
CHALLENGE 04BasicOdd Locker Number Display
Core Skill: Print Odd Numbers from 1 to N
View Challenge →
Odd Locker Number Display
The Odd Locker Number Display processes repeated numeric steps. Use loop-driven C logic to produce all odd numbers between 1 and N.
🎯 Your Task
Produce all odd numbers between 1 and n.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
10
1 3 5 7 9
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
if(i % 2 != 0)
{
printf("%d ", i);
}
}
return 0;
}
CHALLENGE 05EasyDonation Total Tracker
Core Skill: Sum of Numbers from 1 to N
View Challenge →
Donation Total Tracker
The Donation Total Tracker processes repeated numeric steps. Use loop-driven C logic to determine the sum of all numbers from 1 to N.
🎯 Your Task
Determine the sum of all numbers from 1 to n.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
5
15
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, sum = 0;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
sum = sum + i;
}
printf("%d", sum);
return 0;
}
CHALLENGE 06EasyEven Coupon Total
Core Skill: Sum of Even Numbers from 1 to N
View Challenge →
Even Coupon Total
The Even Coupon Total processes repeated numeric steps. Use loop-driven C logic to determine the sum of all even numbers between 1 and N.
🎯 Your Task
Determine the sum of all even numbers between 1 and n.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
10
30
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, sum = 0;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
if(i % 2 == 0)
{
sum += i;
}
}
printf("%d", sum);
return 0;
}
CHALLENGE 07EasyOdd Ticket Total
Core Skill: Sum of Odd Numbers from 1 to N
View Challenge →
Odd Ticket Total
The Odd Ticket Total processes repeated numeric steps. Use loop-driven C logic to determine the sum of all odd numbers between 1 and N.
🎯 Your Task
Determine the sum of all odd numbers between 1 and n.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
10
25
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, sum = 0;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
if(i % 2 != 0)
{
sum += i;
}
}
printf("%d", sum);
return 0;
}
CHALLENGE 08BasicMultiplication Practice Wall
Core Skill: Multiplication Table
View Challenge →
Multiplication Practice Wall
The Multiplication Practice Wall processes repeated numeric steps. Use loop-driven C logic to produce the multiplication table of a given number up to 10.
🎯 Your Task
Produce the multiplication table of a given number up to 10.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
5
5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25 5 x 6 = 30 5 x 7 = 35 5 x 8 = 40 5 x 9 = 45 5 x 10 = 50
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= 10; i++)
{
printf("%d x %d = %d\n",
n, i, n * i);
}
return 0;
}
CHALLENGE 09EasyLibrary Code Digit Counter
Core Skill: Count Digits of a Number
View Challenge →
Library Code Digit Counter
The Library Code Digit Counter processes repeated numeric steps. Use loop-driven C logic to count the number of digits in an integer.
🎯 Your Task
Count the number of digits in an integer.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
12345
5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, count = 0;
scanf("%d", &n);
if(n == 0)
{
count = 1;
}
else
{
while(n != 0)
{
n = n / 10;
count++;
}
}
printf("%d", count);
return 0;
}
CHALLENGE 10EasyDigital Wallet Digit Sum
Core Skill: Sum of Digits
View Challenge →
Digital Wallet Digit Sum
The Digital Wallet Digit Sum processes repeated numeric steps. Use loop-driven C logic to determine the sum of all digits of a number.
🎯 Your Task
Determine the sum of all digits of a number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
12345
15
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, sum = 0;
scanf("%d", &n);
while(n != 0)
{
sum += n % 10;
n /= 10;
}
printf("%d", sum);
return 0;
}
CHALLENGE 11Easy+Badge Number Reversal Desk
Core Skill: Reverse a Number
View Challenge →
Badge Number Reversal Desk
The Badge Number Reversal Desk processes repeated numeric steps. Use loop-driven C logic to reverse the digits of a given number.
🎯 Your Task
Reverse the digits of a given number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
12345
54321
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, reverse = 0;
scanf("%d", &n);
while(n != 0)
{
reverse = reverse * 10 + n % 10;
n /= 10;
}
printf("%d", reverse);
return 0;
}
CHALLENGE 12Easy+Mirror Badge Validator
Core Skill: Palindrome Number
View Challenge →
Mirror Badge Validator
The Mirror Badge Validator processes repeated numeric steps. Use loop-driven C logic to determine whether a number is a palindrome.
🎯 Your Task
Determine whether a number is a palindrome.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
121
Palindrome
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, original, reverse = 0;
scanf("%d", &n);
original = n;
while(n != 0)
{
reverse = reverse * 10 + n % 10;
n /= 10;
}
if(original == reverse)
printf("Palindrome");
else
printf("Not Palindrome");
return 0;
}
CHALLENGE 13EasySecure Code Digit Product
Core Skill: Product of Digits
View Challenge →
Secure Code Digit Product
The Secure Code Digit Product processes repeated numeric steps. Use loop-driven C logic to determine the product of all digits of a number.
🎯 Your Task
Determine the product of all digits of a number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
1234
24
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, product = 1;
scanf("%d", &n);
while(n != 0)
{
product *= n % 10;
n /= 10;
}
printf("%d", product);
return 0;
}
CHALLENGE 14EasyGate Pass Edge Digits
Core Skill: First and Last Digit
View Challenge →
Gate Pass Edge Digits
The Gate Pass Edge Digits processes repeated numeric steps. Use loop-driven C logic to determine the first and last digit of a number.
🎯 Your Task
Determine the first and last digit of a number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
12345
First = 1 Last = 5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, first, last;
scanf("%d", &n);
last = n % 10;
while(n >= 10)
{
n /= 10;
}
first = n;
printf("First = %d\n", first);
printf("Last = %d", last);
return 0;
}
CHALLENGE 15Easy+Device Code Parity Counter
Core Skill: Count Even and Odd Digits
View Challenge →
Device Code Parity Counter
The Device Code Parity Counter processes repeated numeric steps. Use loop-driven C logic to count the number of even and odd digits in a given number.
🎯 Your Task
Count the number of even and odd digits in a given number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
123456
Even Digits = 3 Odd Digits = 3
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, digit;
int even = 0, odd = 0;
scanf("%d", &n);
while(n != 0)
{
digit = n % 10;
if(digit % 2 == 0)
even++;
else
odd++;
n /= 10;
}
printf("Even Digits = %d\n", even);
printf("Odd Digits = %d", odd);
return 0;
}
CHALLENGE 16ModerateMuseum Cube-Code Check
Core Skill: Armstrong Number
View Challenge →
Museum Cube-Code Check
The Museum Cube-Code Check processes repeated numeric steps. Use loop-driven C logic to determine whether a three-digit number is an Armstrong number.
🎯 Your Task
Determine whether a three-digit number is an armstrong number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
153
Armstrong Number
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, original, digit;
int sum = 0;
scanf("%d", &n);
original = n;
while(n != 0)
{
digit = n % 10;
sum += digit * digit * digit;
n /= 10;
}
if(sum == original)
printf("Armstrong Number");
else
printf("Not Armstrong Number");
return 0;
}
CHALLENGE 17ModeratePrime Access Code
Core Skill: Prime Number
View Challenge →
Prime Access Code
The Prime Access Code processes repeated numeric steps. Use loop-driven C logic to determine whether a given number is prime.
🎯 Your Task
Determine whether a given number is prime.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
29
Prime Number
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, count = 0;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
if(n % i == 0)
{
count++;
}
}
if(count == 2)
printf("Prime Number");
else
printf("Not Prime Number");
return 0;
}
CHALLENGE 18IntermediatePrime Range Scanner
Core Skill: Prime Numbers in a Range
View Challenge →
Prime Range Scanner
The Prime Range Scanner processes repeated numeric steps. Use loop-driven C logic to produce all prime numbers between two given numbers.
🎯 Your Task
Produce all prime numbers between two given numbers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
10 30
11 13 17 19 23 29
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int start, end;
scanf("%d %d", &start, &end);
for(int n = start; n <= end; n++)
{
int count = 0;
if(n > 1)
{
for(int i = 1; i <= n; i++)
{
if(n % i == 0)
{
count++;
}
}
if(count == 2)
{
printf("%d ", n);
}
}
}
return 0;
}
CHALLENGE 19ModerateRobotics Sequence Generator
Core Skill: Fibonacci Series
View Challenge →
Robotics Sequence Generator
The Robotics Sequence Generator processes repeated numeric steps. Use loop-driven C logic to produce the first N terms of the Fibonacci series.
🎯 Your Task
Produce the first n terms of the fibonacci series.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
8
0 1 1 2 3 5 8 13
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
int a = 0, b = 1, next;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
printf("%d ", a);
next = a + b;
a = b;
b = next;
}
return 0;
}
CHALLENGE 20Easy+Workshop Arrangement Counter
Core Skill: Factorial of a Number
View Challenge →
Workshop Arrangement Counter
The Workshop Arrangement Counter processes repeated numeric steps. Use loop-driven C logic to determine the factorial of a given number.
🎯 Your Task
Determine the factorial of a given number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use positive inputs small enough for the requested loop/number operation.
5
120
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
long long factorial = 1;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
factorial *= i;
}
printf("%lld", factorial);
return 0;
}
Level 4 — Pattern StudioNested loops through visual star, number and alphabet patterns. • 20 original CodeBhavya challengesOpen 20 Challenges
Every challenge keeps the original C-learning objective from this level, while the story, framing and presentation are newly written for CodeBhavya.
CHALLENGE 01EasySquare Stage Light Wall
Core Skill: Square Star Pattern
View Challenge →
Square Stage Light Wall
The Square Stage Light Wall controls a row-by-row TechFest display. Use nested loops to produce a square pattern of stars with N rows and N columns.
🎯 Your Task
Produce a square pattern of stars with n rows and n columns.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
4
* * * * * * * * * * * * * * * *
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
{
printf("* ");
}
printf("\n");
}
return 0;
}
CHALLENGE 02EasyRectangular Welcome Banner
Core Skill: Rectangle Star Pattern
View Challenge →
Rectangular Welcome Banner
The Rectangular Welcome Banner controls a row-by-row TechFest display. Use nested loops to produce a rectangle with R rows and C columns.
🎯 Your Task
Produce a rectangle with r rows and c columns.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
3 5
* * * * * * * * * * * * * * *
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int rows, cols;
scanf("%d %d", &rows, &cols);
for(int i = 1; i <= rows; i++)
{
for(int j = 1; j <= cols; j++)
{
printf("* ");
}
printf("\n");
}
return 0;
}
CHALLENGE 03EasyRight-Wing Light Ramp
Core Skill: Right Triangle Star Pattern
View Challenge →
Right-Wing Light Ramp
The Right-Wing Light Ramp controls a row-by-row TechFest display. Use nested loops to produce a right triangle using stars.
🎯 Your Task
Produce a right triangle using stars.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
5
* * * * * * * * * * * * * * *
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= i; j++)
{
printf("* ");
}
printf("\n");
}
return 0;
}
CHALLENGE 04EasyClosing Light Ramp
Core Skill: Inverted Right Triangle
View Challenge →
Closing Light Ramp
The Closing Light Ramp controls a row-by-row TechFest display. Use nested loops to produce an inverted right triangle using stars.
🎯 Your Task
Produce an inverted right triangle using stars.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
5
* * * * * * * * * * * * * * *
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = n; i >= 1; i--)
{
for(int j = 1; j <= i; j++)
{
printf("* ");
}
printf("\n");
}
return 0;
}
CHALLENGE 05Easy+Left-Wing Light Ramp
Core Skill: Left-Aligned Triangle
View Challenge →
Left-Wing Light Ramp
The Left-Wing Light Ramp controls a row-by-row TechFest display. Use nested loops to produce a left-aligned triangle with spaces and stars.
🎯 Your Task
Produce a left-aligned triangle with spaces and stars.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
4
*
* *
* * *
* * * *C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n - i; j++)
{
printf(" ");
}
for(int j = 1; j <= i; j++)
{
printf("* ");
}
printf("\n");
}
return 0;
}
CHALLENGE 06Easy+Reverse Left Light Ramp
Core Skill: Inverted Left Triangle
View Challenge →
Reverse Left Light Ramp
The Reverse Left Light Ramp controls a row-by-row TechFest display. Use nested loops to produce an inverted left-aligned triangle.
🎯 Your Task
Produce an inverted left-aligned triangle.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
4
* * * *
* * *
* *
*C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = n; i >= 1; i--)
{
for(int j = 1; j <= n - i; j++)
{
printf(" ");
}
for(int j = 1; j <= i; j++)
{
printf("* ");
}
printf("\n");
}
return 0;
}
CHALLENGE 07Easy+Main Stage Pyramid
Core Skill: Pyramid Pattern
View Challenge →
Main Stage Pyramid
The Main Stage Pyramid controls a row-by-row TechFest display. Use nested loops to produce a centered pyramid using stars.
🎯 Your Task
Produce a centered pyramid using stars.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
4
*
* * *
* * * * *
* * * * * * *C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n - i; j++)
{
printf(" ");
}
for(int j = 1; j <= 2 * i - 1; j++)
{
printf("* ");
}
printf("\n");
}
return 0;
}
CHALLENGE 08Easy+Closing Ceremony Pyramid
Core Skill: Inverted Pyramid
View Challenge →
Closing Ceremony Pyramid
The Closing Ceremony Pyramid controls a row-by-row TechFest display. Use nested loops to produce an inverted centered pyramid.
🎯 Your Task
Produce an inverted centered pyramid.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
4
* * * * * * *
* * * * *
* * *
*C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = n; i >= 1; i--)
{
for(int j = 1; j <= n - i; j++)
{
printf(" ");
}
for(int j = 1; j <= 2 * i - 1; j++)
{
printf("* ");
}
printf("\n");
}
return 0;
}
CHALLENGE 09IntermediateDiamond Laser Frame
Core Skill: Diamond Pattern
View Challenge →
Diamond Laser Frame
The Diamond Laser Frame controls a row-by-row TechFest display. Use nested loops to produce a diamond pattern using stars.
🎯 Your Task
Produce a diamond pattern using stars.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
3
*
* * *
* * * * *
* * *
*C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n - i; j++)
printf(" ");
for(int j = 1; j <= 2 * i - 1; j++)
printf("* ");
printf("\n");
}
for(int i = n - 1; i >= 1; i--)
{
for(int j = 1; j <= n - i; j++)
printf(" ");
for(int j = 1; j <= 2 * i - 1; j++)
printf("* ");
printf("\n");
}
return 0;
}
CHALLENGE 10ModerateHollow Sponsor Square
Core Skill: Hollow Square
View Challenge →
Hollow Sponsor Square
The Hollow Sponsor Square controls a row-by-row TechFest display. Use nested loops to produce a hollow square using stars.
🎯 Your Task
Produce a hollow square using stars.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
5
* * * * * * * * * * * * * * * *
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
{
if(i == 1 || i == n || j == 1 || j == n)
printf("* ");
else
printf(" ");
}
printf("\n");
}
return 0;
}
CHALLENGE 11ModerateHollow Entry Banner
Core Skill: Hollow Rectangle
View Challenge →
Hollow Entry Banner
The Hollow Entry Banner controls a row-by-row TechFest display. Use nested loops to produce a hollow rectangle.
🎯 Your Task
Produce a hollow rectangle.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
4 6
* * * * * * * * * * * * * * * *
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int rows, cols;
scanf("%d %d", &rows, &cols);
for(int i = 1; i <= rows; i++)
{
for(int j = 1; j <= cols; j++)
{
if(i == 1 || i == rows ||
j == 1 || j == cols)
printf("* ");
else
printf(" ");
}
printf("\n");
}
return 0;
}
CHALLENGE 12IntermediateHollow Triangle Arch
Core Skill: Hollow Triangle
View Challenge →
Hollow Triangle Arch
The Hollow Triangle Arch controls a row-by-row TechFest display. Use nested loops to produce a hollow right triangle.
🎯 Your Task
Produce a hollow right triangle.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
5
* * * * * * * * * * * *
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= i; j++)
{
if(j == 1 || j == i || i == n)
printf("* ");
else
printf(" ");
}
printf("\n");
}
return 0;
}
CHALLENGE 13Easy+Seat Number Triangle
Core Skill: Number Triangle
View Challenge →
Seat Number Triangle
The Seat Number Triangle controls a row-by-row TechFest display. Use nested loops to produce numbers from 1 to the row number.
🎯 Your Task
Produce numbers from 1 to the row number.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
5
1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= i; j++)
{
printf("%d ", j);
}
printf("\n");
}
return 0;
}
CHALLENGE 14Easy+Reverse Seat Number Triangle
Core Skill: Inverted Number Triangle
View Challenge →
Reverse Seat Number Triangle
The Reverse Seat Number Triangle controls a row-by-row TechFest display. Use nested loops to produce an inverted number triangle.
🎯 Your Task
Produce an inverted number triangle.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
5
1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = n; i >= 1; i--)
{
for(int j = 1; j <= i; j++)
{
printf("%d ", j);
}
printf("\n");
}
return 0;
}
CHALLENGE 15ModerateContinuous Token Triangle
Core Skill: Continuous Number Triangle
View Challenge →
Continuous Token Triangle
The Continuous Token Triangle controls a row-by-row TechFest display. Use nested loops to produce consecutive numbers in triangle form.
🎯 Your Task
Produce consecutive numbers in triangle form.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
4
1 2 3 4 5 6 7 8 9 10
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, num = 1;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= i; j++)
{
printf("%d ", num);
num++;
}
printf("\n");
}
return 0;
}
CHALLENGE 16Easy+Floyd Registration Board
Core Skill: Floyd's Triangle
View Challenge →
Floyd Registration Board
The Floyd Registration Board controls a row-by-row TechFest display. Use nested loops to produce Floyd's triangle.
🎯 Your Task
Produce floyd's triangle.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, num = 1;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= i; j++)
{
printf("%d ", num++);
}
printf("\n");
}
return 0;
}
CHALLENGE 17Easy+Alphabet Spotlight Triangle
Core Skill: Alphabet Triangle
View Challenge →
Alphabet Spotlight Triangle
The Alphabet Spotlight Triangle controls a row-by-row TechFest display. Use nested loops to produce alphabets in triangle form.
🎯 Your Task
Produce alphabets in triangle form.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
4
A A B A B C A B C D
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
for(int j = 0; j < i; j++)
{
printf("%c ", 'A' + j);
}
printf("\n");
}
return 0;
}
CHALLENGE 18Easy+Repeated Row Number Board
Core Skill: Repeated Number Pattern
View Challenge →
Repeated Row Number Board
The Repeated Row Number Board controls a row-by-row TechFest display. Use nested loops to produce the row number repeatedly in each row.
🎯 Your Task
Produce the row number repeatedly in each row.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
5
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= i; j++)
{
printf("%d ", i);
}
printf("\n");
}
return 0;
}
CHALLENGE 19Easy+Binary Light Triangle
Core Skill: -1 Triangle
View Challenge →
Binary Light Triangle
The Binary Light Triangle controls a row-by-row TechFest display. Use nested loops to produce a triangle using alternating 0 and 1.
🎯 Your Task
Produce a triangle using alternating 0 and 1.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
5
1 0 1 1 0 1 0 1 0 1 1 0 1 0 1
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= i; j++)
{
printf("%d ", (i + j + 1) % 2);
}
printf("\n");
}
return 0;
}
CHALLENGE 20Intermediate+Pascal Spotlight Pyramid
Core Skill: Pascal's Triangle
View Challenge →
Pascal Spotlight Pyramid
The Pascal Spotlight Pyramid controls a row-by-row TechFest display. Use nested loops to produce Pascal's triangle for N rows.
🎯 Your Task
Produce pascal's triangle for n rows.
📥 Input Format
Read one positive integer N that controls the number of rows in the pattern.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 20
5
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for(int i = 0; i < n; i++)
{
long long value = 1;
for(int space = 0; space < n - i - 1; space++)
{
printf(" ");
}
for(int j = 0; j <= i; j++)
{
printf("%lld ", value);
value = value * (i - j) / (j + 1);
}
printf("\n");
}
return 0;
}
Level 5 — Array ChallengesTraversal, searching, duplicates, merging and rotations. • 20 original CodeBhavya challengesOpen 20 Challenges
Every challenge keeps the original C-learning objective from this level, while the story, framing and presentation are newly written for CodeBhavya.
CHALLENGE 01EasySensor Reading Console
Core Skill: Read and Print an Array
View Challenge →
Sensor Reading Console
The Sensor Reading Console stores campus readings in an array. Process those values to accept N elements into an array and print them.
🎯 Your Task
Accept n elements into an array and print them.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
5 10 20 30 40 50
10 20 30 40 50
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
for(int i = 0; i < n; i++)
printf("%d ", arr[i]);
return 0;
}
CHALLENGE 02EasySolar Output Total
Core Skill: Sum of Array Elements
View Challenge →
Solar Output Total
The Solar Output Total stores campus readings in an array. Process those values to determine the sum of all elements in an array.
🎯 Your Task
Determine the sum of all elements in an array.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
5 10 20 30 40 50
150
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, sum = 0;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
{
scanf("%d", &arr[i]);
sum += arr[i];
}
printf("%d", sum);
return 0;
}
CHALLENGE 03Easy+Average Lab Temperature
Core Skill: Average of Array Elements
View Challenge →
Average Lab Temperature
The Average Lab Temperature stores campus readings in an array. Process those values to determine the average of all elements in an array.
🎯 Your Task
Determine the average of all elements in an array.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
4 10 20 30 40
25.00
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, sum = 0;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
{
scanf("%d", &arr[i]);
sum += arr[i];
}
printf("%.2f", (float)sum / n);
return 0;
}
CHALLENGE 04Easy+Coding Contest Peak Score
Core Skill: Find Maximum Element
View Challenge →
Coding Contest Peak Score
The Coding Contest Peak Score stores campus readings in an array. Process those values to determine the largest element in an array.
🎯 Your Task
Determine the largest element in an array.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
5 10 45 23 67 12
67
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
int max = arr[0];
for(int i = 1; i < n; i++)
{
if(arr[i] > max)
max = arr[i];
}
printf("%d", max);
return 0;
}
CHALLENGE 05Easy+Canteen Stock Minimum
Core Skill: Find Minimum Element
View Challenge →
Canteen Stock Minimum
The Canteen Stock Minimum stores campus readings in an array. Process those values to determine the smallest element in an array.
🎯 Your Task
Determine the smallest element in an array.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
5 10 45 23 67 12
10
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
int min = arr[0];
for(int i = 1; i < n; i++)
{
if(arr[i] < min)
min = arr[i];
}
printf("%d", min);
return 0;
}
CHALLENGE 06Easy+Even Device Counter
Core Skill: Count Even Elements
View Challenge →
Even Device Counter
The Even Device Counter stores campus readings in an array. Process those values to count how many even numbers are present in an array.
🎯 Your Task
Count how many even numbers are present in an array.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
6 1 2 4 7 8 9
3
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, count = 0;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
for(int i = 0; i < n; i++)
{
if(arr[i] % 2 == 0)
count++;
}
printf("%d", count);
return 0;
}
CHALLENGE 07Easy+Odd Device Counter
Core Skill: Count Odd Elements
View Challenge →
Odd Device Counter
The Odd Device Counter stores campus readings in an array. Process those values to count how many odd numbers are present in an array.
🎯 Your Task
Count how many odd numbers are present in an array.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
6 1 2 4 7 8 9
3
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, count = 0;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
for(int i = 0; i < n; i++)
{
if(arr[i] % 2 != 0)
count++;
}
printf("%d", count);
return 0;
}
CHALLENGE 08Easy+Power Reading Sign Counter
Core Skill: Count Positive and Negative Elements
View Challenge →
Power Reading Sign Counter
The Power Reading Sign Counter stores campus readings in an array. Process those values to count positive, negative and zero elements.
🎯 Your Task
Count positive, negative and zero elements.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
6 10 -5 0 8 -2 7
Positive = 3 Negative = 2 Zero = 1
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
int positive = 0, negative = 0, zero = 0;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
for(int i = 0; i < n; i++)
{
if(arr[i] > 0)
positive++;
else if(arr[i] < 0)
negative++;
else
zero++;
}
printf("Positive = %d\n", positive);
printf("Negative = %d\n", negative);
printf("Zero = %d", zero);
return 0;
}
CHALLENGE 09ModerateShuttle Log Reversal
Core Skill: Reverse an Array
View Challenge →
Shuttle Log Reversal
The Shuttle Log Reversal stores campus readings in an array. Process those values to produce the elements of an array in reverse order.
🎯 Your Task
Produce the elements of an array in reverse order.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
5 10 20 30 40 50
50 40 30 20 10
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
for(int i = n - 1; i >= 0; i--)
printf("%d ", arr[i]);
return 0;
}
CHALLENGE 10Easy+Backup Reading Copier
Core Skill: Copy One Array into Another
View Challenge →
Backup Reading Copier
The Backup Reading Copier stores campus readings in an array. Process those values to copy all elements from one array into another.
🎯 Your Task
Copy all elements from one array into another.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
4 10 20 30 40
10 20 30 40
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int a[n], b[n];
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
for(int i = 0; i < n; i++)
b[i] = a[i];
for(int i = 0; i < n; i++)
printf("%d ", b[i]);
return 0;
}
CHALLENGE 11ModerateLibrary Shelf Search
Core Skill: Linear Search
View Challenge →
Library Shelf Search
The Library Shelf Search stores campus readings in an array. Process those values to search for an element in an array using linear search.
🎯 Your Task
Search for an element in an array using linear search.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
5 10 20 30 40 50 30
Element found at index 2
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, target, found = -1;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
scanf("%d", &target);
for(int i = 0; i < n; i++)
{
if(arr[i] == target)
{
found = i;
break;
}
}
if(found != -1)
printf("Element found at index %d", found);
else
printf("Element not found");
return 0;
}
CHALLENGE 12IntermediateRunner-Up Contest Score
Core Skill: Second Largest Element
View Challenge →
Runner-Up Contest Score
The Runner-Up Contest Score stores campus readings in an array. Process those values to determine the second largest distinct element.
🎯 Your Task
Determine the second largest distinct element.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
5 10 50 20 40 30
40
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <limits.h>
int main()
{
int n;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
int largest = INT_MIN;
int second = INT_MIN;
for(int i = 0; i < n; i++)
{
if(arr[i] > largest)
{
second = largest;
largest = arr[i];
}
else if(arr[i] > second && arr[i] != largest)
{
second = arr[i];
}
}
if(second == INT_MIN)
printf("No second largest");
else
printf("%d", second);
return 0;
}
CHALLENGE 13IntermediateSecond-Lowest Energy Reading
Core Skill: Second Smallest Element
View Challenge →
Second-Lowest Energy Reading
The Second-Lowest Energy Reading stores campus readings in an array. Process those values to determine the second smallest distinct element.
🎯 Your Task
Determine the second smallest distinct element.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
5 10 50 20 40 30
20
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <limits.h>
int main()
{
int n;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
int smallest = INT_MAX;
int second = INT_MAX;
for(int i = 0; i < n; i++)
{
if(arr[i] < smallest)
{
second = smallest;
smallest = arr[i];
}
else if(arr[i] < second && arr[i] != smallest)
{
second = arr[i];
}
}
if(second == INT_MAX)
printf("No second smallest");
else
printf("%d", second);
return 0;
}
CHALLENGE 14Intermediate+Duplicate Entry Cleaner
Core Skill: Remove Duplicate Elements
View Challenge →
Duplicate Entry Cleaner
The Duplicate Entry Cleaner stores campus readings in an array. Process those values to remove duplicate values from an array and print only distinct elements.
🎯 Your Task
Remove duplicate values from an array and print only distinct elements.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
7 10 20 10 30 20 40 10
10 20 30 40
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
for(int i = 0; i < n; i++)
{
int duplicate = 0;
for(int j = 0; j < i; j++)
{
if(arr[i] == arr[j])
{
duplicate = 1;
break;
}
}
if(!duplicate)
printf("%d ", arr[i]);
}
return 0;
}
CHALLENGE 15Intermediate+Sensor Frequency Report
Core Skill: Frequency of Each Element
View Challenge →
Sensor Frequency Report
The Sensor Frequency Report stores campus readings in an array. Process those values to count the frequency of every distinct element.
🎯 Your Task
Count the frequency of every distinct element.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
6 10 20 10 30 20 10
10 = 3 20 = 2 30 = 1
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
for(int i = 0; i < n; i++)
{
int already = 0;
for(int j = 0; j < i; j++)
{
if(arr[i] == arr[j])
{
already = 1;
break;
}
}
if(already)
continue;
int count = 0;
for(int j = 0; j < n; j++)
{
if(arr[i] == arr[j])
count++;
}
printf("%d = %d\n", arr[i], count);
}
return 0;
}
CHALLENGE 16Intermediate+Missing Locker Token
Core Skill: Find Missing Number
View Challenge →
Missing Locker Token
The Missing Locker Token stores campus readings in an array. Process those values to an array contains numbers from 1 to N with one number missing. Find the missing number.
🎯 Your Task
An array contains numbers from 1 to n with one number missing. find the missing number.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
5 1 2 4 5
3
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, sum = 0;
scanf("%d", &n);
for(int i = 1; i < n; i++)
{
int x;
scanf("%d", &x);
sum += x;
}
int expected = n * (n + 1) / 2;
printf("%d", expected - sum);
return 0;
}
CHALLENGE 17ModerateTwo-Block Reading Merge
Core Skill: Merge Two Arrays
View Challenge →
Two-Block Reading Merge
The Two-Block Reading Merge stores campus readings in an array. Process those values to merge two arrays into a single array.
🎯 Your Task
Merge two arrays into a single array.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
3 1 2 3 2 4 5
1 2 3 4 5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, m;
scanf("%d", &n);
int a[n];
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
scanf("%d", &m);
int b[m];
for(int i = 0; i < m; i++)
scanf("%d", &b[i]);
for(int i = 0; i < n; i++)
printf("%d ", a[i]);
for(int i = 0; i < m; i++)
printf("%d ", b[i]);
return 0;
}
CHALLENGE 18Intermediate+Sorted Attendance Merge
Core Skill: Merge Two Sorted Arrays
View Challenge →
Sorted Attendance Merge
The Sorted Attendance Merge stores campus readings in an array. Process those values to merge two sorted arrays into one sorted array.
🎯 Your Task
Merge two sorted arrays into one sorted array.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
3 1 3 5 3 2 4 6
1 2 3 4 5 6
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, m;
scanf("%d", &n);
int a[n];
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
scanf("%d", &m);
int b[m];
for(int i = 0; i < m; i++)
scanf("%d", &b[i]);
int i = 0, j = 0;
while(i < n && j < m)
{
if(a[i] <= b[j])
printf("%d ", a[i++]);
else
printf("%d ", b[j++]);
}
while(i < n)
printf("%d ", a[i++]);
while(j < m)
printf("%d ", b[j++]);
return 0;
}
CHALLENGE 19IntermediateLeft Shift Shuttle Schedule
Core Skill: Left Rotate an Array
View Challenge →
Left Shift Shuttle Schedule
The Left Shift Shuttle Schedule stores campus readings in an array. Process those values to rotate an array to the left by one position.
🎯 Your Task
Rotate an array to the left by one position.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
5 1 2 3 4 5
2 3 4 5 1
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
int first = arr[0];
for(int i = 0; i < n - 1; i++)
arr[i] = arr[i + 1];
arr[n - 1] = first;
for(int i = 0; i < n; i++)
printf("%d ", arr[i]);
return 0;
}
CHALLENGE 20IntermediateRight Shift Shuttle Schedule
Core Skill: Right Rotate an Array
View Challenge →
Right Shift Shuttle Schedule
The Right Shift Shuttle Schedule stores campus readings in an array. Process those values to rotate an array to the right by one position.
🎯 Your Task
Rotate an array to the right by one position.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100; array values fit in a 32-bit signed integer.
5 1 2 3 4 5
5 1 2 3 4
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
int last = arr[n - 1];
for(int i = n - 1; i > 0; i--)
arr[i] = arr[i - 1];
arr[0] = last;
for(int i = 0; i < n; i++)
printf("%d ", arr[i]);
return 0;
}
Level 6 — String ChallengesCharacter processing, transformations, searching and text analysis. • 20 original CodeBhavya challengesOpen 20 Challenges
Every challenge keeps the original C-learning objective from this level, while the story, framing and presentation are newly written for CodeBhavya.
CHALLENGE 01EasyMessage Display Terminal
Core Skill: Read and Print a String
View Challenge →
Message Display Terminal
The Message Display Terminal receives text from a campus service. Process the characters to accept a string and print it.
🎯 Your Task
Accept a string and print it.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
Hello
Hello
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
scanf("%99s", str);
printf("%s", str);
return 0;
}
CHALLENGE 02Easy+Notice Length Meter
Core Skill: Find String Length
View Challenge →
Notice Length Meter
The Notice Length Meter receives text from a campus service. Process the characters to determine the length of a string without using strlen() .
🎯 Your Task
Determine the length of a string without using strlen() .
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
Hello
5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
int length = 0;
scanf("%99s", str);
while(str[length] != '\0')
{
length++;
}
printf("%d", length);
return 0;
}
CHALLENGE 03Easy+Badge Text Character Counter
Core Skill: Count Characters
View Challenge →
Badge Text Character Counter
The Badge Text Character Counter receives text from a campus service. Process the characters to count the number of characters in a string without using strlen() .
🎯 Your Task
Count the number of characters in a string without using strlen() .
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
Programming
11
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
int count = 0;
scanf("%99s", str);
for(int i = 0; str[i] != '\0'; i++)
{
count++;
}
printf("%d", count);
return 0;
}
CHALLENGE 04Easy+Announcement Vowel Meter
Core Skill: Count Vowels
View Challenge →
Announcement Vowel Meter
The Announcement Vowel Meter receives text from a campus service. Process the characters to count the vowels in a string.
🎯 Your Task
Count the vowels in a string.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
education
5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
int count = 0;
scanf("%99s", str);
for(int i = 0; str[i] != '\0'; i++)
{
if(str[i] == 'a' || str[i] == 'e' ||
str[i] == 'i' || str[i] == 'o' ||
str[i] == 'u')
{
count++;
}
}
printf("%d", count);
return 0;
}
CHALLENGE 05Easy+Announcement Consonant Meter
Core Skill: Count Consonants
View Challenge →
Announcement Consonant Meter
The Announcement Consonant Meter receives text from a campus service. Process the characters to count consonants in a string containing alphabets.
🎯 Your Task
Count consonants in a string containing alphabets.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
hello
3
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
int count = 0;
scanf("%99s", str);
for(int i = 0; str[i] != '\0'; i++)
{
char ch = str[i];
if((ch >= 'a' && ch <= 'z') ||
(ch >= 'A' && ch <= 'Z'))
{
if(!(ch == 'a' || ch == 'e' ||
ch == 'i' || ch == 'o' ||
ch == 'u' || ch == 'A' ||
ch == 'E' || ch == 'I' ||
ch == 'O' || ch == 'U'))
{
count++;
}
}
}
printf("%d", count);
return 0;
}
CHALLENGE 06Easy+Secure Message Digit Counter
Core Skill: Count Digits in a String
View Challenge →
Secure Message Digit Counter
The Secure Message Digit Counter receives text from a campus service. Process the characters to count how many numeric digits are present in a string.
🎯 Your Task
Count how many numeric digits are present in a string.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
abc123xyz45
5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
int count = 0;
scanf("%99s", str);
for(int i = 0; str[i] != '\0'; i++)
{
if(str[i] >= '0' && str[i] <= '9')
count++;
}
printf("%d", count);
return 0;
}
CHALLENGE 07EasySentence Space Counter
Core Skill: Count Spaces
View Challenge →
Sentence Space Counter
The Sentence Space Counter receives text from a campus service. Process the characters to count the spaces in a sentence.
🎯 Your Task
Count the spaces in a sentence.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
C programming is easy
3
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[200];
int count = 0;
fgets(str, sizeof(str), stdin);
for(int i = 0; str[i] != '\0'; i++)
{
if(str[i] == ' ')
count++;
}
printf("%d", count);
return 0;
}
CHALLENGE 08Easy+Lowercase Notice Upgrader
Core Skill: Convert Lowercase to Uppercase
View Challenge →
Lowercase Notice Upgrader
The Lowercase Notice Upgrader receives text from a campus service. Process the characters to convert all lowercase letters to uppercase without using strupr() .
🎯 Your Task
Convert all lowercase letters to uppercase without using strupr() .
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
hello
HELLO
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
scanf("%99s", str);
for(int i = 0; str[i] != '\0'; i++)
{
if(str[i] >= 'a' && str[i] <= 'z')
str[i] = str[i] - 'a' + 'A';
}
printf("%s", str);
return 0;
}
CHALLENGE 09Easy+Uppercase Notice Normalizer
Core Skill: Convert Uppercase to Lowercase
View Challenge →
Uppercase Notice Normalizer
The Uppercase Notice Normalizer receives text from a campus service. Process the characters to convert uppercase letters to lowercase.
🎯 Your Task
Convert uppercase letters to lowercase.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
HELLO
hello
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
scanf("%99s", str);
for(int i = 0; str[i] != '\0'; i++)
{
if(str[i] >= 'A' && str[i] <= 'Z')
str[i] = str[i] - 'A' + 'a';
}
printf("%s", str);
return 0;
}
CHALLENGE 10ModerateMirror Message Tool
Core Skill: Reverse a String
View Challenge →
Mirror Message Tool
The Mirror Message Tool receives text from a campus service. Process the characters to reverse a string without using strrev() .
🎯 Your Task
Reverse a string without using strrev() .
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
hello
olleh
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
int length = 0;
scanf("%99s", str);
while(str[length] != '\0')
length++;
for(int i = length - 1; i >= 0; i--)
printf("%c", str[i]);
return 0;
}
CHALLENGE 11ModeratePalindrome Badge Check
Core Skill: Palindrome String
View Challenge →
Palindrome Badge Check
The Palindrome Badge Check receives text from a campus service. Process the characters to determine whether a string is a palindrome.
🎯 Your Task
Determine whether a string is a palindrome.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
madam
Palindrome
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
int length = 0;
int palindrome = 1;
scanf("%99s", str);
while(str[length] != '\0')
length++;
for(int i = 0; i < length / 2; i++)
{
if(str[i] != str[length - i - 1])
{
palindrome = 0;
break;
}
}
if(palindrome)
printf("Palindrome");
else
printf("Not Palindrome");
return 0;
}
CHALLENGE 12Easy+Message Backup Copier
Core Skill: Copy a String
View Challenge →
Message Backup Copier
The Message Backup Copier receives text from a campus service. Process the characters to copy one string into another without using strcpy() .
🎯 Your Task
Copy one string into another without using strcpy() .
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
Hello
Hello
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char source[100], destination[100];
int i = 0;
scanf("%99s", source);
while(source[i] != '\0')
{
destination[i] = source[i];
i++;
}
destination[i] = '\0';
printf("%s", destination);
return 0;
}
CHALLENGE 13ModerateTwo-Notice Comparator
Core Skill: Compare Two Strings
View Challenge →
Two-Notice Comparator
The Two-Notice Comparator receives text from a campus service. Process the characters to compare two strings without using strcmp() .
🎯 Your Task
Compare two strings without using strcmp() .
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
hello hello
Equal
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char a[100], b[100];
int i = 0, equal = 1;
scanf("%99s", a);
scanf("%99s", b);
while(a[i] != '\0' || b[i] != '\0')
{
if(a[i] != b[i])
{
equal = 0;
break;
}
i++;
}
if(equal)
printf("Equal");
else
printf("Not Equal");
return 0;
}
CHALLENGE 14ModerateNotice Merger
Core Skill: Concatenate Two Strings
View Challenge →
Notice Merger
The Notice Merger receives text from a campus service. Process the characters to concatenate two strings without using strcat() .
🎯 Your Task
Concatenate two strings without using strcat() .
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
Hello World
HelloWorld
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char a[200], b[100];
int i = 0, j = 0;
scanf("%99s", a);
scanf("%99s", b);
while(a[i] != '\0')
i++;
while(b[j] != '\0')
{
a[i] = b[j];
i++;
j++;
}
a[i] = '\0';
printf("%s", a);
return 0;
}
CHALLENGE 15ModerateTarget Letter Frequency Desk
Core Skill: Frequency of a Character
View Challenge →
Target Letter Frequency Desk
The Target Letter Frequency Desk receives text from a campus service. Process the characters to count how many times a character occurs in a string.
🎯 Your Task
Count how many times a character occurs in a string.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
programming g
2
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100], ch;
int count = 0;
scanf("%99s", str);
scanf(" %c", &ch);
for(int i = 0; str[i] != '\0'; i++)
{
if(str[i] == ch)
count++;
}
printf("%d", count);
return 0;
}
CHALLENGE 16ModerateCompact Message Cleaner
Core Skill: Remove Spaces
View Challenge →
Compact Message Cleaner
The Compact Message Cleaner receives text from a campus service. Process the characters to remove all spaces from a sentence.
🎯 Your Task
Remove all spaces from a sentence.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
C programming is easy
Cprogrammingiseasy
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[200];
fgets(str, sizeof(str), stdin);
for(int i = 0; str[i] != '\0'; i++)
{
if(str[i] != ' ')
printf("%c", str[i]);
}
return 0;
}
CHALLENGE 17Intermediate+Duplicate Character Cleaner
Core Skill: Remove Duplicate Characters
View Challenge →
Duplicate Character Cleaner
The Duplicate Character Cleaner receives text from a campus service. Process the characters to remove duplicate characters from a string.
🎯 Your Task
Remove duplicate characters from a string.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
programming
progamin
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
scanf("%99s", str);
for(int i = 0; str[i] != '\0'; i++)
{
int duplicate = 0;
for(int j = 0; j < i; j++)
{
if(str[i] == str[j])
{
duplicate = 1;
break;
}
}
if(!duplicate)
printf("%c", str[i]);
}
return 0;
}
CHALLENGE 18Intermediate+First Unique Symbol Finder
Core Skill: First Non-Repeating Character
View Challenge →
First Unique Symbol Finder
The First Unique Symbol Finder receives text from a campus service. Process the characters to determine the first character that occurs only once.
🎯 Your Task
Determine the first character that occurs only once.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
aabbcdde
c
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
scanf("%99s", str);
for(int i = 0; str[i] != '\0'; i++)
{
int count = 0;
for(int j = 0; str[j] != '\0'; j++)
{
if(str[i] == str[j])
count++;
}
if(count == 1)
{
printf("%c", str[i]);
return 0;
}
}
printf("No non-repeating character");
return 0;
}
CHALLENGE 19Intermediate+Team Name Anagram Check
Core Skill: Check Anagram
View Challenge →
Team Name Anagram Check
The Team Name Anagram Check receives text from a campus service. Process the characters to determine whether two strings are anagrams.
🎯 Your Task
Determine whether two strings are anagrams.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
listen silent
Anagram
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char a[100], b[100];
int countA[256] = {0};
int countB[256] = {0};
scanf("%99s", a);
scanf("%99s", b);
for(int i = 0; a[i] != '\0'; i++)
countA[(unsigned char)a[i]]++;
for(int i = 0; b[i] != '\0'; i++)
countB[(unsigned char)b[i]]++;
for(int i = 0; i < 256; i++)
{
if(countA[i] != countB[i])
{
printf("Not Anagram");
return 0;
}
}
printf("Anagram");
return 0;
}
CHALLENGE 20ModerateSentence Word Counter
Core Skill: Count Words in a Sentence
View Challenge →
Sentence Word Counter
The Sentence Word Counter receives text from a campus service. Process the characters to count the number of words in a sentence.
🎯 Your Task
Count the number of words in a sentence.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Input text length ≤ 200 characters unless otherwise stated.
C programming is easy
4
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <ctype.h>
int main()
{
char str[200];
int words = 0;
int inWord = 0;
fgets(str, sizeof(str), stdin);
for(int i = 0; str[i] != '\0'; i++)
{
if(!isspace((unsigned char)str[i]))
{
if(!inWord)
{
words++;
inWord = 1;
}
}
else
{
inWord = 0;
}
}
printf("%d", words);
return 0;
}
Level 7 — Functions & RecursionReusable functions, recursion and structured decomposition. • 20 original CodeBhavya challengesOpen 20 Challenges
Every challenge keeps the original C-learning objective from this level, while the story, framing and presentation are newly written for CodeBhavya.
CHALLENGE 01EasyReusable Addition Service
Core Skill: Add Two Numbers Using Function
View Challenge →
Reusable Addition Service
The Reusable Addition Service is being converted into reusable C components. Use functions or recursion to write a function to add two numbers and return the result.
🎯 Your Task
Write a function to add two numbers and return the result.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
10 20
30
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int add(int a, int b)
{
return a + b;
}
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d", add(a, b));
return 0;
}
CHALLENGE 02EasyReusable Maximum Service
Core Skill: Find Maximum Using Function
View Challenge →
Reusable Maximum Service
The Reusable Maximum Service is being converted into reusable C components. Use functions or recursion to write a function to find the larger of two numbers.
🎯 Your Task
Write a function to find the larger of two numbers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
25 18
25
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int maximum(int a, int b)
{
if(a > b)
return a;
return b;
}
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d", maximum(a, b));
return 0;
}
CHALLENGE 03EasyParity Check Service
Core Skill: Check Even or Odd Using Function
View Challenge →
Parity Check Service
The Parity Check Service is being converted into reusable C components. Use functions or recursion to write a function to check whether a number is even or odd.
🎯 Your Task
Write a function to check whether a number is even or odd.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
24
Even
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int isEven(int n)
{
return n % 2 == 0;
}
int main()
{
int n;
scanf("%d", &n);
if(isEven(n))
printf("Even");
else
printf("Odd");
return 0;
}
CHALLENGE 04Easy+Factorial Service Desk
Core Skill: Find Factorial Using Function
View Challenge →
Factorial Service Desk
The Factorial Service Desk is being converted into reusable C components. Use functions or recursion to write a function to find the factorial of a number.
🎯 Your Task
Write a function to find the factorial of a number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
5
120
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
long long factorial(int n)
{
long long fact = 1;
for(int i = 1; i <= n; i++)
fact *= i;
return fact;
}
int main()
{
int n;
scanf("%d", &n);
printf("%lld", factorial(n));
return 0;
}
CHALLENGE 05ModeratePrime Validation Service
Core Skill: Check Prime Using Function
View Challenge →
Prime Validation Service
The Prime Validation Service is being converted into reusable C components. Use functions or recursion to write a function to check whether a number is prime.
🎯 Your Task
Write a function to check whether a number is prime.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
17
Prime
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int isPrime(int n)
{
if(n < 2)
return 0;
for(int i = 2; i * i <= n; i++)
{
if(n % i == 0)
return 0;
}
return 1;
}
int main()
{
int n;
scanf("%d", &n);
if(isPrime(n))
printf("Prime");
else
printf("Not Prime");
return 0;
}
CHALLENGE 06Easy+Number Reversal Service
Core Skill: Reverse Number Using Function
View Challenge →
Number Reversal Service
The Number Reversal Service is being converted into reusable C components. Use functions or recursion to write a function to reverse a number.
🎯 Your Task
Write a function to reverse a number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
12345
54321
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int reverseNumber(int n)
{
int rev = 0;
while(n != 0)
{
rev = rev * 10 + n % 10;
n /= 10;
}
return rev;
}
int main()
{
int n;
scanf("%d", &n);
printf("%d", reverseNumber(n));
return 0;
}
CHALLENGE 07ModerateFibonacci Service
Core Skill: Fibonacci Using Function
View Challenge →
Fibonacci Service
The Fibonacci Service is being converted into reusable C components. Use functions or recursion to write a function to print the first N Fibonacci numbers.
🎯 Your Task
Write a function to print the first n fibonacci numbers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
7
0 1 1 2 3 5 8
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
void fibonacci(int n)
{
int a = 0, b = 1;
for(int i = 0; i < n; i++)
{
printf("%d", a);
if(i < n - 1)
printf(" ");
int c = a + b;
a = b;
b = c;
}
}
int main()
{
int n;
scanf("%d", &n);
fibonacci(n);
return 0;
}
CHALLENGE 08ModerateCommon-Divisor Service
Core Skill: GCD Using Function
View Challenge →
Common-Divisor Service
The Common-Divisor Service is being converted into reusable C components. Use functions or recursion to determine the greatest common divisor of two numbers.
🎯 Your Task
Determine the greatest common divisor of two numbers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
24 36
12
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int gcd(int a, int b)
{
while(b != 0)
{
int temp = b;
b = a % b;
a = temp;
}
return a;
}
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d", gcd(a, b));
return 0;
}
CHALLENGE 09ModeratePower Calculation Service
Core Skill: Power Using Function
View Challenge →
Power Calculation Service
The Power Calculation Service is being converted into reusable C components. Use functions or recursion to compute a raised to the power b using a function.
🎯 Your Task
Compute a raised to the power b using a function.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
2 5
32
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int power(int a, int b)
{
int result = 1;
for(int i = 1; i <= b; i++)
result *= a;
return result;
}
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d", power(a, b));
return 0;
}
CHALLENGE 10ModerateRecursive Factorial Engine
Core Skill: Factorial Using Recursion
View Challenge →
Recursive Factorial Engine
The Recursive Factorial Engine is being converted into reusable C components. Use functions or recursion to determine the factorial of a number using recursion.
🎯 Your Task
Determine the factorial of a number using recursion.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
5
120
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
long long factorial(int n)
{
if(n <= 1)
return 1;
return n * factorial(n - 1);
}
int main()
{
int n;
scanf("%d", &n);
printf("%lld", factorial(n));
return 0;
}
CHALLENGE 11Intermediate+Recursive Fibonacci Engine
Core Skill: Fibonacci Using Recursion
View Challenge →
Recursive Fibonacci Engine
The Recursive Fibonacci Engine is being converted into reusable C components. Use functions or recursion to determine the Nth Fibonacci number using recursion.
🎯 Your Task
Determine the nth fibonacci number using recursion.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
6
8
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int fibonacci(int n)
{
if(n <= 1)
return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
int main()
{
int n;
scanf("%d", &n);
printf("%d", fibonacci(n));
return 0;
}
CHALLENGE 12Easy+Recursive Natural Sum Engine
Core Skill: Sum of Natural Numbers Using Recursion
View Challenge →
Recursive Natural Sum Engine
The Recursive Natural Sum Engine is being converted into reusable C components. Use functions or recursion to determine the sum of the first N natural numbers using recursion.
🎯 Your Task
Determine the sum of the first n natural numbers using recursion.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
10
55
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int sum(int n)
{
if(n == 0)
return 0;
return n + sum(n - 1);
}
int main()
{
int n;
scanf("%d", &n);
printf("%d", sum(n));
return 0;
}
CHALLENGE 13ModerateRecursive Digit Sum Engine
Core Skill: Sum of Digits Using Recursion
View Challenge →
Recursive Digit Sum Engine
The Recursive Digit Sum Engine is being converted into reusable C components. Use functions or recursion to determine the sum of all digits of a number using recursion.
🎯 Your Task
Determine the sum of all digits of a number using recursion.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
12345
15
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int sumDigits(int n)
{
if(n == 0)
return 0;
return n % 10 + sumDigits(n / 10);
}
int main()
{
int n;
scanf("%d", &n);
printf("%d", sumDigits(n));
return 0;
}
CHALLENGE 14IntermediateRecursive Number Mirror
Core Skill: Reverse a Number Using Recursion
View Challenge →
Recursive Number Mirror
The Recursive Number Mirror is being converted into reusable C components. Use functions or recursion to reverse a number using recursion.
🎯 Your Task
Reverse a number using recursion.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
1234
4321
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int reverseHelper(int n, int rev)
{
if(n == 0)
return rev;
return reverseHelper(n / 10,
rev * 10 + n % 10);
}
int main()
{
int n;
scanf("%d", &n);
printf("%d", reverseHelper(n, 0));
return 0;
}
CHALLENGE 15Intermediate+Recursive Binary Converter
Core Skill: Decimal to Binary Using Recursion
View Challenge →
Recursive Binary Converter
The Recursive Binary Converter is being converted into reusable C components. Use functions or recursion to convert a decimal number to binary using recursion.
🎯 Your Task
Convert a decimal number to binary using recursion.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
10
1010
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
void binary(int n)
{
if(n > 1)
binary(n / 2);
printf("%d", n % 2);
}
int main()
{
int n;
scanf("%d", &n);
binary(n);
return 0;
}
CHALLENGE 16ModerateArray Maximum Service
Core Skill: Find Maximum in Array Using Function
View Challenge →
Array Maximum Service
The Array Maximum Service is being converted into reusable C components. Use functions or recursion to write a function to find the largest element in an array.
🎯 Your Task
Write a function to find the largest element in an array.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
5 10 25 7 40 18
40
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int maximum(int arr[], int n)
{
int max = arr[0];
for(int i = 1; i < n; i++)
{
if(arr[i] > max)
max = arr[i];
}
return max;
}
int main()
{
int n, arr[100];
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
printf("%d", maximum(arr, n));
return 0;
}
CHALLENGE 17ModerateArray Parity Counter Service
Core Skill: Count Even and Odd Using Function
View Challenge →
Array Parity Counter Service
The Array Parity Counter Service is being converted into reusable C components. Use functions or recursion to count the number of even and odd elements in an array.
🎯 Your Task
Count the number of even and odd elements in an array.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
6 1 2 3 4 5 6
Even: 3 Odd: 3
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int countEven(int arr[], int n)
{
int count = 0;
for(int i = 0; i < n; i++)
{
if(arr[i] % 2 == 0)
count++;
}
return count;
}
int countOdd(int arr[], int n)
{
int count = 0;
for(int i = 0; i < n; i++)
{
if(arr[i] % 2 != 0)
count++;
}
return count;
}
int main()
{
int n, arr[100];
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
printf("Even: %d\n", countEven(arr, n));
printf("Odd: %d", countOdd(arr, n));
return 0;
}
CHALLENGE 18ModeratePalindrome Validation Service
Core Skill: Check Palindrome Using Function
View Challenge →
Palindrome Validation Service
The Palindrome Validation Service is being converted into reusable C components. Use functions or recursion to determine whether a number is a palindrome using a function.
🎯 Your Task
Determine whether a number is a palindrome using a function.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
1221
Palindrome
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int isPalindrome(int n)
{
int original = n;
int reverse = 0;
while(n != 0)
{
reverse = reverse * 10 + n % 10;
n /= 10;
}
return original == reverse;
}
int main()
{
int n;
scanf("%d", &n);
if(isPalindrome(n))
printf("Palindrome");
else
printf("Not Palindrome");
return 0;
}
CHALLENGE 19IntermediateLCM Service Desk
Core Skill: LCM Using Function
View Challenge →
LCM Service Desk
The LCM Service Desk is being converted into reusable C components. Use functions or recursion to determine the least common multiple of two numbers.
🎯 Your Task
Determine the least common multiple of two numbers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
12 18
36
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int gcd(int a, int b)
{
while(b != 0)
{
int temp = b;
b = a % b;
a = temp;
}
return a;
}
int lcm(int a, int b)
{
return (a / gcd(a, b)) * b;
}
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d", lcm(a, b));
return 0;
}
CHALLENGE 20Advanced+Tower Transfer Simulator
Core Skill: Tower of Hanoi
View Challenge →
Tower Transfer Simulator
The Tower Transfer Simulator is being converted into reusable C components. Use functions or recursion to solve the Tower of Hanoi problem using recursion.
🎯 Your Task
Solve the tower of hanoi problem using recursion.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Keep recursive input sizes small enough to avoid excessive recursion depth.
3
Move disk 1 from A to C Move disk 2 from A to B Move disk 1 from C to B Move disk 3 from A to C Move disk 1 from B to A Move disk 2 from B to C Move disk 1 from A to C
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
void hanoi(int n, char source, char auxiliary, char destination)
{
if(n == 1)
{
printf("Move disk 1 from %c to %c\n",
source, destination);
return;
}
hanoi(n - 1, source, destination, auxiliary);
printf("Move disk %d from %c to %c\n",
n, source, destination);
hanoi(n - 1, auxiliary, source, destination);
}
int main()
{
int n;
scanf("%d", &n);
hanoi(n, 'A', 'B', 'C');
return 0;
}
Level 8 — Pointers & Dynamic MemoryAddresses, pointers, dynamic arrays, strings and matrices. • 20 original CodeBhavya challengesOpen 20 Challenges
Every challenge keeps the original C-learning objective from this level, while the story, framing and presentation are newly written for CodeBhavya.
CHALLENGE 01Easy+Address Inspector
Core Skill: Print Value Using Pointer
View Challenge →
Address Inspector
The Address Inspector works with addresses or runtime-sized storage. Use pointers or dynamic memory to store a number in a variable and print its value using a pointer.
🎯 Your Task
Store a number in a variable and print its value using a pointer.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
25
25
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
int *p;
scanf("%d", &n);
p = &n;
printf("%d", *p);
return 0;
}
CHALLENGE 02Easy+Remote Value Updater
Core Skill: Change Value Using Pointer
View Challenge →
Remote Value Updater
The Remote Value Updater works with addresses or runtime-sized storage. Use pointers or dynamic memory to change the value of a variable using a pointer.
🎯 Your Task
Change the value of a variable using a pointer.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
10
50
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
int *p;
scanf("%d", &n);
p = &n;
*p = 50;
printf("%d", n);
return 0;
}
CHALLENGE 03ModeratePointer Swap Station
Core Skill: Swap Two Numbers Using Pointers
View Challenge →
Pointer Swap Station
The Pointer Swap Station works with addresses or runtime-sized storage. Use pointers or dynamic memory to swap two numbers using a function and pointers.
🎯 Your Task
Swap two numbers using a function and pointers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
10 20
20 10
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
void swap(int *a, int *b)
{
int temp = *a;
*a = *b;
*b = temp;
}
int main()
{
int a, b;
scanf("%d %d", &a, &b);
swap(&a, &b);
printf("%d %d", a, b);
return 0;
}
CHALLENGE 04ModeratePointer Array Sum Desk
Core Skill: Sum Array Using Pointer
View Challenge →
Pointer Array Sum Desk
The Pointer Array Sum Desk works with addresses or runtime-sized storage. Use pointers or dynamic memory to determine the sum of array elements using pointer arithmetic.
🎯 Your Task
Determine the sum of array elements using pointer arithmetic.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
5 10 20 30 40 50
150
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, arr[100];
int *p = arr;
int sum = 0;
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
for(int i = 0; i < n; i++)
sum += *(p + i);
printf("%d", sum);
return 0;
}
CHALLENGE 05ModeratePointer Maximum Scanner
Core Skill: Find Maximum Using Pointer
View Challenge →
Pointer Maximum Scanner
The Pointer Maximum Scanner works with addresses or runtime-sized storage. Use pointers or dynamic memory to determine the largest element in an array using pointers.
🎯 Your Task
Determine the largest element in an array using pointers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
5 12 45 7 30 20
45
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, arr[100];
int *p;
int max;
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
p = arr;
max = *p;
for(int i = 1; i < n; i++)
{
if(*(p + i) > max)
max = *(p + i);
}
printf("%d", max);
return 0;
}
CHALLENGE 06IntermediatePointer Array Reversal
Core Skill: Reverse Array Using Pointers
View Challenge →
Pointer Array Reversal
The Pointer Array Reversal works with addresses or runtime-sized storage. Use pointers or dynamic memory to reverse an array using pointers.
🎯 Your Task
Reverse an array using pointers.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
5 1 2 3 4 5
5 4 3 2 1
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, arr[100];
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
int *left = arr;
int *right = arr + n - 1;
while(left < right)
{
int temp = *left;
*left = *right;
*right = temp;
left++;
right--;
}
for(int i = 0; i < n; i++)
{
printf("%d", arr[i]);
if(i < n - 1)
printf(" ");
}
return 0;
}
CHALLENGE 07ModeratePointer Element Counter
Core Skill: Count Array Elements Using Pointers
View Challenge →
Pointer Element Counter
The Pointer Element Counter works with addresses or runtime-sized storage. Use pointers or dynamic memory to count the number of elements in an array using pointers.
🎯 Your Task
Count the number of elements in an array using pointers.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
6 10 20 30 40 50 60
6
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, arr[100];
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
int *start = arr;
int *end = arr + n;
printf("%ld", end - start);
return 0;
}
CHALLENGE 08IntermediateDynamic Registration List
Core Skill: Dynamically Allocate an Array
View Challenge →
Dynamic Registration List
The Dynamic Registration List works with addresses or runtime-sized storage. Use pointers or dynamic memory to allocate memory dynamically for N integers and print their sum.
🎯 Your Task
Allocate memory dynamically for n integers and print their sum.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
5 10 20 30 40 50
150
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
int *arr;
int sum = 0;
scanf("%d", &n);
arr = malloc(n * sizeof(int));
if(arr == NULL)
return 1;
for(int i = 0; i < n; i++)
{
scanf("%d", &arr[i]);
sum += arr[i];
}
printf("%d", sum);
free(arr);
return 0;
}
CHALLENGE 09IntermediateDynamic Score Average
Core Skill: Find Average Using Dynamic Memory
View Challenge →
Dynamic Score Average
The Dynamic Score Average works with addresses or runtime-sized storage. Use pointers or dynamic memory to dynamically allocate an array and find its average.
🎯 Your Task
Dynamically allocate an array and find its average.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
4 10 20 30 40
25.00
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
int *arr;
int sum = 0;
scanf("%d", &n);
arr = malloc(n * sizeof(int));
if(arr == NULL)
return 1;
for(int i = 0; i < n; i++)
{
scanf("%d", &arr[i]);
sum += arr[i];
}
printf("%.2f", (float)sum / n);
free(arr);
return 0;
}
CHALLENGE 10IntermediateZeroed Seat Allocation
Core Skill: calloc() for Array
View Challenge →
Zeroed Seat Allocation
The Zeroed Seat Allocation works with addresses or runtime-sized storage. Use pointers or dynamic memory to dynamically allocate an array using calloc() and display its initial values.
🎯 Your Task
Dynamically allocate an array using calloc() and display its initial values.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
5
0 0 0 0 0
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
int *arr;
scanf("%d", &n);
arr = calloc(n, sizeof(int));
if(arr == NULL)
return 1;
for(int i = 0; i < n; i++)
{
printf("%d", arr[i]);
if(i < n - 1)
printf(" ");
}
free(arr);
return 0;
}
CHALLENGE 11Intermediate+Expandable Registration List
Core Skill: Resize Array Using realloc()
View Challenge →
Expandable Registration List
The Expandable Registration List works with addresses or runtime-sized storage. Use pointers or dynamic memory to create an array of N elements and increase its size to M elements using realloc() .
🎯 Your Task
Create an array of n elements and increase its size to m elements using realloc() .
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
3 10 20 30 5 40 50
10 20 30 40 50
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n, m;
int *arr;
scanf("%d", &n);
arr = malloc(n * sizeof(int));
if(arr == NULL)
return 1;
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
scanf("%d", &m);
arr = realloc(arr, m * sizeof(int));
if(arr == NULL)
return 1;
for(int i = n; i < m; i++)
scanf("%d", &arr[i]);
for(int i = 0; i < m; i++)
{
printf("%d", arr[i]);
if(i < m - 1)
printf(" ");
}
free(arr);
return 0;
}
CHALLENGE 12IntermediatePointer Function Sum
Core Skill: Find Sum Using Pointer Function
View Challenge →
Pointer Function Sum
The Pointer Function Sum works with addresses or runtime-sized storage. Use pointers or dynamic memory to pass an array to a function using a pointer and find its sum.
🎯 Your Task
Pass an array to a function using a pointer and find its sum.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
4 5 10 15 20
50
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int sum(int *arr, int n)
{
int total = 0;
for(int i = 0; i < n; i++)
total += *(arr + i);
return total;
}
int main()
{
int n, arr[100];
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
printf("%d", sum(arr, n));
return 0;
}
CHALLENGE 13IntermediatePointer Seat Swap
Core Skill: Swap Array Elements Using Pointers
View Challenge →
Pointer Seat Swap
The Pointer Seat Swap works with addresses or runtime-sized storage. Use pointers or dynamic memory to swap two elements of an array using pointers.
🎯 Your Task
Swap two elements of an array using pointers.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
5 10 20 30 40 50 1 4
10 50 30 40 20
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
void swap(int *a, int *b)
{
int temp = *a;
*a = *b;
*b = temp;
}
int main()
{
int n, arr[100];
int x, y;
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
scanf("%d %d", &x, &y);
swap(&arr[x], &arr[y]);
for(int i = 0; i < n; i++)
{
printf("%d", arr[i]);
if(i < n - 1)
printf(" ");
}
return 0;
}
CHALLENGE 14IntermediatePointer String Length Meter
Core Skill: Find String Length Using Pointer
View Challenge →
Pointer String Length Meter
The Pointer String Length Meter works with addresses or runtime-sized storage. Use pointers or dynamic memory to determine the length of a string using a character pointer.
🎯 Your Task
Determine the length of a string using a character pointer.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
Hello
5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
char *p;
int length = 0;
scanf("%99s", str);
p = str;
while(*p != '\0')
{
length++;
p++;
}
printf("%d", length);
return 0;
}
CHALLENGE 15Intermediate+Pointer String Reversal
Core Skill: Reverse String Using Pointer
View Challenge →
Pointer String Reversal
The Pointer String Reversal works with addresses or runtime-sized storage. Use pointers or dynamic memory to reverse a string using pointers.
🎯 Your Task
Reverse a string using pointers.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
hello
olleh
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
char *p;
int length = 0;
scanf("%99s", str);
while(str[length] != '\0')
length++;
p = str + length - 1;
while(p >= str)
{
printf("%c", *p);
p--;
}
return 0;
}
CHALLENGE 16Intermediate+Runtime Number Vault
Core Skill: Dynamic Memory for Multiple Numbers
View Challenge →
Runtime Number Vault
The Runtime Number Vault works with addresses or runtime-sized storage. Use pointers or dynamic memory to allocate memory dynamically and find the largest number.
🎯 Your Task
Allocate memory dynamically and find the largest number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
5 15 42 8 31 20
42
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
int *arr;
int max;
scanf("%d", &n);
arr = malloc(n * sizeof(int));
if(arr == NULL)
return 1;
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
max = *arr;
for(int i = 1; i < n; i++)
{
if(*(arr + i) > max)
max = *(arr + i);
}
printf("%d", max);
free(arr);
return 0;
}
CHALLENGE 17Intermediate+Runtime Name Buffer
Core Skill: Dynamic Memory for String
View Challenge →
Runtime Name Buffer
The Runtime Name Buffer works with addresses or runtime-sized storage. Use pointers or dynamic memory to dynamically allocate memory for a string and print it.
🎯 Your Task
Dynamically allocate memory for a string and print it.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
Programming
Programming
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main()
{
char *str;
str = malloc(100 * sizeof(char));
if(str == NULL)
return 1;
scanf("%99s", str);
printf("%s", str);
free(str);
return 0;
}
CHALLENGE 18Intermediate+Double-Pointer Control Desk
Core Skill: Pointer to Pointer
View Challenge →
Double-Pointer Control Desk
The Double-Pointer Control Desk works with addresses or runtime-sized storage. Use pointers or dynamic memory to use a pointer to pointer to access the value of a variable.
🎯 Your Task
Use a pointer to pointer to access the value of a variable.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
100
100
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
int *p;
int **pp;
scanf("%d", &n);
p = &n;
pp = &p;
printf("%d", **pp);
return 0;
}
CHALLENGE 19Advanced+Dynamic Matrix Board
Core Skill: Dynamic Matrix
View Challenge →
Dynamic Matrix Board
The Dynamic Matrix Board works with addresses or runtime-sized storage. Use pointers or dynamic memory to dynamically allocate memory for a matrix and print it.
🎯 Your Task
Dynamically allocate memory for a matrix and print it.
📥 Input Format
Read the matrix dimensions first, followed by the matrix elements in row-major order.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
2 3 1 2 3 4 5 6
1 2 3 4 5 6
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main()
{
int rows, cols;
int **matrix;
scanf("%d %d", &rows, &cols);
matrix = malloc(rows * sizeof(int *));
if(matrix == NULL)
return 1;
for(int i = 0; i < rows; i++)
matrix[i] = malloc(cols * sizeof(int));
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
scanf("%d", &matrix[i][j]);
}
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d", matrix[i][j]);
if(j < cols - 1)
printf(" ");
}
printf("\n");
}
for(int i = 0; i < rows; i++)
free(matrix[i]);
free(matrix);
return 0;
}
CHALLENGE 20AdvancedPointer Runner-Up Scanner
Core Skill: Find Second Largest Using Pointers
View Challenge →
Pointer Runner-Up Scanner
The Pointer Runner-Up Scanner works with addresses or runtime-sized storage. Use pointers or dynamic memory to determine the second largest element using pointer arithmetic.
🎯 Your Task
Determine the second largest element using pointer arithmetic.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 100 for runtime-sized arrays/matrices; check allocations before use.
5 10 40 20 50 30
40
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <limits.h>
int main()
{
int n, arr[100];
int largest = INT_MIN;
int second = INT_MIN;
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%d", &arr[i]);
for(int *p = arr; p < arr + n; p++)
{
if(*p > largest)
{
second = largest;
largest = *p;
}
else if(*p > second && *p != largest)
{
second = *p;
}
}
printf("%d", second);
return 0;
}
Level 9 — Structures & Record FilesStructures, unions and record-oriented file handling. • 20 original CodeBhavya challengesOpen 20 Challenges
Every challenge keeps the original C-learning objective from this level, while the story, framing and presentation are newly written for CodeBhavya.
CHALLENGE 01ModerateStudent Profile Desk
Core Skill: Store Student Details Using Structure
View Challenge →
Student Profile Desk
The Student Profile Desk manages structured campus records. Use structures, unions or files to create a structure to store a student's roll number, name and marks.
🎯 Your Task
Create a structure to store a student's roll number, name and marks.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file operations before use.
101 Ravi 85
101 Ravi 85
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
struct Student
{
int roll;
char name[50];
float marks;
};
int main()
{
struct Student s;
scanf("%d", &s.roll);
scanf("%49s", s.name);
scanf("%f", &s.marks);
printf("%d %s %.0f",
s.roll, s.name, s.marks);
return 0;
}
CHALLENGE 02IntermediateMerit Record Finder
Core Skill: Find Student with Highest Marks
View Challenge →
Merit Record Finder
The Merit Record Finder manages structured campus records. Use structures, unions or files to store details of N students and find the student with the highest marks.
🎯 Your Task
Store details of n students and find the student with the highest marks.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file operations before use.
3 101 Ravi 80 102 Sita 92 103 Arun 85
Sita 92
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
struct Student
{
int roll;
char name[50];
int marks;
};
int main()
{
int n;
struct Student s[100];
int maxIndex = 0;
scanf("%d", &n);
for(int i = 0; i < n; i++)
{
scanf("%d %49s %d",
&s[i].roll,
s[i].name,
&s[i].marks);
}
for(int i = 1; i < n; i++)
{
if(s[i].marks > s[maxIndex].marks)
maxIndex = i;
}
printf("%s %d",
s[maxIndex].name,
s[maxIndex].marks);
return 0;
}
CHALLENGE 03IntermediateClass Average Register
Core Skill: Average Marks Using Structure
View Challenge →
Class Average Register
The Class Average Register manages structured campus records. Use structures, unions or files to compute the average marks of N students.
🎯 Your Task
Compute the average marks of n students.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file operations before use.
3 80 90 70
80.00
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
struct Student
{
int marks;
};
int main()
{
int n;
struct Student s[100];
int sum = 0;
scanf("%d", &n);
for(int i = 0; i < n; i++)
{
scanf("%d", &s[i].marks);
sum += s[i].marks;
}
printf("%.2f", (float)sum / n);
return 0;
}
CHALLENGE 04IntermediateStudent Pointer Desk
Core Skill: Structure Pointer
View Challenge →
Student Pointer Desk
The Student Pointer Desk manages structured campus records. Use structures, unions or files to access structure members using a structure pointer.
🎯 Your Task
Access structure members using a structure pointer.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file operations before use.
101 Ravi 85
101 Ravi 85
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
struct Student
{
int roll;
char name[50];
int marks;
};
int main()
{
struct Student s;
struct Student *p = &s;
scanf("%d %49s %d",
&p->roll,
p->name,
&p->marks);
printf("%d %s %d",
p->roll,
p->name,
p->marks);
return 0;
}
CHALLENGE 05ModerateEmployee Salary Register
Core Skill: Employee Salary
View Challenge →
Employee Salary Register
The Employee Salary Register manages structured campus records. Use structures, unions or files to store employee details using a structure and calculate the annual salary.
🎯 Your Task
Store employee details using a structure and calculate the annual salary.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file operations before use.
101 Ravi 25000
300000
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
struct Employee
{
int id;
char name[50];
int salary;
};
int main()
{
struct Employee e;
scanf("%d", &e.id);
scanf("%49s", e.name);
scanf("%d", &e.salary);
printf("%d", e.salary * 12);
return 0;
}
CHALLENGE 06IntermediateRoll Number Lookup
Core Skill: Search Student by Roll Number
View Challenge →
Roll Number Lookup
The Roll Number Lookup manages structured campus records. Use structures, unions or files to search for a student using the roll number.
🎯 Your Task
Search for a student using the roll number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file operations before use.
3 101 Ravi 80 102 Sita 90 103 Arun 85 102
Sita 90
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
struct Student
{
int roll;
char name[50];
int marks;
};
int main()
{
int n, search;
struct Student s[100];
scanf("%d", &n);
for(int i = 0; i < n; i++)
{
scanf("%d %49s %d",
&s[i].roll,
s[i].name,
&s[i].marks);
}
scanf("%d", &search);
for(int i = 0; i < n; i++)
{
if(s[i].roll == search)
{
printf("%s %d",
s[i].name,
s[i].marks);
return 0;
}
}
printf("Student Not Found");
return 0;
}
CHALLENGE 07AdvancedMerit List Sorter
Core Skill: Sort Students by Marks
View Challenge →
Merit List Sorter
The Merit List Sorter manages structured campus records. Use structures, unions or files to sort student records according to marks in descending order.
🎯 Your Task
Sort student records according to marks in descending order.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file operations before use.
3 101 Ravi 70 102 Sita 90 103 Arun 80
Sita 90 Arun 80 Ravi 70
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
struct Student
{
int roll;
char name[50];
int marks;
};
int main()
{
int n;
struct Student s[100];
scanf("%d", &n);
for(int i = 0; i < n; i++)
{
scanf("%d %49s %d",
&s[i].roll,
s[i].name,
&s[i].marks);
}
for(int i = 0; i < n - 1; i++)
{
for(int j = i + 1; j < n; j++)
{
if(s[i].marks < s[j].marks)
{
struct Student temp = s[i];
s[i] = s[j];
s[j] = temp;
}
}
}
for(int i = 0; i < n; i++)
printf("%s %d\n", s[i].name, s[i].marks);
return 0;
}
CHALLENGE 08Intermediate+Nested Address Register
Core Skill: Nested Structure
View Challenge →
Nested Address Register
The Nested Address Register manages structured campus records. Use structures, unions or files to create a student structure containing a nested address structure.
🎯 Your Task
Create a student structure containing a nested address structure.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file operations before use.
101 Ravi Hyderabad
101 Ravi Hyderabad
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
struct Address
{
char city[50];
};
struct Student
{
int roll;
char name[50];
struct Address address;
};
int main()
{
struct Student s;
scanf("%d", &s.roll);
scanf("%49s", s.name);
scanf("%49s", s.address.city);
printf("%d %s %s",
s.roll,
s.name,
s.address.city);
return 0;
}
CHALLENGE 09IntermediateShared Memory Union Demo
Core Skill: Union Memory Concept
View Challenge →
Shared Memory Union Demo
The Shared Memory Union Demo manages structured campus records. Use structures, unions or files to create a union containing an integer, float and character. Store one value and display it.
🎯 Your Task
Create a union containing an integer, float and character. store one value and display it.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file operations before use.
25
25
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
union Data
{
int i;
float f;
char c;
};
int main()
{
union Data d;
scanf("%d", &d.i);
printf("%d", d.i);
return 0;
}
CHALLENGE 10IntermediateRecord Vault Writer
Core Skill: Write Data to a File
View Challenge →
Record Vault Writer
The Record Vault Writer manages structured campus records. Use structures, unions or files to write a message into a text file.
🎯 Your Task
Write a message into a text file.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file operations before use.
Hello C
Data written successfully
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
char str[100];
fgets(str, sizeof(str), stdin);
fp = fopen("data.txt", "w");
if(fp == NULL)
{
printf("File Error");
return 1;
}
fputs(str, fp);
fclose(fp);
printf("Data written successfully");
return 0;
}
CHALLENGE 11IntermediateRecord Vault Reader
Core Skill: Read Data from a File
View Challenge →
Record Vault Reader
The Record Vault Reader manages structured campus records. Use structures, unions or files to accept and display the contents of a text file.
🎯 Your Task
Accept and display the contents of a text file.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file operations before use.
data.txt contains: Hello C Programming
Hello C Programming
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
char str[200];
fp = fopen("data.txt", "r");
if(fp == NULL)
{
printf("File Not Found");
return 1;
}
while(fgets(str, sizeof(str), fp) != NULL)
printf("%s", str);
fclose(fp);
return 0;
}
CHALLENGE 12IntermediateArchive Character Counter
Core Skill: Count Characters in a File
View Challenge →
Archive Character Counter
The Archive Character Counter manages structured campus records. Use structures, unions or files to count the number of characters stored in a text file.
🎯 Your Task
Count the number of characters stored in a text file.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file operations before use.
data.txt: Hello
5
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
int ch;
int count = 0;
fp = fopen("data.txt", "r");
if(fp == NULL)
return 1;
while((ch = fgetc(fp)) != EOF)
count++;
fclose(fp);
printf("%d", count);
return 0;
}
CHALLENGE 13IntermediateArchive Line Counter
Core Skill: Count Lines in a File
View Challenge →
Archive Line Counter
The Archive Line Counter manages structured campus records. Use structures, unions or files to count the number of lines in a text file.
🎯 Your Task
Count the number of lines in a text file.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file operations before use.
data.txt: Line 1 Line 2 Line 3
3
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
int ch;
int lines = 0;
int last = '\n';
fp = fopen("data.txt", "r");
if(fp == NULL)
return 1;
while((ch = fgetc(fp)) != EOF)
{
if(ch == '\n')
lines++;
last = ch;
}
if(last != '\n')
lines++;
fclose(fp);
printf("%d", lines);
return 0;
}
CHALLENGE 14Intermediate+Archive Copy Desk
Core Skill: Copy One File to Another
View Challenge →
Archive Copy Desk
The Archive Copy Desk manages structured campus records. Use structures, unions or files to copy the contents of one file into another file.
🎯 Your Task
Copy the contents of one file into another file.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file operations before use.
source.txt: Hello C
destination.txt: Hello C
Show Program
#include <stdio.h>
int main()
{
FILE *source, *destination;
int ch;
source = fopen("source.txt", "r");
destination = fopen("destination.txt", "w");
if(source == NULL || destination == NULL)
return 1;
while((ch = fgetc(source)) != EOF)
fputc(ch, destination);
fclose(source);
fclose(destination);
printf("File copied successfully");
return 0;
}
CHALLENGE 15IntermediateArchive Append Desk
Core Skill: Append Data to a File
View Challenge →
Archive Append Desk
The Archive Append Desk manages structured campus records. Use structures, unions or files to add new text to the end of an existing file.
🎯 Your Task
Add new text to the end of an existing file.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file operations before use.
Welcome
Data appended successfully
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
char str[100];
fgets(str, sizeof(str), stdin);
fp = fopen("data.txt", "a");
if(fp == NULL)
return 1;
fputs(str, fp);
fclose(fp);
printf("Data appended successfully");
return 0;
}
CHALLENGE 16Intermediate+Persistent Student Writer
Core Skill: Store Student Record in File
View Challenge →
Persistent Student Writer
The Persistent Student Writer manages structured campus records. Use structures, unions or files to store a student's roll number, name and marks in a file.
🎯 Your Task
Store a student's roll number, name and marks in a file.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file operations before use.
101 Ravi 85
Student record saved
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
int roll, marks;
char name[50];
scanf("%d %49s %d",
&roll, name, &marks);
fp = fopen("student.txt", "w");
if(fp == NULL)
return 1;
fprintf(fp, "%d %s %d\n",
roll, name, marks);
fclose(fp);
printf("Student record saved");
return 0;
}
CHALLENGE 17Intermediate+Persistent Student Reader
Core Skill: Read Student Record from File
View Challenge →
Persistent Student Reader
The Persistent Student Reader manages structured campus records. Use structures, unions or files to accept a student's record from a file and display it.
🎯 Your Task
Accept a student's record from a file and display it.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file operations before use.
student.txt: 101 Ravi 85
101 Ravi 85
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
int roll, marks;
char name[50];
fp = fopen("student.txt", "r");
if(fp == NULL)
return 1;
fscanf(fp, "%d %49s %d",
&roll, name, &marks);
printf("%d %s %d",
roll, name, marks);
fclose(fp);
return 0;
}
CHALLENGE 18Intermediate+Student File Counter
Core Skill: Count Students in File
View Challenge →
Student File Counter
The Student File Counter manages structured campus records. Use structures, unions or files to count the number of student records stored in a file.
🎯 Your Task
Count the number of student records stored in a file.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file operations before use.
student.txt: 101 Ravi 80 102 Sita 90 103 Arun 85
3
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
int roll, marks;
char name[50];
int count = 0;
fp = fopen("student.txt", "r");
if(fp == NULL)
return 1;
while(fscanf(fp, "%d %49s %d",
&roll, name, &marks) == 3)
{
count++;
}
fclose(fp);
printf("%d", count);
return 0;
}
CHALLENGE 19AdvancedBinary Student Archive
Core Skill: Binary File Using Structure
View Challenge →
Binary Student Archive
The Binary Student Archive manages structured campus records. Use structures, unions or files to store a structure in a binary file using fwrite() .
🎯 Your Task
Store a structure in a binary file using fwrite() .
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file operations before use.
101 Ravi 85
Record stored successfully
Show Program
#include <stdio.h>
struct Student
{
int roll;
char name[50];
int marks;
};
int main()
{
FILE *fp;
struct Student s;
scanf("%d %49s %d",
&s.roll,
s.name,
&s.marks);
fp = fopen("student.dat", "wb");
if(fp == NULL)
return 1;
fwrite(&s, sizeof(s), 1, fp);
fclose(fp);
printf("Record stored successfully");
return 0;
}
CHALLENGE 20HardStudent Record Manager
Core Skill: Student Management Mini Project
View Challenge →
Student Record Manager
The Student Record Manager manages structured campus records. Use structures, unions or files to create a menu-driven student management system using structures and file handling.
🎯 Your Task
Create a menu-driven student management system using structures and file handling.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file operations before use.
1 101 Ravi 85
Student added successfully
Show Program
#include <stdio.h>
struct Student
{
int roll;
char name[50];
int marks;
};
void addStudent()
{
FILE *fp;
struct Student s;
fp = fopen("students.dat", "ab");
if(fp == NULL)
{
printf("File Error\n");
return;
}
printf("Enter Roll Number: ");
scanf("%d", &s.roll);
printf("Enter Name: ");
scanf("%49s", s.name);
printf("Enter Marks: ");
scanf("%d", &s.marks);
fwrite(&s, sizeof(s), 1, fp);
fclose(fp);
printf("Student added successfully\n");
}
void displayStudents()
{
FILE *fp;
struct Student s;
fp = fopen("students.dat", "rb");
if(fp == NULL)
{
printf("No records found\n");
return;
}
while(fread(&s, sizeof(s), 1, fp) == 1)
{
printf("Roll: %d\n", s.roll);
printf("Name: %s\n", s.name);
printf("Marks: %d\n\n", s.marks);
}
fclose(fp);
}
int main()
{
int choice;
do
{
printf("1. Add Student\n");
printf("2. Display Students\n");
printf("3. Exit\n");
scanf("%d", &choice);
switch(choice)
{
case 1:
addStudent();
break;
case 2:
displayStudents();
break;
case 3:
printf("Exiting...");
break;
default:
printf("Invalid choice\n");
}
} while(choice != 3);
return 0;
}
Level 10 — Files & Runtime MemoryFile workflows combined with runtime-sized memory. • 20 original CodeBhavya challengesOpen 20 Challenges
Every challenge keeps the original C-learning objective from this level, while the story, framing and presentation are newly written for CodeBhavya.
CHALLENGE 01IntermediateDaily Note Writer
Core Skill: Create and Write to a File
View Challenge →
Daily Note Writer
The Daily Note Writer handles persistent data or memory requested at runtime. Build the C workflow to create a file and write a message into it.
🎯 Your Task
Create a file and write a message into it.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
Hello C Programming
Data written successfully
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
char str[100];
fgets(str, sizeof(str), stdin);
fp = fopen("data.txt", "w");
if(fp == NULL)
{
printf("File cannot be opened");
return 0;
}
fprintf(fp, "%s", str);
fclose(fp);
printf("Data written successfully");
return 0;
}
CHALLENGE 02IntermediateDaily Note Reader
Core Skill: Read Data from a File
View Challenge →
Daily Note Reader
The Daily Note Reader handles persistent data or memory requested at runtime. Build the C workflow to accept and display the contents of a text file.
🎯 Your Task
Accept and display the contents of a text file.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
data.txt contains: Hello C
Hello C
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
char str[200];
fp = fopen("data.txt", "r");
if(fp == NULL)
{
printf("File not found");
return 0;
}
while(fgets(str, sizeof(str), fp) != NULL)
{
printf("%s", str);
}
fclose(fp);
return 0;
}
CHALLENGE 03IntermediateArchive Character Audit
Core Skill: Count Characters in a File
View Challenge →
Archive Character Audit
The Archive Character Audit handles persistent data or memory requested at runtime. Build the C workflow to count the number of characters present in a text file.
🎯 Your Task
Count the number of characters present in a text file.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
data.txt: Hello
5
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
int ch;
int count = 0;
fp = fopen("data.txt", "r");
if(fp == NULL)
{
printf("File not found");
return 0;
}
while((ch = fgetc(fp)) != EOF)
{
count++;
}
fclose(fp);
printf("%d", count);
return 0;
}
CHALLENGE 04IntermediateArchive Line Audit
Core Skill: Count Lines in a File
View Challenge →
Archive Line Audit
The Archive Line Audit handles persistent data or memory requested at runtime. Build the C workflow to count the number of lines present in a text file.
🎯 Your Task
Count the number of lines present in a text file.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
data.txt: Hello World C Programming
3
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
int ch;
int lines = 0;
int last = '\n';
fp = fopen("data.txt", "r");
if(fp == NULL)
{
printf("File not found");
return 0;
}
while((ch = fgetc(fp)) != EOF)
{
if(ch == '\n')
lines++;
last = ch;
}
if(last != '\n')
lines++;
fclose(fp);
printf("%d", lines);
return 0;
}
CHALLENGE 05Intermediate+Archive Word Audit
Core Skill: Count Words in a File
View Challenge →
Archive Word Audit
The Archive Word Audit handles persistent data or memory requested at runtime. Build the C workflow to count the number of words present in a text file.
🎯 Your Task
Count the number of words present in a text file.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
data.txt: C programming is easy
4
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
int ch;
int words = 0;
int inWord = 0;
fp = fopen("data.txt", "r");
if(fp == NULL)
{
printf("File not found");
return 0;
}
while((ch = fgetc(fp)) != EOF)
{
if(isspace(ch))
{
inWord = 0;
}
else if(!inWord)
{
words++;
inWord = 1;
}
}
fclose(fp);
printf("%d", words);
return 0;
}
CHALLENGE 06Intermediate+Vault Copy Service
Core Skill: Copy One File to Another
View Challenge →
Vault Copy Service
The Vault Copy Service handles persistent data or memory requested at runtime. Build the C workflow to copy the contents of one text file into another file.
🎯 Your Task
Copy the contents of one text file into another file.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
source.txt: Hello C Programming
Data copied successfully
Show Program
#include <stdio.h>
int main()
{
FILE *source;
FILE *destination;
int ch;
source = fopen("source.txt", "r");
if(source == NULL)
{
printf("Source file not found");
return 0;
}
destination = fopen("copy.txt", "w");
if(destination == NULL)
{
fclose(source);
printf("Destination file cannot be opened");
return 0;
}
while((ch = fgetc(source)) != EOF)
{
fputc(ch, destination);
}
fclose(source);
fclose(destination);
printf("Data copied successfully");
return 0;
}
CHALLENGE 07IntermediateVault Append Service
Core Skill: Append Data to a File
View Challenge →
Vault Append Service
The Vault Append Service handles persistent data or memory requested at runtime. Build the C workflow to add new text to the end of an existing file without deleting its old contents.
🎯 Your Task
Add new text to the end of an existing file without deleting its old contents.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
data.txt: Hello New input: World
Hello World
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
char str[100];
fgets(str, sizeof(str), stdin);
fp = fopen("data.txt", "a");
if(fp == NULL)
{
printf("File cannot be opened");
return 0;
}
fprintf(fp, "%s", str);
fclose(fp);
printf("Data appended successfully");
return 0;
}
CHALLENGE 08Intermediate+Archive Keyword Finder
Core Skill: Search for a Word in a File
View Challenge →
Archive Keyword Finder
The Archive Keyword Finder handles persistent data or memory requested at runtime. Build the C workflow to search whether a given word is present in a text file.
🎯 Your Task
Search whether a given word is present in a text file.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
data.txt: C programming is powerful Search: programming
Found
Show Program
#include <stdio.h>
#include <string.h>
int main()
{
FILE *fp;
char word[100];
char search[100];
fp = fopen("data.txt", "r");
if(fp == NULL)
{
printf("File not found");
return 0;
}
scanf("%99s", search);
while(fscanf(fp, "%99s", word) == 1)
{
if(strcmp(word, search) == 0)
{
printf("Found");
fclose(fp);
return 0;
}
}
fclose(fp);
printf("Not Found");
return 0;
}
CHALLENGE 09IntermediateArchive Character Finder
Core Skill: Count a Character in a File
View Challenge →
Archive Character Finder
The Archive Character Finder handles persistent data or memory requested at runtime. Build the C workflow to count how many times a given character occurs in a text file.
🎯 Your Task
Count how many times a given character occurs in a text file.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
data.txt:
programming
Search:
g2
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
int ch;
char search;
int count = 0;
fp = fopen("data.txt", "r");
if(fp == NULL)
{
printf("File not found");
return 0;
}
scanf(" %c", &search);
while((ch = fgetc(fp)) != EOF)
{
if(ch == search)
count++;
}
fclose(fp);
printf("%d", count);
return 0;
}
CHALLENGE 10Intermediate+Number Archive Writer
Core Skill: Store Numbers in a File
View Challenge →
Number Archive Writer
The Number Archive Writer handles persistent data or memory requested at runtime. Build the C workflow to accept N integers and store them in a file.
🎯 Your Task
Accept n integers and store them in a file.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
5 10 20 30 40 50
Numbers stored successfully
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
int n, x;
scanf("%d", &n);
fp = fopen("numbers.txt", "w");
if(fp == NULL)
{
printf("File cannot be opened");
return 0;
}
for(int i = 0; i < n; i++)
{
scanf("%d", &x);
fprintf(fp, "%d ", x);
}
fclose(fp);
printf("Numbers stored successfully");
return 0;
}
CHALLENGE 11Intermediate+Number Archive Sum Desk
Core Skill: Read Numbers from a File and Find Sum
View Challenge →
Number Archive Sum Desk
The Number Archive Sum Desk handles persistent data or memory requested at runtime. Build the C workflow to accept integers from a file and calculate their sum.
🎯 Your Task
Accept integers from a file and calculate their sum.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
numbers.txt: 10 20 30 40 50
150
Show Program
#include <stdio.h>
int main()
{
FILE *fp;
int x;
int sum = 0;
fp = fopen("numbers.txt", "r");
if(fp == NULL)
{
printf("File not found");
return 0;
}
while(fscanf(fp, "%d", &x) == 1)
{
sum += x;
}
fclose(fp);
printf("%d", sum);
return 0;
}
CHALLENGE 12IntermediateRuntime Integer Slot
Core Skill: Allocate Memory Using malloc()
View Challenge →
Runtime Integer Slot
The Runtime Integer Slot handles persistent data or memory requested at runtime. Build the C workflow to dynamically allocate memory for N integers using malloc() and print them.
🎯 Your Task
Dynamically allocate memory for n integers using malloc() and print them.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
5 10 20 30 40 50
10 20 30 40 50
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
scanf("%d", &n);
int *a = malloc(n * sizeof(int));
if(a == NULL)
{
printf("Memory allocation failed");
return 0;
}
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
for(int i = 0; i < n; i++)
printf("%d ", a[i]);
free(a);
return 0;
}
CHALLENGE 13Intermediate+Runtime Array Sum
Core Skill: Sum of Dynamically Allocated Array
View Challenge →
Runtime Array Sum
The Runtime Array Sum handles persistent data or memory requested at runtime. Build the C workflow to dynamically allocate an integer array and find the sum of its elements.
🎯 Your Task
Dynamically allocate an integer array and find the sum of its elements.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
5 10 20 30 40 50
150
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
int sum = 0;
scanf("%d", &n);
int *a = malloc(n * sizeof(int));
if(a == NULL)
return 0;
for(int i = 0; i < n; i++)
{
scanf("%d", &a[i]);
sum += a[i];
}
printf("%d", sum);
free(a);
return 0;
}
CHALLENGE 14IntermediateZeroed Runtime Array
Core Skill: Allocate Memory Using calloc()
View Challenge →
Zeroed Runtime Array
The Zeroed Runtime Array handles persistent data or memory requested at runtime. Build the C workflow to allocate memory for N integers using calloc() and display the initial values.
🎯 Your Task
Allocate memory for n integers using calloc() and display the initial values.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
5
0 0 0 0 0
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
scanf("%d", &n);
int *a = calloc(n, sizeof(int));
if(a == NULL)
{
printf("Memory allocation failed");
return 0;
}
for(int i = 0; i < n; i++)
printf("%d ", a[i]);
free(a);
return 0;
}
CHALLENGE 15Intermediate+Expandable Runtime Array
Core Skill: Resize Memory Using realloc()
View Challenge →
Expandable Runtime Array
The Expandable Runtime Array handles persistent data or memory requested at runtime. Build the C workflow to allocate memory for N integers and increase the array size to M using realloc() .
🎯 Your Task
Allocate memory for n integers and increase the array size to m using realloc() .
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
3 10 20 30 5 40 50
10 20 30 40 50
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n, m;
scanf("%d", &n);
int *a = malloc(n * sizeof(int));
if(a == NULL)
return 0;
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
scanf("%d", &m);
int *temp = realloc(a, m * sizeof(int));
if(temp == NULL)
{
free(a);
return 0;
}
a = temp;
for(int i = n; i < m; i++)
scanf("%d", &a[i]);
for(int i = 0; i < m; i++)
printf("%d ", a[i]);
free(a);
return 0;
}
CHALLENGE 16Intermediate+Runtime Maximum Finder
Core Skill: Find Largest Element Using Dynamic Memory
View Challenge →
Runtime Maximum Finder
The Runtime Maximum Finder handles persistent data or memory requested at runtime. Build the C workflow to dynamically allocate an array and find its largest element.
🎯 Your Task
Dynamically allocate an array and find its largest element.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
5 10 45 20 67 30
67
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
scanf("%d", &n);
int *a = malloc(n * sizeof(int));
if(a == NULL)
return 0;
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
int max = a[0];
for(int i = 1; i < n; i++)
{
if(a[i] > max)
max = a[i];
}
printf("%d", max);
free(a);
return 0;
}
CHALLENGE 17AdvancedRuntime Array Reversal
Core Skill: Reverse Dynamically Allocated Array
View Challenge →
Runtime Array Reversal
The Runtime Array Reversal handles persistent data or memory requested at runtime. Build the C workflow to dynamically allocate an array and reverse its elements.
🎯 Your Task
Dynamically allocate an array and reverse its elements.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
5 10 20 30 40 50
50 40 30 20 10
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
scanf("%d", &n);
int *a = malloc(n * sizeof(int));
if(a == NULL)
return 0;
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
int start = 0;
int end = n - 1;
while(start < end)
{
int temp = a[start];
a[start] = a[end];
a[end] = temp;
start++;
end--;
}
for(int i = 0; i < n; i++)
printf("%d ", a[i]);
free(a);
return 0;
}
CHALLENGE 18Intermediate+Runtime Text Buffer
Core Skill: Dynamically Allocate a String
View Challenge →
Runtime Text Buffer
The Runtime Text Buffer handles persistent data or memory requested at runtime. Build the C workflow to dynamically allocate memory for a string and display the entered string.
🎯 Your Task
Dynamically allocate memory for a string and display the entered string.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
Programming
Programming
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char temp[100];
fgets(temp, sizeof(temp), stdin);
temp[strcspn(temp, "\n")] = '\0';
char *str = malloc((strlen(temp) + 1) * sizeof(char));
if(str == NULL)
return 0;
strcpy(str, temp);
printf("%s", str);
free(str);
return 0;
}
CHALLENGE 19AdvancedRuntime Student Registry
Core Skill: Dynamic Memory with Structure
View Challenge →
Runtime Student Registry
The Runtime Student Registry handles persistent data or memory requested at runtime. Build the C workflow to dynamically allocate memory for N students using structures and display their details.
🎯 Your Task
Dynamically allocate memory for n students using structures and display their details.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
2 Ravi 85 Sita 92
Ravi 85 Sita 92
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
struct Student
{
char name[50];
int marks;
};
int main()
{
int n;
scanf("%d", &n);
struct Student *s =
malloc(n * sizeof(struct Student));
if(s == NULL)
return 0;
for(int i = 0; i < n; i++)
{
scanf("%49s %d", s[i].name, &s[i].marks);
}
for(int i = 0; i < n; i++)
{
printf("%s %d\n",
s[i].name,
s[i].marks);
}
free(s);
return 0;
}
CHALLENGE 20HardPersistent Dynamic Student Vault
Core Skill: Student Records Using File and Dynamic Memory
View Challenge →
Persistent Dynamic Student Vault
The Persistent Dynamic Student Vault handles persistent data or memory requested at runtime. Build the C workflow to dynamically allocate memory for student records, store them in a file and then read and display them.
🎯 Your Task
Dynamically allocate memory for student records, store them in a file and then read and display them.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Produce the requested file/record result in the exact format shown.
📏 Constraints
Use at most 100 records/items; check file and memory operations before use.
2 Ravi 85 Sita 92
Ravi 85 Sita 92
Show Program
#include <stdio.h>
#include <stdlib.h>
struct Student
{
char name[50];
int marks;
};
int main()
{
int n;
scanf("%d", &n);
struct Student *s =
malloc(n * sizeof(struct Student));
if(s == NULL)
return 0;
for(int i = 0; i < n; i++)
{
scanf("%49s %d",
s[i].name,
&s[i].marks);
}
FILE *fp = fopen("students.txt", "w");
if(fp == NULL)
{
free(s);
return 0;
}
for(int i = 0; i < n; i++)
{
fprintf(fp, "%s %d\n",
s[i].name,
s[i].marks);
}
fclose(fp);
free(s);
fp = fopen("students.txt", "r");
if(fp == NULL)
return 0;
struct Student temp;
while(fscanf(fp, "%49s %d",
temp.name,
&temp.marks) == 2)
{
printf("%s %d\n",
temp.name,
temp.marks);
}
fclose(fp);
return 0;
}
Level 11 — Terminal & BitwiseCommand-line utilities and compact bit-level operations. • 20 original CodeBhavya challengesOpen 20 Challenges
Every challenge keeps the original C-learning objective from this level, while the story, framing and presentation are newly written for CodeBhavya.
CHALLENGE 01ModerateTerminal Greeting Tool
Core Skill: Read Command Line Argument
View Challenge →
Terminal Greeting Tool
The Terminal Greeting Tool is a systems-style utility. Implement the command-line or bitwise operation needed to accept and display a command line argument.
🎯 Your Task
Accept and display a command line argument.
📥 Input Format
Supply the required values as command-line arguments after the executable name.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Assume the required argument count is provided unless the challenge asks you to validate it.
./program Venu
Venu
C Code Editor
Command Line Arguments
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main(int argc, char *argv[])
{
if(argc > 1)
printf("%s", argv[1]);
return 0;
}
CHALLENGE 02ModerateTerminal Argument Meter
Core Skill: Count Command Line Arguments
View Challenge →
Terminal Argument Meter
The Terminal Argument Meter is a systems-style utility. Implement the command-line or bitwise operation needed to count the number of arguments supplied through the command line.
🎯 Your Task
Count the number of arguments supplied through the command line.
📥 Input Format
Supply the required values as command-line arguments after the executable name.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Assume the required argument count is provided unless the challenge asks you to validate it.
./program C Java Python
3
C Code Editor
Command Line Arguments
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("%d", argc - 1);
return 0;
}
CHALLENGE 03IntermediateTerminal Sum Utility
Core Skill: Add Two Command Line Numbers
View Challenge →
Terminal Sum Utility
The Terminal Sum Utility is a systems-style utility. Implement the command-line or bitwise operation needed to accept two integers through command line arguments and print their sum.
🎯 Your Task
Accept two integers through command line arguments and print their sum.
📥 Input Format
Supply the required values as command-line arguments after the executable name.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Assume the required argument count is provided unless the challenge asks you to validate it.
./program 10 20
30
C Code Editor
Command Line Arguments
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if(argc != 3)
return 0;
int a = atoi(argv[1]);
int b = atoi(argv[2]);
printf("%d", a + b);
return 0;
}
CHALLENGE 04Intermediate+Terminal Maximum Utility
Core Skill: Find Largest Command Line Number
View Challenge →
Terminal Maximum Utility
The Terminal Maximum Utility is a systems-style utility. Implement the command-line or bitwise operation needed to accept three integers through command line arguments and find the largest number.
🎯 Your Task
Accept three integers through command line arguments and find the largest number.
📥 Input Format
Supply the required values as command-line arguments after the executable name.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Assume the required argument count is provided unless the challenge asks you to validate it.
./program 25 10 40
40
C Code Editor
Command Line Arguments
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if(argc != 4)
return 0;
int a = atoi(argv[1]);
int b = atoi(argv[2]);
int c = atoi(argv[3]);
int max = a;
if(b > max)
max = b;
if(c > max)
max = c;
printf("%d", max);
return 0;
}
CHALLENGE 05Easy+Permission AND Console
Core Skill: Bitwise AND
View Challenge →
Permission AND Console
The Permission AND Console is a systems-style utility. Implement the command-line or bitwise operation needed to perform bitwise AND operation on two integers.
🎯 Your Task
Perform bitwise and operation on two integers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
12 10
8
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d", a & b);
return 0;
}
CHALLENGE 06Easy+Feature OR Console
Core Skill: Bitwise OR
View Challenge →
Feature OR Console
The Feature OR Console is a systems-style utility. Implement the command-line or bitwise operation needed to perform bitwise OR operation on two integers.
🎯 Your Task
Perform bitwise or operation on two integers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
12 10
14
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d", a | b);
return 0;
}
CHALLENGE 07Easy+Toggle XOR Console
Core Skill: Bitwise XOR
View Challenge →
Toggle XOR Console
The Toggle XOR Console is a systems-style utility. Implement the command-line or bitwise operation needed to perform bitwise XOR operation on two integers.
🎯 Your Task
Perform bitwise xor operation on two integers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
12 10
6
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d", a ^ b);
return 0;
}
CHALLENGE 08Easy+Bit Inversion Panel
Core Skill: Bitwise NOT
View Challenge →
Bit Inversion Panel
The Bit Inversion Panel is a systems-style utility. Implement the command-line or bitwise operation needed to determine the bitwise NOT of a given integer.
🎯 Your Task
Determine the bitwise not of a given integer.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
5
-6
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
printf("%d", ~n);
return 0;
}
CHALLENGE 09Easy+Fast Multiply Shift Panel
Core Skill: Left Shift
View Challenge →
Fast Multiply Shift Panel
The Fast Multiply Shift Panel is a systems-style utility. Implement the command-line or bitwise operation needed to perform a left shift operation on an integer.
🎯 Your Task
Perform a left shift operation on an integer.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
5 2
20
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, shift;
scanf("%d %d", &n, &shift);
printf("%d", n << shift);
return 0;
}
CHALLENGE 10Easy+Fast Divide Shift Panel
Core Skill: Right Shift
View Challenge →
Fast Divide Shift Panel
The Fast Divide Shift Panel is a systems-style utility. Implement the command-line or bitwise operation needed to perform a right shift operation on an integer.
🎯 Your Task
Perform a right shift operation on an integer.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
20 2
5
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, shift;
scanf("%d %d", &n, &shift);
printf("%d", n >> shift);
return 0;
}
CHALLENGE 11Easy+Parity Bit Scanner
Core Skill: Check Whether a Number is Even Using Bitwise
View Challenge →
Parity Bit Scanner
The Parity Bit Scanner is a systems-style utility. Implement the command-line or bitwise operation needed to determine whether a number is even or odd using a bitwise operator.
🎯 Your Task
Determine whether a number is even or odd using a bitwise operator.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
18
Even
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
if((n & 1) == 0)
printf("Even");
else
printf("Odd");
return 0;
}
CHALLENGE 12ModerateSpecific Bit Inspector
Core Skill: Check a Specific Bit
View Challenge →
Specific Bit Inspector
The Specific Bit Inspector is a systems-style utility. Implement the command-line or bitwise operation needed to determine whether the K-th bit of a number is set. Consider the least significant bit as bit 0.
🎯 Your Task
Determine whether the k-th bit of a number is set. consider the least significant bit as bit 0.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
10 1
Set
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, k;
scanf("%d %d", &n, &k);
if(n & (1 << k))
printf("Set");
else
printf("Not Set");
return 0;
}
CHALLENGE 13ModeratePermission Bit Setter
Core Skill: Set the K-th Bit
View Challenge →
Permission Bit Setter
The Permission Bit Setter is a systems-style utility. Implement the command-line or bitwise operation needed to set the K-th bit of a number to 1.
🎯 Your Task
Set the k-th bit of a number to 1.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
8 1
10
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, k;
scanf("%d %d", &n, &k);
n = n | (1 << k);
printf("%d", n);
return 0;
}
CHALLENGE 14ModeratePermission Bit Cleaner
Core Skill: Clear the K-th Bit
View Challenge →
Permission Bit Cleaner
The Permission Bit Cleaner is a systems-style utility. Implement the command-line or bitwise operation needed to clear the K-th bit of a number.
🎯 Your Task
Clear the k-th bit of a number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
10 1
8
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, k;
scanf("%d %d", &n, &k);
n = n & ~(1 << k);
printf("%d", n);
return 0;
}
CHALLENGE 15ModeratePermission Bit Toggle
Core Skill: Toggle the K-th Bit
View Challenge →
Permission Bit Toggle
The Permission Bit Toggle is a systems-style utility. Implement the command-line or bitwise operation needed to toggle the K-th bit of a number.
🎯 Your Task
Toggle the k-th bit of a number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
10 1
8
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, k;
scanf("%d %d", &n, &k);
n = n ^ (1 << k);
printf("%d", n);
return 0;
}
CHALLENGE 16Intermediate+Active Flag Counter
Core Skill: Count Set Bits
View Challenge →
Active Flag Counter
The Active Flag Counter is a systems-style utility. Implement the command-line or bitwise operation needed to count the number of 1 bits in the binary representation of a positive integer.
🎯 Your Task
Count the number of 1 bits in the binary representation of a positive integer.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
13
3
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
unsigned int n;
int count = 0;
scanf("%u", &n);
while(n > 0)
{
count += n & 1;
n = n >> 1;
}
printf("%d", count);
return 0;
}
CHALLENGE 17IntermediateSingle-Flag Power Check
Core Skill: Check Power of Two
View Challenge →
Single-Flag Power Check
The Single-Flag Power Check is a systems-style utility. Implement the command-line or bitwise operation needed to determine whether a positive integer is a power of 2 using bitwise operations.
🎯 Your Task
Determine whether a positive integer is a power of 2 using bitwise operations.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
16
Power of 2
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
unsigned int n;
scanf("%u", &n);
if(n > 0 && (n & (n - 1)) == 0)
printf("Power of 2");
else
printf("Not Power of 2");
return 0;
}
CHALLENGE 18Intermediate+Unique Device ID Finder
Core Skill: Find the Unique Element
View Challenge →
Unique Device ID Finder
The Unique Device ID Finder is a systems-style utility. Implement the command-line or bitwise operation needed to every element in an array appears twice except one. Find the element that appears only once.
🎯 Your Task
Every element in an array appears twice except one. find the element that appears only once.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use values appropriate to the command-line or bitwise operation.
5 4 1 2 1 2
4
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
int result = 0;
scanf("%d", &n);
for(int i = 0; i < n; i++)
{
int x;
scanf("%d", &x);
result = result ^ x;
}
printf("%d", result);
return 0;
}
CHALLENGE 19IntermediateXOR Swap Console
Core Skill: Swap Two Numbers Using XOR
View Challenge →
XOR Swap Console
The XOR Swap Console is a systems-style utility. Implement the command-line or bitwise operation needed to swap two integer values without using a third variable, using XOR.
🎯 Your Task
Swap two integer values without using a third variable, using xor.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
10 20
20 10
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
a = a ^ b;
b = a ^ b;
a = a ^ b;
printf("%d %d", a, b);
return 0;
}
CHALLENGE 20AdvancedEight-Bit Mirror Panel
Core Skill: Reverse Bits of an 8-bit Number
View Challenge →
Eight-Bit Mirror Panel
The Eight-Bit Mirror Panel is a systems-style utility. Implement the command-line or bitwise operation needed to reverse the bits of an 8-bit unsigned number.
🎯 Your Task
Reverse the bits of an 8-bit unsigned number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
13
176
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
unsigned int n;
unsigned int result = 0;
scanf("%u", &n);
for(int i = 0; i < 8; i++)
{
result = (result << 1) | (n & 1);
n = n >> 1;
}
printf("%u", result);
return 0;
}
Level 12 — Placement SprintInterview-style algorithmic challenges with clear competitive statements. • 20 original CodeBhavya challengesOpen 20 Challenges
Every challenge keeps the original C-learning objective from this level, while the story, framing and presentation are newly written for CodeBhavya.
CHALLENGE 01Intermediate+Runner-Up Package Board
Core Skill: Second Largest Element
View Challenge →
Runner-Up Package Board
During the CodeBhavya Placement Sprint, the Runner-Up Package Board challenge tests careful problem solving. Implement a reliable solution to determine the second largest element in an array without sorting it.
🎯 Your Task
Determine the second largest element in an array without sorting it.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
6 10 25 8 40 15 30
30
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <limits.h>
int main()
{
int n;
scanf("%d", &n);
int a[n];
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
int largest = INT_MIN;
int second = INT_MIN;
for(int i = 0; i < n; i++)
{
if(a[i] > largest)
{
second = largest;
largest = a[i];
}
else if(a[i] > second && a[i] != largest)
{
second = a[i];
}
}
printf("%d", second);
return 0;
}
CHALLENGE 02Intermediate+Candidate ID Deduplicator
Core Skill: Remove Duplicates from Array
View Challenge →
Candidate ID Deduplicator
During the CodeBhavya Placement Sprint, the Candidate ID Deduplicator challenge tests careful problem solving. Implement a reliable solution to remove duplicate elements from an array and print only the unique elements.
🎯 Your Task
Remove duplicate elements from an array and print only the unique elements.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
7 10 20 10 30 20 40 30
10 20 30 40
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int a[n];
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
for(int i = 0; i < n; i++)
{
int unique = 1;
for(int j = 0; j < i; j++)
{
if(a[i] == a[j])
{
unique = 0;
break;
}
}
if(unique)
printf("%d ", a[i]);
}
return 0;
}
CHALLENGE 03Intermediate+Vacant Seat Compactor
Core Skill: Move All Zeros to End
View Challenge →
Vacant Seat Compactor
During the CodeBhavya Placement Sprint, the Vacant Seat Compactor challenge tests careful problem solving. Implement a reliable solution to move all zero elements to the end while maintaining the order of non-zero elements.
🎯 Your Task
Move all zero elements to the end while maintaining the order of non-zero elements.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
7 0 1 0 3 12 0 5
1 3 12 5 0 0 0
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int a[n];
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
int pos = 0;
for(int i = 0; i < n; i++)
{
if(a[i] != 0)
a[pos++] = a[i];
}
while(pos < n)
a[pos++] = 0;
for(int i = 0; i < n; i++)
printf("%d ", a[i]);
return 0;
}
CHALLENGE 04Intermediate+Missing Registration ID
Core Skill: Find Missing Number
View Challenge →
Missing Registration ID
During the CodeBhavya Placement Sprint, the Missing Registration ID challenge tests careful problem solving. Implement a reliable solution to an array contains numbers from 1 to N with one number missing. Find the missing number.
🎯 Your Task
An array contains numbers from 1 to n with one number missing. find the missing number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
5 1 2 4 5
3
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int sum = n * (n + 1) / 2;
int actual = 0;
for(int i = 0; i < n - 1; i++)
{
int x;
scanf("%d", &x);
actual += x;
}
printf("%d", sum - actual);
return 0;
}
CHALLENGE 05HardBest Streak Score
Core Skill: Maximum Subarray Sum
View Challenge →
Best Streak Score
During the CodeBhavya Placement Sprint, the Best Streak Score challenge tests careful problem solving. Implement a reliable solution to determine the maximum possible sum of a contiguous subarray.
🎯 Your Task
Determine the maximum possible sum of a contiguous subarray.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
8 -2 1 -3 4 -1 2 1 -5
6
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int x;
scanf("%d", &x);
int current = x;
int maximum = x;
for(int i = 1; i < n; i++)
{
scanf("%d", &x);
if(current + x > x)
current = current + x;
else
current = x;
if(current > maximum)
maximum = current;
}
printf("%d", maximum);
return 0;
}
CHALLENGE 06AdvancedCircular Shift Roster
Core Skill: Rotate Array Right by K Positions
View Challenge →
Circular Shift Roster
During the CodeBhavya Placement Sprint, the Circular Shift Roster challenge tests careful problem solving. Implement a reliable solution to rotate an array to the right by K positions.
🎯 Your Task
Rotate an array to the right by k positions.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
5 2 1 2 3 4 5
4 5 1 2 3
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
void reverse(int a[], int left, int right)
{
while(left < right)
{
int temp = a[left];
a[left] = a[right];
a[right] = temp;
left++;
right--;
}
}
int main()
{
int n, k;
scanf("%d %d", &n, &k);
int a[n];
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
k = k % n;
reverse(a, 0, n - 1);
reverse(a, 0, k - 1);
reverse(a, k, n - 1);
for(int i = 0; i < n; i++)
printf("%d ", a[i]);
return 0;
}
CHALLENGE 07AdvancedUnique Badge Character
Core Skill: First Non-Repeating Character
View Challenge →
Unique Badge Character
During the CodeBhavya Placement Sprint, the Unique Badge Character challenge tests careful problem solving. Implement a reliable solution to determine the first character that appears only once in a string.
🎯 Your Task
Determine the first character that appears only once in a string.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
swiss
w
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
char str[100];
int freq[256] = {0};
scanf("%99s", str);
for(int i = 0; str[i] != '\0'; i++)
freq[(unsigned char)str[i]]++;
for(int i = 0; str[i] != '\0'; i++)
{
if(freq[(unsigned char)str[i]] == 1)
{
printf("%c", str[i]);
return 0;
}
}
printf("No unique character");
return 0;
}
CHALLENGE 08Intermediate+Team Code Anagram Check
Core Skill: Check Anagram
View Challenge →
Team Code Anagram Check
During the CodeBhavya Placement Sprint, the Team Code Anagram Check challenge tests careful problem solving. Implement a reliable solution to determine whether two strings are anagrams of each other.
🎯 Your Task
Determine whether two strings are anagrams of each other.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
listen silent
Anagram
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <string.h>
int main()
{
char a[100], b[100];
int freq[256] = {0};
scanf("%99s", a);
scanf("%99s", b);
if(strlen(a) != strlen(b))
{
printf("Not Anagram");
return 0;
}
for(int i = 0; a[i] != '\0'; i++)
{
freq[(unsigned char)a[i]]++;
freq[(unsigned char)b[i]]--;
}
for(int i = 0; i < 256; i++)
{
if(freq[i] != 0)
{
printf("Not Anagram");
return 0;
}
}
printf("Anagram");
return 0;
}
CHALLENGE 09Advanced+Notice Word Reversal
Core Skill: Reverse Words in a String
View Challenge →
Notice Word Reversal
During the CodeBhavya Placement Sprint, the Notice Word Reversal challenge tests careful problem solving. Implement a reliable solution to reverse the order of words in a sentence.
🎯 Your Task
Reverse the order of words in a sentence.
📥 Input Format
Read the required string, sentence or character data exactly as described.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
C is powerful
powerful is C
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
#include <string.h>
int main()
{
char str[200];
char words[50][50];
int count = 0;
fgets(str, sizeof(str), stdin);
char *token = strtok(str, " \n");
while(token != NULL)
{
strcpy(words[count++], token);
token = strtok(NULL, " \n");
}
for(int i = count - 1; i >= 0; i--)
printf("%s ", words[i]);
return 0;
}
CHALLENGE 10ModerateMirror Candidate Number
Core Skill: Check Palindrome Number
View Challenge →
Mirror Candidate Number
During the CodeBhavya Placement Sprint, the Mirror Candidate Number challenge tests careful problem solving. Implement a reliable solution to determine whether a number is a palindrome.
🎯 Your Task
Determine whether a number is a palindrome.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
1221
Palindrome
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, original, reverse = 0;
scanf("%d", &n);
original = n;
while(n > 0)
{
reverse = reverse * 10 + n % 10;
n /= 10;
}
if(original == reverse)
printf("Palindrome");
else
printf("Not Palindrome");
return 0;
}
CHALLENGE 11IntermediateCube-Sum ID Check
Core Skill: Armstrong Number
View Challenge →
Cube-Sum ID Check
During the CodeBhavya Placement Sprint, the Cube-Sum ID Check challenge tests careful problem solving. Implement a reliable solution to determine whether a three-digit number is an Armstrong number.
🎯 Your Task
Determine whether a three-digit number is an armstrong number.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
153
Armstrong
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, original, sum = 0;
scanf("%d", &n);
original = n;
while(n > 0)
{
int digit = n % 10;
sum += digit * digit * digit;
n /= 10;
}
if(sum == original)
printf("Armstrong");
else
printf("Not Armstrong");
return 0;
}
CHALLENGE 12Intermediate+Prime Screening Window
Core Skill: Prime Numbers in a Range
View Challenge →
Prime Screening Window
During the CodeBhavya Placement Sprint, the Prime Screening Window challenge tests careful problem solving. Implement a reliable solution to produce all prime numbers between L and R.
🎯 Your Task
Produce all prime numbers between l and r.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
10 20
11 13 17 19
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int isPrime(int n)
{
if(n < 2)
return 0;
for(int i = 2; i * i <= n; i++)
{
if(n % i == 0)
return 0;
}
return 1;
}
int main()
{
int l, r;
scanf("%d %d", &l, &r);
for(int i = l; i <= r; i++)
{
if(isPrime(i))
printf("%d ", i);
}
return 0;
}
CHALLENGE 13ModerateInterview GCD Utility
Core Skill: GCD of Two Numbers
View Challenge →
Interview GCD Utility
During the CodeBhavya Placement Sprint, the Interview GCD Utility challenge tests careful problem solving. Implement a reliable solution to determine the greatest common divisor of two integers.
🎯 Your Task
Determine the greatest common divisor of two integers.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
48 18
6
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
while(b != 0)
{
int temp = b;
b = a % b;
a = temp;
}
printf("%d", a);
return 0;
}
CHALLENGE 14IntermediateBinary Badge Converter
Core Skill: Decimal to Binary
View Challenge →
Binary Badge Converter
During the CodeBhavya Placement Sprint, the Binary Badge Converter challenge tests careful problem solving. Implement a reliable solution to convert a decimal number to binary without using library conversion functions.
🎯 Your Task
Convert a decimal number to binary without using library conversion functions.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
13
1101
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
int binary[32];
int i = 0;
scanf("%d", &n);
if(n == 0)
{
printf("0");
return 0;
}
while(n > 0)
{
binary[i++] = n % 2;
n /= 2;
}
while(i > 0)
printf("%d", binary[--i]);
return 0;
}
CHALLENGE 15Intermediate+Active Skill Bit Counter
Core Skill: Count Set Bits
View Challenge →
Active Skill Bit Counter
During the CodeBhavya Placement Sprint, the Active Skill Bit Counter challenge tests careful problem solving. Implement a reliable solution to count the number of set bits in a positive integer.
🎯 Your Task
Count the number of set bits in a positive integer.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
Use non-negative 32-bit integer values unless a specific bit width is stated.
29
4
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
unsigned int n;
int count = 0;
scanf("%u", &n);
while(n)
{
n = n & (n - 1);
count++;
}
printf("%d", count);
return 0;
}
CHALLENGE 16Intermediate+Duplicate Candidate ID
Core Skill: Find Duplicate Number
View Challenge →
Duplicate Candidate ID
During the CodeBhavya Placement Sprint, the Duplicate Candidate ID challenge tests careful problem solving. Implement a reliable solution to an array contains numbers from 1 to N-1 and exactly one number appears twice. Find the duplicate.
🎯 Your Task
An array contains numbers from 1 to n-1 and exactly one number appears twice. find the duplicate.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
5 1 3 4 2 3
3
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int a[n];
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
for(int i = 0; i < n; i++)
{
for(int j = i + 1; j < n; j++)
{
if(a[i] == a[j])
{
printf("%d", a[i]);
return 0;
}
}
}
return 0;
}
CHALLENGE 17AdvancedTarget Package Pair
Core Skill: Find Pair with Given Sum
View Challenge →
Target Package Pair
During the CodeBhavya Placement Sprint, the Target Package Pair challenge tests careful problem solving. Implement a reliable solution to determine whether two elements in an array add up to a given target value.
🎯 Your Task
Determine whether two elements in an array add up to a given target value.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
5 9 2 7 11 15 1
2 7
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n, target;
scanf("%d %d", &n, &target);
int a[n];
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
for(int i = 0; i < n; i++)
{
for(int j = i + 1; j < n; j++)
{
if(a[i] + a[j] == target)
{
printf("%d %d", a[i], a[j]);
return 0;
}
}
}
printf("No Pair");
return 0;
}
CHALLENGE 18Intermediate+Score Frequency Report
Core Skill: Frequency of Array Elements
View Challenge →
Score Frequency Report
During the CodeBhavya Placement Sprint, the Score Frequency Report challenge tests careful problem solving. Implement a reliable solution to produce the frequency of every distinct element in an array.
🎯 Your Task
Produce the frequency of every distinct element in an array.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
6 2 3 2 4 3 2
2 - 3 3 - 2 4 - 1
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int a[n];
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
for(int i = 0; i < n; i++)
{
int already = 0;
for(int j = 0; j < i; j++)
{
if(a[i] == a[j])
{
already = 1;
break;
}
}
if(already)
continue;
int count = 0;
for(int j = 0; j < n; j++)
{
if(a[i] == a[j])
count++;
}
printf("%d - %d\n", a[i], count);
}
return 0;
}
CHALLENGE 19AdvancedThree-Bucket Sort Challenge
Core Skill: Sort 0s, 1s and 2s
View Challenge →
Three-Bucket Sort Challenge
During the CodeBhavya Placement Sprint, the Three-Bucket Sort Challenge challenge tests careful problem solving. Implement a reliable solution to sort an array containing only 0, 1 and 2 without using a general sorting algorithm.
🎯 Your Task
Sort an array containing only 0, 1 and 2 without using a general sorting algorithm.
📥 Input Format
Read the required value or values from standard input in the order shown in the example.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
6 2 0 2 1 1 0
0 0 1 1 2 2
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int count[3] = {0};
for(int i = 0; i < n; i++)
{
int x;
scanf("%d", &x);
if(x >= 0 && x <= 2)
count[x]++;
}
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < count[i]; j++)
printf("%d ", i);
}
return 0;
}
CHALLENGE 20HardFinal Skyline Leader Challenge
Core Skill: Leaders in Array
View Challenge →
Final Skyline Leader Challenge
During the CodeBhavya Placement Sprint, the Final Skyline Leader Challenge challenge tests careful problem solving. Implement a reliable solution to an element is called a leader if it is greater than every element to its right. Print all leaders.
🎯 Your Task
An element is called a leader if it is greater than every element to its right. print all leaders.
📥 Input Format
Read N first, followed by the N array values; read any additional value such as K or target when required.
📤 Output Format
Print only the required result in the exact format shown in the example output.
📏 Constraints
1 ≤ N ≤ 1000 for array challenges; values fit in a 32-bit signed integer unless stated.
6 16 17 4 3 5 2
17 5 2
C Code Editor
Sample Input
Program Output
Run your program to see the output.
Test Cases
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int a[n];
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
int leaders[n];
int count = 0;
int maximum = a[n - 1];
leaders[count++] = maximum;
for(int i = n - 2; i >= 0; i--)
{
if(a[i] > maximum)
{
maximum = a[i];
leaders[count++] = a[i];
}
}
for(int i = count - 1; i >= 0; i--)
printf("%d ", leaders[i]);
return 0;
}