a problem of C

Input

You are given a single line of text, with length at most 1000
characters. The text consists of English words. Adjacent words in the
line are separated by a single space.

The second line consists of a single integer ‘N’ denoting the width of
an output line.

Output

Print the input text in the following format:

  1. no line of output must be more than N characters long.
  2. no word can be split across two lines. If a word does not
    completely fit in a line, move the word to the next line.

Sample Input

O SOFT embalmer of the still midnight Shutting with careful fingers
34

Sample Output

O SOFT embalmer of the still
midnight Shutting with careful
fingers

Explanation

Each output line is at most 34 characters long. “midnight” does not
fit on the first line, hence it was moved to the second
line. “fingers” does not fit on the second line, hence it was moved
to the third line.

hey are you finding NPTEL programs answers
we can answer the test together as i am also an participant
can you please share your mail id

#include<stdio.h>
#include<string.h>

int next(char *a, int i)
{
int size = 0;

for(i=+1; a[i] != ' '; i++)
{
    size++;
}

return size;

}

int main()
{
char a[1001];
int j, n, k, i=0;

scanf("%[^\n]s", a);

//printf("%s", a);

scanf("%d", &n);

//printf("%d", n);

while(i<strlen(a))
{
    if(i+n >=strlen(a))
    {
        for(j=i; j<strlen(a); j++)
            printf("%c", a[j]);
        break;
    }
    if(a[i+n]==' '){
        for(j=i; j<i+n; j++)
            printf("%c", a[j]);
        printf("\n");
        i=j;
    }
    else
    {
        for(k = i+n; ; k--)
            if(a[k] == ' ')
                break;
        for(j=i; j<=k; j++)
            printf("%c", a[j]);
        printf("\n");
        i=k+1;
    }
}

return 0;

}

bhai jldi krle!!! :slight_smile:

#include <stdio.h>
#include <string.h>

int main(void) {
char c[1001]; int j, n, k, i=0;

scanf("%[^\n]s", c);

scanf("%d", &n);
int len = strlen©;

while(i < len )
{
if(i+n >=len)
{
for(j=i; j<len; j++)
printf("%c", c[j]);
break;
}
if(c[i+n] == ’ '){
for(j=i; j<i+n; j++)
printf("%c", c[j]);
printf("\n");
i=j;
}
else
{
for(k = i+n; ; k–)
if(c[k] == ’ ')
break;
for(j=i; j<=k; j++)
printf("%c", c[j]);
printf("\n");
i=k+1;
}
}

return 0;

}

any1 having answers for remainig codes

You are the encoded form of a data string as follows: consecutive
occurrences of a letter (up to 9) are represented by the letter
followed by the number of occurrences.

For example, the string

a9a3b2c4de

stands for the string

aaaaaaaaaaaabbccccdc

  • that is, 12 consecutive occurrences of a, followed by 2 bs, and then
    4 cs, followed by a d and finally c

Given an encoded form, you have to output the data string.

Input

The encoded form of the string, made as per the following rules.

  1. If a character occurs only once, then in the encoded string, it
    appears as such (for example, ‘d’ in the above string.)
  2. If the number of consecutive occurrences of the character is
    between 2 and 9, then it is represented as the character followed
    by the number of occurrences (e.g. aaaab is represented as a4b).
  3. If the number of consecutive occurrences of a character is greater
    than 9, then group 9 occurrences as per rule 2. Iterate the set of
    rules on the remaining string.

Output

The original string, consisting only of characters whose
encoding was given as input.

You are given an array ‘a’ of integers. You will then be given a
starting index, ‘s’ and ending index, ‘e’. You have to find the
maximum element in the in the subarray from a[s]…a[e].

Input format

First, you will be given a positive integer N <= 100 which indicates
the number of elements in the array.

This will be followed by N integers.

Then you will be given a starting index s and and an end index e. You
can assume that 0 <= s <= e <= N-1.

Output format

You have to print the maximum element in the subarray starting with
index s, and ending with index e, both indices included.

Can I join with you guys Mr nptel introduction to c programming language toppers.
My mail id is valetisandeepkumar@gmail.com.

please mention the link of the question , often noticed that online contest questions going in some part of the world are posted as such.