Category Archives: precise examples

Program to display 1 to ‘n’ numbers and display sum of 1 to ‘n’.

Code: View the code on Gist. Output: Enter the numbers you want to display:5 1       2      3      4      5 the sum from 1 to 5  =15

Posted in C, precise examples | Tagged , , , , | Leave a comment

Program to calculate factorial of number n and find out permutation and combination using return type.

Problem Analysis: The problem is to calculate the factorial of a given number and find out permutation and combination using the factorial calculated. Code:   View the code on Gist. Outputs: Enter a number(n) to calculate it’s factorial and r … Continue reading

Posted in C, precise examples | Tagged , , , , , | Leave a comment

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.  

Posted in C, precise examples | Tagged , , , , , | Leave a comment

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

Posted in C, precise examples | Tagged , , , , , | Leave a comment

Program to display the Fibonacci series of last term upto 300.

Problem Analysis: The problem is to display the Fibonacci series of last term upto 300.   Algorithms: 1.start. 2.Declare i,f=0,s=1,n. 3.n=f+s. 4.print f,s,n. 5.stark: for (i=1;i<100;i++) { f=s; s=n; n=f+s; if (n<300) { printf(“\f%d”,n); go to stark } else goto … Continue reading

Posted in C, precise examples | Tagged , , , | Leave a comment

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

Posted in C, precise examples | Tagged , , , , , | Leave a comment

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

Posted in C, precise examples | Tagged , , , , , | Leave a comment

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

Posted in C, precise examples | Tagged , , , , , | Leave a comment

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

Posted in C, precise examples | Tagged , , , , , | Leave a comment

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

Posted in C, precise examples | Tagged , , , , , | Leave a comment