I have an array of 100 elements. Each element contains some
text. i want to:
append a star character to the end of every fifth element
remove every second character from every tenth element,
and…
add a line feed (ascii 10) after the 30th character of
every array element whose length is greater than 30
characters.



I have an array of 100 elements. Each element contains some text. i want to: append a star chara..

Answer / ravi joshi

int process_str()
{
int i, j;
char *ptr[100] = {"some text here"};
int len = 100;

for(i = 0; i < len; i++)
{
if(!(i % 5))
{
// process fifth element
}
elseif(!(i % 10))
{
// process 10th element
}
elseif(!(i % 30))
{
// process 30th element
}
}
}

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

How do I access command-line arguments?

2 Answers   Bosch, Wipro,


What is the function of volatile in c language?

0 Answers  


Why do we need arrays in c?

0 Answers  


Rapunzel walks into the forest of forgetfullness. She meets a Lion who lies on Monday Tuesdays and Wednesdays and meets a rabbit who lies on Thurs fridays and saturdays . On that day both say that "I lied yesterday". What day is it .

3 Answers   TCS,


Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.

0 Answers  






What is variable and explain rules to declare variable in c?

0 Answers  


Every time i run a c-code in editor, getting some runtime error and editor is disposing, even after reinstalling the software what may be the problem?

2 Answers  


What is meant by realloc()?

0 Answers  


how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software

0 Answers  


What is a macro?

0 Answers  


The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?

0 Answers  


What are pragmas and what are they good for?

0 Answers  


Categories