Home » C Programming

How to Solve Second Order Quadratic Equation Using C Program

Published on 16-Dec-2021 16:09:33
Program : To obtain solution of second order quadratic equation #include <stdio.h> #include <math.h> int main() { float a, b, c; float desc, root1, root2; printf("\nEnter the Values of a : "); scanf("%f", &a); printf("\nEnter the Values of b : "); scanf("%f", &b); printf("\nEnter the Values of c : "); scanf("%f", &c); desc = sqrt(b * b - 4 * a * c); root1 = (-b + desc) /... Read More

How to calculate sum of 5 subjects and find percentage Using C Program

Published on 16-Dec-2021 16:02:43
C Program to calculate sum of 5 subjects and find percentage #include <stdio.h> int main() { int s1, s2, s3, s4, s5, sum, total = 500; float per; printf("\nEnter marks of 5 subjects : "); scanf("%d %d %d %d %d", &s1, &s2, &s3, &s4, &s5); sum = s1 + s2 + s3 + s4 + s5; printf("\nSum : %d", sum); per = (sum * 100) / total; printf("\nPercentage : %f", per); return (0); } ... Read More

How to reverse a given number using C

Published on 16-Dec-2021 15:56:34
#include <stdio.h> int main() { int num, rem, rev = 0; printf("\nEnter any no to be reversed : "); scanf("%d", &num); while (num >= 1) { rem = num % 10; rev = rev * 10 + rem; num = num / 10; } printf("\nReversed Number : %d", rev); return (0); } Output : Enter any no to be reversed : 123 Reversed Number : 321 ... Read More

How to calculate gross salary of a person using C Program

Published on 16-Dec-2021 15:48:12
#include <stdio.h> int main() { int gross_salary, basic, da, ta; printf("Enter basic salary : "); scanf("%d", &basic); da = (10 * basic) / 100; ta = (12 * basic) / 100; gross_salary = basic + da + ta; printf("\nGross salary : %d", gross_salary); return (0); } Output : Enter basic Salary : 1000 Gross Salart : 1220 ... Read More

How to reads customer number and power consumed and prints amount to be paid using C

Published on 16-Dec-2021 15:41:24
An electric power distribution company charges its domestic consumers as follows Consumption Rate of Units Charge ------------------------------------ 0-200 Rs.0.50 per unit 201-400 Rs.100 plus Rs.0.65 per unit excess 200 401-600 Rs.230 plus Rs.0.80 per unit excess of 400. ------------------------------------ Write a C program that reads the customer number and power consumed an... Read More

How to read the values of x, y and z and print the results expressions in one line using C Program

Published on 16-Dec-2021 15:31:37
Problem Statement : Write a program to read the values of x, y and z and print the results of the following expressions in one line. (x+y+z) / (x-y-z) (x+y+z) / 3 (x+y) * (x-y) * (y-z) Program : #include<stdio.h> #include<conio.h> void main() { int x, y, z; float a, b, c; clrscr(); printf("\nEnter the values of x,y and z : "); scanf("%d %d %d", &x, &y, &z); a = (x + y + z) / (x - y - z... Read More

Write C program to find Exponent Power Series

Published on 12-Dec-2021 17:32:54
Program : A program to evaluate the power series x2 x3 xn ex = 1 + x + --- + --- + ..... + ---- 2! 3! n! , 0 < x < 1 It uses if……else to test the accuracy. The power series contains the recurrence relationship of the type Tn = Tn-1 (---) for n > 1 T1 = x for n = 1 T0 = 1 If Tn-1 (usually known as previous term) is known, then Tn (known as present term) ca... Read More

Write a ‘C’ Program to compute the sum of all elements stored in an array using pointers

Published on 12-Dec-2021 17:17:20
C Program to compute sum of the array elements using pointers Program : #include <stdio.h> #include <conio.h> void main() { int numArray[10]; int i, sum = 0; int *ptr; printf("\nEnter 10 elements : "); for (i = 0; i < 10; i++) scanf("%d", &numArray[i]); ptr = numArray; /* a=&a[0] */ for (i = 0; i < 10; i++) { sum = sum + *ptr; ptr++; } printf("... Read More

How to check the type of triangle using C

Published on 12-Dec-2021 17:04:29
C Program to check the type of triangle #include <stdio.h> #include <math.h> int main() { int side1, side2, side3; //Change values accordingly side1 = 5; side2 = 4; side3 = 3; if ((side1 + side2 > side3 && side1 + side3 > side2 && side2 + side3 > side1) && (side1 > 0 && side2 > 0 && side3 > 0)) { if (side1 == side2 &&am... Read More

How to Calculate Area of Circle using C Programming

Published on 12-Dec-2021 13:16:37
C Program to Calculate Area of Circle Shape : Circle Formula : Π * r * r Definition : 1. Ellipse in which the two axes are of equal length 2. Plane curve generated by one point moving at a constant distance from a fixed point 3. You can compute the area of a Circle if you know its radius. Program : #include <stdio.h> int main() { float radius, area; printf("\nEnter the radius of Circle : "); scanf("%d", &... Read More