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 we select the big element or any other operation from array which is read dynamically. user need to give the elements only no need to mention the size.

0 Answers  


char ch="{'H','I',0};printf("%s",ch);what is output

9 Answers   Accenture,


1. main() { printf("%d",printf("HelloSoft")); } Output?

3 Answers   HCL,


Can the sizeof operator be used to tell the size of an array passed to a function?

0 Answers  


What is 2 d array in c?

0 Answers  


write a programme that inputs a number by user and gives its multiplication table.

2 Answers  


hello friends what do u mean by BUS ERROR i got this error while i am doing my program in DATA STRUCTURES

2 Answers   Wipro,


Write a program to print prime nums from 1-20 using c programing?

13 Answers   IBM,


Do you know what are bitwise shift operators in c programming?

0 Answers  


Write a program that his output 1 12 123

0 Answers  


# define x=1+4; main() { int x; printf("%d%d",x/2,x/4); }

5 Answers  


Explain how can I open a file so that other programs can update it at the same time?

0 Answers  


Categories