C program string

C program find to length using (strlen)  string function : 


Example : 

Input :   atikurrahman

Output : length = 12




program code : 


#include<stdio.h>
#include<string.h>

int main()
{
    char nam[100];
    scanf("%s",&nam);
    int len;
    len=strlen(nam);
    printf("length = %d",len);

    return 0;
}


output :















c program find to length without (strlen ) string function :


Example : 

Input : atik

Output : length= 4

program code : 


#include<stdio.h>
int main(){
char nam[];
 printf("Enthe the valu :");
 scanf("%s",&nam);
int i;
for(i=0;nam[i]!='\0';i++){

}
printf("length= %d",i);
return 0;
}




Output : 







No comments

Powered by Blogger.