in turbcoC++
-----------------------------------------------------------------
//program to find length of a string. USe no arguments and return its value
#include <stdio.h> // header file to control input and output
#include<string.h> //header file to handle string function
#include<conio.h> // header file to control console input and output
int string_length(); // function prototype
int main() // main function returning integer value
{
printf("length=%d", string_length()); // function calling
getch(); // holds input and output
return 0; // returning value 0
}
int string_length() // function body
{
char string[100]; // string declaration
int length;
puts("enter string"); // message printing
gets(string); // gets string from user
length=strlen(string); // displays length with the help of strlen() function
return length; //returns value to length
}
-------------------------------------------------------------------------------------------
in codeblocks:
--------------------------------------------------------------------------------------------
//program to find length of a string. USe no arguments and return its value
#include <stdio.h> // header file to control input and output
#include<string.h> //header file to handle string function
#include<conio.h> // header file to control console input and output
int string_length(); // function prototype
int main() // main function returning integer value
{
printf("length=%d", string_length()); // function calling
getch(); // holds input and output
return 0; // returning value 0
}
int string_length() // function body
{
char string[100]; // string declaration
int length;
puts("enter string"); // message printing
gets(string); // gets string from user
length=strlen(string); // displays length with the help of strlen() function
return length; //returns value to length
}
-----------------------------------------------------------------
//program to find length of a string. USe no arguments and return its value
#include <stdio.h> // header file to control input and output
#include<string.h> //header file to handle string function
#include<conio.h> // header file to control console input and output
int string_length(); // function prototype
int main() // main function returning integer value
{
printf("length=%d", string_length()); // function calling
getch(); // holds input and output
return 0; // returning value 0
}
int string_length() // function body
{
char string[100]; // string declaration
int length;
puts("enter string"); // message printing
gets(string); // gets string from user
length=strlen(string); // displays length with the help of strlen() function
return length; //returns value to length
}
-------------------------------------------------------------------------------------------
in codeblocks:
--------------------------------------------------------------------------------------------
//program to find length of a string. USe no arguments and return its value
#include <stdio.h> // header file to control input and output
#include<string.h> //header file to handle string function
#include<conio.h> // header file to control console input and output
int string_length(); // function prototype
int main() // main function returning integer value
{
printf("length=%d", string_length()); // function calling
getch(); // holds input and output
return 0; // returning value 0
}
int string_length() // function body
{
char string[100]; // string declaration
int length;
puts("enter string"); // message printing
gets(string); // gets string from user
length=strlen(string); // displays length with the help of strlen() function
return length; //returns value to length
}
No comments:
Post a Comment