Public · Protected · Private
problems2
Type: Public  |  Created: 2026-09-14  |  Frozen: No
« Previous Public Blog
Comments
  • Age in Days: Ask the user to enter their age in years, then calculate and print roughly how many days old they are (age * 365).

    Rectangle Perimeter & Area: Prompt for the length and width of a room as integers. Output both its perimeter ($2 \times (l + w)$) and area ($l \times w$).

    Candy Splitter: Enter total candies and the number of friends. Use / to show how many each person gets, and % (modulus) to display how many are left over.

    Time Converter: Ask for a total number of minutes (e.g., 145) and convert it into hours and remaining minutes (e.g., "2 hours and 25 minutes").


    Split the Dinner Bill: Enter the total restaurant bill and number of diners. Calculate and print each person’s share formatted to two decimal places.

    Temperature Converter: Take a temperature in Celsius as a float and convert it to Fahrenheit using $F = (C \times 9.0 / 5.0) + 32.0$.

    Circle Calculator: Input the radius of a circle as a float. Compute and display both the circumference ($2 \times 3.14159 \times r$) and area ($3.14159 \times r^2$).

    Simple Interest: Ask for principal amount, annual interest rate (e.g., 5.5%), and time in years. Calculate simple interest: $(P \times R \times T) / 100$.




    1. Secret ASCII Decoder: Input a single character and print both the character and its hidden numerical ASCII value (%d).
    2. Case Switcher: Take a lowercase character (like 'a') and convert it to uppercase ('A') by subtracting 32 from its ASCII code.
    3. Next in Line: Read a letter from the keyboard and print the letter that immediately follows it in the alphabet (e.g., 'b' follows 'a').
    4. Vowel or Consonant: Read one lowercase letter and use a simple if-else statement to determine whether it is a vowel (a, e, i, o, u) or a consonant.




    Greeting Generator: Take a user's first name as a string and print a custom banner message: *** Welcome, [Name]! ***.

    Character Count (No Library): Input a word and write a while loop that counts how many letters it contains until it encounters the null terminator '\0'.

    Initials Extractor: Read a first name and last name as two separate strings, then print the user's initials (e.g., "John Doe" $\rightarrow$ "J.D.").

    Reverse a Word: Enter a short word (like "code") and print it backward letter-by-letter ("edoc").




    Supermarket Receipt: Ask for an item code (char), quantity (int), and price per unit (float). Print a formatted receipt line showing the total cost.

    Student Grade Card: Input a student's name (string), roll number (int), and three exam scores (float). Print their details along with their final average percentage.

    Digit Sum Extractor: Take a 3-digit integer (e.g., 456), extract each digit using / and %, and calculate their sum ($4 + 5 + 6 = 15$).

    Mini ATM Simulator: Set a starting bank balance as a float. Prompt the user to deposit or withdraw an amount, check if funds are sufficient, and display the updated balance.

    2026-09-14 18:38
  • 1. Age in Days

    C


    #include <stdio.h>
    
    int main() {
        int age, days;
    
        printf("Enter your age in years: ");
        scanf("%d", &age);
    
        days = age * 365;
    
        printf("You are approximately %d days old!\n", days);
        return 0;
    }
    

    2. Rectangle Perimeter & Area

    C


    #include <stdio.h>
    
    int main() {
        int length, width;
    
        printf("Enter length and width: ");
        scanf("%d %d", &length, &width);
    
        int perimeter = 2 * (length + width);
        int area = length * width;
    
        printf("Perimeter: %d\n", perimeter);
        printf("Area: %d\n", area);
        return 0;
    }
    

    3. Candy Splitter

    C


    #include <stdio.h>
    
    int main() {
        int candies, friends;
    
        printf("Enter total candies: ");
        scanf("%d", &candies);
        printf("Enter number of friends: ");
        scanf("%d", &friends);
    
        int each = candies / friends;
        int leftover = candies % friends;
    
        printf("Each friend gets: %d candies\n", each);
        printf("Leftover candies: %d\n", leftover);
        return 0;
    }
    

    4. Time Converter

    C


    #include <stdio.h>
    
    int main() {
        int total_minutes;
    
        printf("Enter total minutes: ");
        scanf("%d", &total_minutes);
    
        int hours = total_minutes / 60;
        int minutes = total_minutes % 60;
    
        printf("%d minutes = %d hour(s) and %d minute(s)\n", total_minutes, hours, minutes);
        return 0;
    }
    

    Level 2: Floating-Point Math (float, %.2f)

    5. Split the Dinner Bill

    C


    #include <stdio.h>
    
    int main() {
        float bill;
        int people;
    
        printf("Enter total bill amount: ");
        scanf("%f", &bill);
        printf("Enter number of people: ");
        scanf("%d", &people);
    
        float share = bill / people;
    
        printf("Each person pays: $%.2f\n", share);
        return 0;
    }
    

    6. Temperature Converter

    C


    #include <stdio.h>
    
    int main() {
        float celsius, fahrenheit;
    
        printf("Enter temperature in Celsius: ");
        scanf("%f", &celsius);
    
        fahrenheit = (celsius * 9.0 / 5.0) + 32.0;
    
        printf("%.2f C is equal to %.2f F\n", celsius, fahrenheit);
        return 0;
    }
    

    7. Circle Calculator

    C


    #include <stdio.h>
    
    int main() {
        float radius;
        const float PI = 3.14159;
    
        printf("Enter radius of the circle: ");
        scanf("%f", &radius);
    
        float circumference = 2 * PI * radius;
        float area = PI * radius * radius;
    
        printf("Circumference: %.2f\n", circumference);
        printf("Area: %.2f\n", area);
        return 0;
    }
    

    8. Simple Interest

    C


    #include <stdio.h>
    
    int main() {
        float principal, rate, time;
    
        printf("Enter Principal, Rate (%%), and Time (years): ");
        scanf("%f %f %f", &principal, &rate, &time);
    
        float interest = (principal * rate * time) / 100.0;
    
        printf("Simple Interest earned: %.2f\n", interest);
        printf("Total Amount: %.2f\n", principal + interest);
        return 0;
    }
    

    Level 3: Characters & ASCII Codes (char, %c)

    9. Secret ASCII Decoder

    C


    #include <stdio.h>
    
    int main() {
        char ch;
    
        printf("Enter any character: ");
        scanf(" %c", &ch); // Leading space avoids reading leftover newlines
    
        printf("Character: '%c'\n", ch);
        printf("ASCII Value: %d\n", ch);
        return 0;
    }
    

    10. Case Switcher

    C


    #include <stdio.h>
    
    int main() {
        char lower;
    
        printf("Enter a lowercase letter: ");
        scanf(" %c", &lower);
    
        // In ASCII, uppercase letters are 32 positions before lowercase
        char upper = lower - 32;
    
        printf("Uppercase: %c\n", upper);
        return 0;
    }
    

    11. Next in Line

    C


    #include <stdio.h>
    
    int main() {
        char ch;
    
        printf("Enter a letter: ");
        scanf(" %c", &ch);
    
        char next = ch + 1;
    
        printf("The next letter is: %c\n", next);
        return 0;
    }
    

    12. Vowel or Consonant

    C


    #include <stdio.h>
    
    int main() {
        char ch;
    
        printf("Enter a lowercase letter: ");
        scanf(" %c", &ch);
    
        if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
            printf("'%c' is a vowel.\n", ch);
        } else {
            printf("'%c' is a consonant.\n", ch);
        }
        return 0;
    }
    

    Level 4: Strings & Word Play (char[], %s)

    13. Greeting Generator

    C


    #include <stdio.h>
    
    int main() {
        char name[50];
    
        printf("Enter your first name: ");
        scanf("%s", name);
    
        printf("*******************************\n");
        printf("   Welcome to Coding, %s!      \n", name);
        printf("*******************************\n");
        return 0;
    }
    


    2026-09-14 19:06
  • 14. Character Count (No Library)

    C


    #include <stdio.h>
    
    int main() {
        char word[100];
        int count = 0;
    
        printf("Enter a single word: ");
        scanf("%s", word);
    
        // Loop until we reach the null character '\0'
        while (word[count] != '\0') {
            count++;
        }
    
        printf("The word \"%s\" has %d characters.\n", word, count);
        return 0;
    }
    

    15. Initials Extractor

    C


    #include <stdio.h>
    
    int main() {
        char first[50], last[50];
    
        printf("Enter first and last name: ");
        scanf("%s %s", first, last);
    
        // The first character of each string is at index 0
        printf("Initials: %c.%c.\n", first[0], last[0]);
        return 0;
    }
    

    16. Reverse a Word

    C


    #include <stdio.h>
    
    int main() {
        char word[100];
        int length = 0;
    
        printf("Enter a word to reverse: ");
        scanf("%s", word);
    
        // 1. Find the length
        while (word[length] != '\0') {
            length++;
        }
    
        // 2. Print backwards starting from the last valid character
        printf("Reversed: ");
        for (int i = length - 1; i >= 0; i--) {
            printf("%c", word[i]);
        }
        printf("\n");
    
        return 0;
    }
    

    Level 5: Mixed Types & Mini-Projects

    17. Supermarket Receipt

    C


    #include <stdio.h>
    
    int main() {
        char item_code;
        int qty;
        float unit_price;
    
        printf("Enter Item Code (single character): ");
        scanf(" %c", &item_code);
    
        printf("Enter Quantity: ");
        scanf("%d", &qty);
    
        printf("Enter Unit Price: ");
        scanf("%f", &unit_price);
    
        float total = qty * unit_price;
    
        printf("\n--- STORE RECEIPT ---\n");
        printf("Item Code : %c\n", item_code);
        printf("Quantity  : %d\n", qty);
        printf("Unit Price: $%.2f\n", unit_price);
        printf("Total Due : $%.2f\n", total);
        printf("---------------------\n");
    
        return 0;
    }
    

    18. Student Grade Card

    C


    #include <stdio.h>
    
    int main() {
        char name[50];
        int roll_no;
        float m1, m2, m3;
    
        printf("Enter student name: ");
        scanf("%s", name);
    
        printf("Enter roll number: ");
        scanf("%d", &roll_no);
    
        printf("Enter 3 subject marks (out of 100): ");
        scanf("%f %f %f", &m1, &m2, &m3);
    
        float average = (m1 + m2 + m3) / 3.0;
    
        printf("\n--- REPORT CARD ---\n");
        printf("Name    : %s\n", name);
        printf("Roll No : %d\n", roll_no);
        printf("Average : %.2f%%\n", average);
        return 0;
    }
    

    19. Digit Sum Extractor

    C


    #include <stdio.h>
    
    int main() {
        int num;
    
        printf("Enter a 3-digit number (e.g., 456): ");
        scanf("%d", &num);
    
        int d3 = num % 10;        // Last digit (6)
        int d2 = (num / 10) % 10; // Middle digit (5)
        int d1 = num / 100;       // First digit (4)
    
        int sum = d1 + d2 + d3;
    
        printf("Digits: %d + %d + %d\n", d1, d2, d3);
        printf("Sum: %d\n", sum);
        return 0;
    }
    

    20. Mini ATM Simulator

    C


    #include <stdio.h>
    
    int main() {
        float balance = 500.0; // Initial bank balance
        int choice;
        float amount;
    
        printf("Current Balance: $%.2f\n", balance);
        printf("1. Deposit\n2. Withdraw\nChoose (1 or 2): ");
        scanf("%d", &choice);
    
        if (choice == 1) {
            printf("Enter deposit amount: ");
            scanf("%f", &amount);
            balance += amount;
            printf("Deposit successful! New Balance: $%.2f\n", balance);
        } else if (choice == 2) {
            printf("Enter withdrawal amount: ");
            scanf("%f", &amount);
            if (amount <= balance) {
                balance -= amount;
                printf("Withdrawal successful! Remaining Balance: $%.2f\n", balance);
            } else {
                printf("Insufficient funds! Transaction cancelled.\n");
            }
        } else {
            printf("Invalid option.\n");
        }
    
        return 0;
    }
    


    2026-09-14 19:06