Skip to content

P069.c

Problem Statement

Write a program using user defined method to implement the following JAVA PROG Mastery -> JPM java prog mastery -> JPM Acharya Prafulla Chandra -> JPM

Metadata

Property Detail
Author Amit Dutta amitdutta4255@gmail.com
Date 14 Jan 2026
License MIT License (See the LICENSE file for details)
Difficulty Beginner (index: 2 / 10)

Concepts

Beta Feature

This concept detection system is still in beta and may occasionally show incorrect or incomplete results.

  • Recursion
  • Array
  • Iteration

Actions

Raw View on GitHub

You can print or save this file by opening Raw and using your browser.

Source Code

#include <stdio.h>
#include <ctype.h>

void _short_1(char str[])
{
    int i = 0, j = 0;
    char s[10];
    if (str[0] != '\0' && str[0] != ' ')
    {
        s[j] = toupper(str[j]);
        i++;
        j++;
    }
    while (str[i] != '\0')
    {
        if (str[i] == ' ')
        {
            s[j] = toupper(str[i + 1]);
            i++;
            j++;
        }
        i++;
    }
    s[j] = '\0';
    printf("\nResult 1: %s", s);
}

void _short_2(char str[])
{
    int i, j;
    char strnew[10];
    strnew[0] = toupper(str[0]);
    i = j = 1;
    while (str[i] != '\0')
    {
        if (str[i] == ' ')
        {
            strnew[j++] = toupper(str[i + 1]);
        }
        i++;
    }
    strnew[j] = '\0';
    printf("\nResult 2: %s", strnew);
}

int main()
{
    char str[30];
    printf("Enter the string: ");
    gets(str);
    _short_1(str);
    _short_2(str);
    return 0;
}

Explanation

Explain with AI

Copy the prompt below and paste it into any AI assistant.

    You are explaining a C programming code to a beginner.

    STRICT RULES:

    - Only use the given code. Do NOT assume anything not present.

    - Do NOT add extra examples.

    - Keep explanation clear and short.

    - If something is unclear, say "Not clear from code".

    - Follow the exact format below. Do NOT change headings.

    FORMAT:

    [START]

    ## What it does

    (Explain the overall purpose in 1-2 sentences)

    ## Step-by-step

    (Explain how the code works in steps, simple language)

    ## Key Concepts

    (List concepts like loop, condition, function, etc.)

    ## Notes

    (Mention any limitations, errors, or assumptions)

    [END]

    CODE (P069.c):

    #include <stdio.h>
    #include <ctype.h>

    void _short_1(char str[])
    {
        int i = 0, j = 0;
        char s[10];
        if (str[0] != '\0' && str[0] != ' ')
        {
            s[j] = toupper(str[j]);
            i++;
            j++;
        }
        while (str[i] != '\0')
        {
            if (str[i] == ' ')
            {
                s[j] = toupper(str[i + 1]);
                i++;
                j++;
            }
            i++;
        }
        s[j] = '\0';
        printf("\nResult 1: %s", s);
    }

    void _short_2(char str[])
    {
        int i, j;
        char strnew[10];
        strnew[0] = toupper(str[0]);
        i = j = 1;
        while (str[i] != '\0')
        {
            if (str[i] == ' ')
            {
                strnew[j++] = toupper(str[i + 1]);
            }
            i++;
        }
        strnew[j] = '\0';
        printf("\nResult 2: %s", strnew);
    }

    int main()
    {
        char str[30];
        printf("Enter the string: ");
        gets(str);
        _short_1(str);
        _short_2(str);
        return 0;
    }