# Tag Archives: codes

## Program to calculate sum of first 50 natural numbers using recursive function.

Problem Analysis: The problem is to calculate the sum of first 50 natural numbers using recursive function. Code: View the code on Gist. Outputs: the sum of first 50 natural numbers is 1275.

## Program to add, subtract, multiply and divide two integers using user defined type function with return type.

Problem Analysis the problem is to write a program to add, subtract, multiply and divide two integers using user defined type function with return type. Codes: View the code on Gist. Output: enter two numbers:1 2 sum=3 difference=-1 product=2 quotient=0.500000 … Continue reading

## Program to find GCD(greatest common divisor or HCF) and LCM(least common multiple) of two numbers.

Problem Analysis: The problem is to input the two integers from the user and display their GCD and LCM.for this,the necessary parameters and header files are given below. Input variables processing variables … Continue reading

## Program to input two integer numbers and display the sum of even numbers between these two input numbers.

Problem Analysis: The problem is to input the two integers from the user and displays the sum of even numbers between them.For this we need two input variables(a,b) ,a calculation parameter (sum) and another variables(i) for the loop. Input … Continue reading

## Program to read the values for coefficients a,b and c of a quadratic equation ax²+bx+c=0.

Problem Analysis: The problem is to read the values of coefficient a,b,c of quadratic equation ax²+bx+c=0 and to find the equation of the roots. i.e. r1 =(-b + sqrt (d) /(2*a); … Continue reading

## Program to check whether the entered year is leap year or not( a year is leap if it is divisible by 4 and divisible by 100 or 400)

Problem Analysis: The problem is to check whether the entered year is leap year or not ( a year is leap if it is divisible by 4 and divisible by 100 or 400. Algorithms : 1.start 2.Define :year: 3.Enter: … Continue reading

## Program to get the input of two or higher digit integer number and display in reverse order.

Problem Analysis: The problem is to get the input of two or higher digit integer number and display in reverse order. i.e. digit = num%10; rev= rev*10 + digit; num= num/10; Input variables Processing … Continue reading

## Program to check whether the input alphabet is vowel or not by using if else and switch statements.

Problem Analysis: The problem is to check whether the input alphabets is vowel or not by using if else and switch statements. Algorithm 1: (using if else) 1.start 2.define :ch 3.Input; ch from the user. 4. If (ch==’a’//ch==’e’//ch==’i’//ch==’o’//ch==’u’ //ch==’A’//ch==’E’//ch==’I’//ch==’O’//ch==’U’) … Continue reading

## Program to print the size of char,float.double,and long double data types in C.

Problem Analysis: The problem is to print the size of char,float,double and long double data types in C. The output is to print the size of the data types. Algorithm: 1.start. 2.Print the size of characters ,float,double and long … Continue reading

## Program to check and detect whether the number is odd or even given by the user.

Problem Analysis: The problem is to check the given numbers are odd or even having the parameters a. The output is to print the numbers as odd or even Algorithms: 1.start 2.Input the parameters by the user. i.e. int … Continue reading