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=5; printf(“%d”,i=++i ==6); }

1 Answers  


main(int argc, char *argv[]) { (main && argc) ? main(argc-1, NULL) : return 0; } a. Runtime error. b. Compile error. Illegal syntax c. Gets into Infinite loop d. None of the above

4 Answers   HCL, LG,


main() { char name[10],s[12]; scanf(" \"%[^\"]\"",s); } How scanf will execute?

2 Answers  


#define int char main() { int i=65; printf("sizeof(i)=%d",sizeof(i)); }

1 Answers  


Write a program to print a square of size 5 by using the character S.

6 Answers   Microsoft,






respected sir, i did my MCA in 2013 when i am going to attend to an interview i was asked about my project how will i explain my project could please help me in this and my project title is "Social Networking Site For Social Responsibility"

1 Answers   Genpact, Ozdocs,


main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); } int i;

1 Answers  


main() { char *p = “ayqm”; printf(“%c”,++*(p++)); }

29 Answers   IBM, TCS, UGC NET, Wipro,


main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }

2 Answers  


struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf("origin is(%d%d)\n",(*pp).x,(*pp).y); printf("origin is (%d%d)\n",pp->x,pp->y); }

1 Answers  


#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }

2 Answers  


main() { char *cptr,c; void *vptr,v; c=10; v=0; cptr=&c; vptr=&v; printf("%c%v",c,v); }

1 Answers  


Categories