TCS
Company
Programming
Program
what will be the o/p of the program
main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("n%c%c%c%c",s[i ],*(s+i),*(i+s),i[s]);
}
Read Solution (Total 21)
-
- Output :
mmmm
aaaa
nnnn
Assume the base address of s=1000 ... so address of s[0]=1000, s[1]= 1001, s[2]=1002
s[0]=m, s[1]=a, s[2]=n
s[i] => s[0] = m
*(s+i) => *(1000+ 0) = *(s) => m
+(i+s) => *(0+1000) = *(S) => m
i[s] is equal to s[i]... both are equal... So for 1st iteration, all ll print "m", nd 2nd iteration it ll print "a" nd 3rd it ll print "n"...
Hence mmmm, nnnn, aaaa
- 10 years agoHelpfull: Yes(33) No(7)
- nmmmm,naaaa,nnnnn
- 10 years agoHelpfull: Yes(10) No(0)
- o/p
nmmmmnaaaannnnn
s[i],*(s+i),*(i+s),i[s] these all are same....... - 10 years agoHelpfull: Yes(1) No(0)
- nmmmmnaaaannnnn
- 10 years agoHelpfull: Yes(1) No(0)
- it will be
nmmmmnaaaannnnn
because for i=0 it will be = nmmmm (n is coming from "n.....")
for i=1 it will be = naaaa(again n is coming from "n.....")
for i=2 it will be= nnnnn (again n is coming from "n....")
so o/p = nmmmmnaaaannnnn - 10 years agoHelpfull: Yes(1) No(0)
- output: nmmmmnaaaaannnnn
- 10 years agoHelpfull: Yes(1) No(0)
- nmmmmnaaaannnnn
- 10 years agoHelpfull: Yes(1) No(0)
- sorry mmmm,aaaa,nnnn
- 10 years agoHelpfull: Yes(0) No(3)
- mmmm
aaaa
nnnn - 10 years agoHelpfull: Yes(0) No(0)
- output: mmmaaannn
- 10 years agoHelpfull: Yes(0) No(0)
- output -
nmmmmnaaaannnnn - 10 years agoHelpfull: Yes(0) No(0)
- mmmm
aaaa
nnnn
loop will iterate and print character one by one...condition is s[i]!=0 - 10 years agoHelpfull: Yes(0) No(0)
- print operation may be error
- 9 years agoHelpfull: Yes(0) No(0)
- nmmmmnaaaannnnn
- 9 years agoHelpfull: Yes(0) No(0)
- it will give error message because array defined of character types excepts value with ' '
- 9 years agoHelpfull: Yes(0) No(2)
- it will give error message because array defined of character types excepts value with ' '
- 9 years agoHelpfull: Yes(0) No(1)
- it will give error message because array defined of character types excepts value with ' '
- 9 years agoHelpfull: Yes(0) No(1)
- it will give error message because array defined of character types excepts value with ' '
- 9 years agoHelpfull: Yes(0) No(1)
- it will give error message because array defined of character types excepts value with ' '
- 9 years agoHelpfull: Yes(0) No(1)
- it will give error message because array defined of character types excepts value with ' '
- 9 years agoHelpfull: Yes(0) No(1)
- it will give error message because array defined of character types excepts value with ' '
- 9 years agoHelpfull: Yes(0) No(1)
TCS Other Question