0% found this document useful (0 votes)
16 views8 pages

MergeResult 2023 10 06 06 21 48

The document contains C code for solving several problems: 1) A program to find the roots of a quadratic equation by taking coefficients as input and calculating the discriminant. 2) A program to find the maximum and minimum of three numbers entered by the user. 3) A program to calculate the factorial of a given number. 4) A program to calculate the sum of first n natural numbers of the form 5i. 5) A program to print patterns of stars. 6) A program to print patterns of numbers in a triangle shape.

Uploaded by

123103073
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views8 pages

MergeResult 2023 10 06 06 21 48

The document contains C code for solving several problems: 1) A program to find the roots of a quadratic equation by taking coefficients as input and calculating the discriminant. 2) A program to find the maximum and minimum of three numbers entered by the user. 3) A program to calculate the factorial of a given number. 4) A program to calculate the sum of first n natural numbers of the form 5i. 5) A program to print patterns of stars. 6) A program to print patterns of numbers in a triangle shape.

Uploaded by

123103073
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

#include <math.

h>

#include <stdio.h>

int main() {

double a, b, c, discriminant, root1, root2, realPart, imagPart;

printf("Enter coefficients a, b and c: ");

scanf("%lf %lf %lf", &a, &b, &c);

discriminant = b * b - 4 * a * c;

if (discriminant > 0) {

root1 = (-b + sqrt(discriminant)) / (2 * a);

root2 = (-b - sqrt(discriminant)) / (2 * a);

printf("root1 = %.2lf and root2 = %.2lf", root1, root2);

else if (discriminant == 0) {

root1 = root2 = -b / (2 * a);

printf("root1 = root2 = %.2lf;", root1);

else {

realPart = -b / (2 * a);

imagPart = sqrt(-discriminant) / (2 * a);

printf("root1 = %.2lf+%.2lfi and root2 = %.2f-%.2fi", realPart, imagPart, realPart, imagPart);

return 0;

}
#include <stdio.h>

int main() {

int a, b, c;

printf("Enter 3 numbers: ");

scanf("%d %d %d", &a, &b, &c);

int max_num, min_num;

max_num = min_num = a;

if (b > max_num) {

max_num = b;

} else if (b < min_num) {

min_num = b;

if (c > max_num) {

max_num = c;

} else if (c < min_num) {

min_num = c;

printf("Maximum number: %d\n", max_num);

printf("Minimum number: %d\n", min_num);

return 0;

}
#include<stdio.h>

int main()

int i,fact=1,number;

printf("Enter a number: ");

scanf("%d",&number);

for(i=1;i<=number;i++){

fact=fact*i;

printf("Factorial of %d is: %d",number,fact);

return 0;

}
#include <stdio.h>

main(){

int s=1;

int n;

printf("Enter the value of n \n");

scanf("%d",&n);

for(int i=1;i<n;i++)

s+=(5*i);

printf("sum is %d \n",s);

}
#include <stdio.h>

main(){

int n;

printf("Enter the value of n \n");

scanf("%d",&n);

for(int i=1;i<=n;i++){

for(int j=1;j<=i;j++)

printf("*");

printf("\n");
}

}
#include <stdio.h>

int main() {

int n;

printf("Enter the number of lines: ");

scanf("%d", &n);

for (int i = 1; i <= n; i++) {

for (int j = 1; j <= n - i; j++) {

printf(" ");

for (int j = 1; j <= i; j++) {

printf("%d", j);

for (int j = i - 1; j >= 1; j--) {

printf("%d", j);

printf("\n");

return 0;}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy