Length of string

Program:

#include<stdio.h>
int main()
{
char str[30];
int len=0,i;
printf("Enter a string: ");
gets(str);
for(i=0;str[i]!='\0';i++)
{
  len++;
}
printf("Length of string: %d",len);
return 0;
}

Output:



No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...