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() { 41printf("%p",main); }8

1 Answers  


void main() { int i=10, j=2; int *ip= &i, *jp = &j; int k = *ip/*jp; printf(“%d”,k); }

1 Answers  


main() { struct student { char name[30]; struct date dob; }stud; struct date { int day,month,year; }; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month, &student.dob.year); }

1 Answers  


main() { int i=-1; +i; printf("i = %d, +i = %d \n",i,+i); }

1 Answers  


main() { int x=5; clrscr(); for(;x==0;x--) { printf("x=%d\n”", x--); } } a. 4, 3, 2, 1, 0 b. 1, 2, 3, 4, 5 c. 0, 1, 2, 3, 4 d. none of the above

3 Answers   HCL,






#include<stdio.h> main() { char s[]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32); }

2 Answers   CNSI,


main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }

7 Answers  


main() { char *str1="abcd"; char str2[]="abcd"; printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); }

1 Answers  


main() { static int var = 5; printf("%d ",var--); if(var) main(); }

1 Answers  


Finding a number multiplication of 8 with out using arithmetic operator

8 Answers   Eyeball, NetApp,


main( ) { char *q; int j; for (j=0; j<3; j++) scanf(“%s” ,(q+j)); for (j=0; j<3; j++) printf(“%c” ,*(q+j)); for (j=0; j<3; j++) printf(“%s” ,(q+j)); }

1 Answers  


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

2 Answers  


Categories