What will be the output ?

void main()
{
    char ch[40]={'p','g','\0','d','c','a'};
    int len=strlen(ch);
    printf("string =%s and length of the string =%d",ch,len);
  
}


Output : string =pg and length of the string =2
Explanation: String ends with  null character.


 void main()
{
    static int a[19];
    clrscr();
    printf("%d",sizeof(a));
    return;
}
Output: 38
Explanation: size of int a[19] =19*2=38

No comments:

Post a Comment

Related Post

Array:
String functions:
General (Loops-for/while)
Write a Program to print reverse of a given number Write a Program to print Product of Digits (eg. 212=2*1*2=4) of a given number Write a C++ Program to Convert Binary into Decimal Number