Find Length of String Using Library Function [crayon-61757e4b06e8a009196728/] Explanation of Program : We need to find the length of the string using library function provided by C Programming. [crayon-61757e4b06e94872359891/] strlen() function will evaluate the length of the string and return the string length (i.e integer value). [crayon-61757e4b06e98811411541/] We need to include string.h header file in order to use string manipulation functions in c program. [box] Functions Required => strlen() : String Function for Computing Length [/box]
With using User-defined Function Write a Program to Find Length of String [crayon-61757e4b07b37986646267/] Explanation of the program - after accepting the string from the user we are passing the complete array to the function. [crayon-61757e4b07b3f876662954/] Now inside the function we are executing a while loop which will calculate the length of the string. [crayon-61757e4b07b42570925293/] Dry run and more detail explanation of this while loop is already explained in the previous chapter.
C Program to Find Length of String Without using Library Function It is easier to find the length of the string using given library function, but in this program we are finding the length of the string without using library function. [crayon-61757e4b07ec6171257955/] Explanation of Program : In the above program we have accepted the string from the user. [crayon-61757e4b07ece777514038/] After that we have initialized the length variable with zero. "length" variable is used to keep track of the number of character accessed. [crayon-61757e4b07ed1242423850/] Initially length is [...]
C Program to Convert Decimal to Binary using Bitwise and operator [crayon-61757e4b082da218345944/] Output : [crayon-61757e4b082e1674141930/] Above program is just to know the size of integer variable in C Programming (Borland C/C++ Compiler.) Integer number can be represented by 16 bits. To convert the Decimal Number into Binary , Check First MSB bit of number , if it is 1 then display '1' otherwise display '0'. Program : [crayon-61757e4b082e4804382220/] Output : [crayon-61757e4b082e7154822464/] Explanation of Decimal to Binary Program : In this program we have accepted the decimal number using [...]
Program to Convert Binary to Decimal number:Number System [crayon-61757e4b087ae787127317/] Output : [crayon-61757e4b087b5918098589/] Note : This program is for beginners (not for Experts) that's why we haven't provided any Validations while accepting the input. Please provide proper binary input to this program i.e (0 and 1). Logic of This Program : In the main function we have accepted the proper binary input i.e suppose we have accepted 111 as binary input. [crayon-61757e4b087b8738270034/] Inside the function while loop gets executed. Sample Dry run for the while loop is shown [...]
C Program to Convert Decimal number into Hexadecimal : [crayon-61757e4b08b7f542604316/] Output : [crayon-61757e4b08b86524461920/] Logic of This Program : In this program firstly we need to accept decimal number from the user using following statement - [crayon-61757e4b08b8a458664447/] Now after accepting the number we are calling the function which can evaluate equivalent hexadecimal number. [crayon-61757e4b08b8d348608913/] Inside the function we have declared 3 variables. Below table will explain the significance of each and every variable used inside the function. Now perform below steps until the number becomes less than 0 - Divide the [...]
Logic of This Program : In this program we are accepting the decimal number from the user and decimal number is converted into the equivalent octal number with simple steps - [box] Steps to Convert Decimal to Octal : Accept the given decimal number If the number is less than 8 the octal number is the same If the num > 7 then Divide the number with 8 Write down the remainder Do steps 3 and 4 with the quotient till that quotient is less than 8 Write [...]
Program to Convert Decimal number into Binary : Number System : Download [crayon-61757e4b093b3668151419/] Output : [crayon-61757e4b093bb987113015/] Explanation of Program : Always Program execution starts from main function. Inside Main function we are accepting the decimal number. [crayon-61757e4b093be119440693/] Now after accepting the input decimal number we pass the decimal number to function dec_bin(num) function using following syntax. [crayon-61757e4b093c0862309040/] Inside the Function Call - We have declared some variables and the use of each variable is listed in following table - We are following steps until the number becomes 0 or less [...]
Program : [crayon-61757e4b097e6226288777/] Explanation : [crayon-61757e4b097ef946723721/] Circle Function Draws Circle having Center (x,y) and Radius 'rad' Syntax : [crayon-61757e4b097f2171333992/]
Area of Circle can be computed using the pointer. We are passing the variables to function using pass by reference or address scheme and we are writing the result directly on the final memory location.