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.
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 |
swapping of two numbers without using third variable using AND and OR operators
What is a void pointer? When is a void pointer used?
What do you mean by scope of a variable in c?
write an algorithm and a program to count the number of elements in a circularly singly linked list
How can I read a binary data file properly?
What are the types of arrays in c?
What is spark map function?
How do you prevent buffer overflows in C?
Write a program with dynamically allocation of variable.
Here is alphabets : abcdefgh 1) how to reverse. as hgfedcba 2) after reversal, how to group them in a pair hg fe dc ba.
What is s or c?
What is external variable in c?