Get Off-Campus Placement Jobs Info !!!
Programs asked in Mettl Coding Round
Click To Practce List of Programs asked in Nagarro !!!

Program Discussion :: Basics

Home > Programs > Basics

10 / 248

Write a program using sizeof and strlen.

Answer:

#include

#include
int main() 
{
    char str[50];
    printf("\nEnter a string: ");
    scanf("%s",str);
    printf("\nSize of the string is: %d",sizeof(str));  //sizeof() operator gives the size in bytes.
    printf("\nLength of the string is: %d",strlen(str));    //strlen() function gives the length of the whole string.
    return 0;
}

Asked In :: Syntel Inc.

Post Your Answer Here:

Language:

Post Your Reply Here: