Write a single line c expression to delete a,b,c from aabbcc

Answers were Sorted based on User's Feedback



Write a single line c expression to delete a,b,c from aabbcc..

Answer / shirley

in arrays:

char a[6]="aabbcc";
for(i=0;i<3;i+=2)
a[i]=a[i+2];
a[i+1]='\0';

using pointers:

*s="aabbcc"
for(i=0;i<3;i++)
*(s+i)=*(s+i+2);
*(s+i+1)='\0';

Is This Answer Correct ?    10 Yes 7 No

Write a single line c expression to delete a,b,c from aabbcc..

Answer / arihant jain

printf("%s\b\b\b\b\b\b \b\b\b\b\b\babc","aabbcc");

Is This Answer Correct ?    5 Yes 2 No

Post New Answer

More C Code Interview Questions

main() { int i =10, j = 20; clrscr(); printf("%d, %d, ", j-- , --i); printf("%d, %d ", j++ , ++i); } a. 20, 10, 20, 10 b. 20, 9, 20, 10 c. 20, 9, 19, 10 d. 19, 9, 20, 10

4 Answers   HCL,


void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(ā€œ%dā€, i); }

2 Answers  


Write a C program to add two numbers before the main function is called.

11 Answers   Infotech, TC,


how to concatenate the two strings

1 Answers  


main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); }

1 Answers  






main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; printf("\n%d %d %d",a,*f1,*f2); }

6 Answers  


Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.

2 Answers   Wipro,


main() { int i=10; i=!i>14; Printf ("i=%d",i); }

1 Answers  


main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }

6 Answers  


In a gymnastic competition, scoring is based on the average of all scores given by the judges excluding the maximum and minimum scores. Let the user input the number of judges, after that, input the scores from the judges. Output the average score. Note: In case, more than two judges give the same score and it happens that score is the maximum or minimum then just eliminate two scores. For example, if the number of judges is 5 and all of them give 10 points each. Then the maximum and minimum score is 10. So the computation would be 10+10+10, this time. The output should be 10 because 30/3 is 10.

0 Answers   TCS,


To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']

0 Answers  


Write a Program that Inputs 10 Numbers in an Array and Show the Maximum Number

2 Answers   Ace Info,


Categories