In this program, using a for loop, we have iterated over characters of the string from i = 0 to until '\0' (null character) is encountered. In each iteration, the value of i is increased by 1. When the loop ends, the length of the string will be stored in the i variable.
In this program, three numbers are assigned in to the three variables one by one. Then, compare the two selected of them with the use of comparison operator. Repeat the same process for the other two. After the successful execution of the program the final largest number amongst the three are displayed on the screen.
In this Program, User will enter the three sides of the triangle a, b, c. Then, Calculating the Perimeter of the Triangle. Moreover, calculating the semi perimeter using the formula (a + b + c) / 2 and calculating the Area of a triangle using Heron’s Formula: sqrt(s * (s - a) * (s - b) * (s - c)). After the successful execution of the program the final area of a triangle is shown on screen.
In this Program, User will enter the length and width of the rectangle into two variables length and width. Then, Calculating the Area of the rectangle using the formula Area = length × width. After the successful execution the final area of a rectangle is shown on screen.
To get the output of the this Program, User will Enter temperature in Celsius: 100 Then, Compiler will convert it into Fahrenheit automatically. The final output shown onto the screen is as follows: Enter temperature in Celsius: 100 100 Celsius = 212.00 Fahrenheit
In this program, User Enter a number and check whether the given number is even or odd. Then, after successful compilation displays to check it is Odd or Even on the screen. The output of this Program is given below:Enter any number to check it is even or odd: 4153 is Even.Enter any number to check it is even or odd: 33 is Odd.
This C program allows the user to enter the Principal Amount, Rate of Interest, and the Number of years. By using those values, this C Program will calculate the Simple Interest using following formula: Simple Interest = (Principal Amount * Rate of Interest * Number of years) / 100.
In this Program, The first two elements are respectively started from 0 , 1, and the other numbers in the series are generated by adding the last two numbers of the series using looping. These numbers are stored in an array and printed as output.
This Program adds previous two numbers value to compute the next number value. In this program Fibonacci series is calculated using recursion, with seed as 0 and 1. In the code Fibonacci function calls itself with a lesser value several times. An termination condition is very important to recursion function, i.e. n == 0 and n == 1 or the recursive call would be infinite leading to stack overflow error.
In this Program, we will solve this problem using recursion. We will first take base and exponent as input from user and pass it to a recursive function, which will return the value of base raised to the power of exponent(base^exponent).
Program execution will start from the beginning of the main() function. The main function consists of fact() recursive function, this fact() function is called from main() function with user entered number n as an argument. After passing number 5 to the fact() function will call fact() function (recursive call). In recursive call, the value of that passed argument ‘n’ is decreased by 1 until n value reaches less than 1. The fact(0) will always 1. Once n value is less than one, there is no recursive call and the factorial program will calculate and print output. Your C compiler asks you to enter a number to find factorial as follows:Enter a positive number: 5After you enter your number, the program will be executed and give output like below:Factorial of 5 = 120
Above program first takes length of diagonals as input form user using scanf function and stores it in two floating point variables. Then it calculates the area of Rhombus using the formula given above. Then, it prints the area of Rhombus on screen using printf function.
This Program accepts the three sides of the triangle a, b, c. Then, Calculates the Perimeter of the Triangle. Moreover, calculates the semi perimeter using the formula (a + b + c) / 2 and the Area of a triangle using Heron’s Formula: √(s × (s - a) × (s - b) × (s - c)). After the successful execution of the program the final area of a triangle is shown on screen.
In this Program, the if…else statement is used to check whether an alphabet entered by the user is a vowel or a constant. The five letters A, E, I, O and U are called vowels. All other letters except these 5 vowel letters are called consonants. This program assumes that the user will always enter an alphabetic character.
In this Program, the if…else statement is used to check whether a character entered by the user is alphabet or not? The alphabets A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, and Z are called Alphabet. All other characters except these 26 letters are not an Alphabet. If User entered any character rather than 26 Alphabet than a print like # is not an alphabet.
Never Miss an Articles from us.
Contribute the Community.