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

#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b); }

7 Answers   Infosys,


program to print upper & lower triangle of a matrix

2 Answers   TCS,


What does the characters “r” and “w” mean when writing programs that will make use of files?

0 Answers  


What is local and global variable in c?

0 Answers  


What is the sizeof () a pointer?

0 Answers  






What is the best way to store flag values in a program?

0 Answers  


int i=0,j; j=++i + ++i ++i; printf(" %d",j);

2 Answers   ME,


The C language terminator is a.semicolon b.colon c.period d.exclamation mark

6 Answers   TCS,


An array name contains base address of the array. Can we change the base address of the array?

4 Answers   NMIMS, Wipro,


What is ambagious result in C? explain with an example.

0 Answers   Infosys,


Explain a file operation in C with an example.

0 Answers   Amdocs,


Tell us two differences between new () and malloc ()?

0 Answers   Adobe,


Categories