This program calculates the length of a string manually using a for loop.We are not using strlen( ) over here.
SOURCE CODE
1 2 3 4 5 6 7 8 9 10 11 12 13 | #include |
OUTPUT
Explanation:
Here within the main() we have declared one character variable i and one character string srt[].Then we print a message for the user to input the string and stores it in str[]. Then we are running a for loop which run from i=0 until str[i]!='/0' i.e, null and it will count the i i.e, the number of elements in the string.Next we just print the value of i , i.e, the number of elements in the string.
More Topics on C program
- C program to store information of n student using structure
- C program to find the Armstrong Number between intervals
- C program to check whether a certain number is Armstrong or not
- C Program to Check Whether a Number is Palindrome or Not
- C Program to display the Fibonacci Series up-to n number of terms
- C Program to display the Fibonacci Series up-to a certain number
- C program to find the factorial of a number
- C Program to Find Prime Numbers Between Intervals Using Functions.
- C program: perfect or not checking
- C program to identify a number as even or odd
- C Program to print Hello World
No comments:
Post a Comment