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 Posted / 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 View All Answers
What is storage class?
Can we declare variables anywhere in c?
What is the explanation for prototype function in c?
using only #include
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
What is the size of a union variable?
cavium networks written test pattern ..
`write a program to display the recomended action depends on a color of trafic light using nested if statments
What is the use of void pointer and null pointer in c language?
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
Stimulate calculator using Switch-case-default statement for two numbers
Explain why can’t constant values be used to define an array’s initial size?
What is wild pointer in c with example?
What is #include called?
What are the different data types in C?