Skip to content

Commit 7fa6476

Browse files
authored
Merge pull request #7 from 112121040/if-else-coding
If else coding
2 parents e4284fd + b7427f1 commit 7fa6476

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include<stdio.h>
2+
#include<stdlib.h>
3+
//main function
4+
int main()
5+
{
6+
//Variable Decleration
7+
int choice;
8+
float r ,circle,side,square;
9+
while(choice != 3)
10+
{
11+
printf("Press 1 for area of circle\n");
12+
printf("Press 2 for area of square\n");
13+
printf("Press 3 to CY@\n");
14+
scanf("%d", &choice);
15+
16+
if(choice==1)
17+
{
18+
printf("Enter the radius.\n\n");
19+
scanf("%f", &r);
20+
circle = 3.14*r*r;
21+
printf("Area of circle is %f\n", circle);
22+
}
23+
else if(choice==2)
24+
{
25+
printf("Enter a side.\n");
26+
scanf("%f", &side);
27+
square = side*side;
28+
printf("Area of square is %f\n", square);
29+
}
30+
else if(choice==3)
31+
{
32+
printf("=======================\n=======================\n=======================\n");
33+
}
34+
else
35+
{
36+
printf("you entered incorrect choice.\n");
37+
}
38+
39+
}
40+
41+
}

differentiation prog

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <stdio.h>
2+
#include <conio.h>
3+
4+
float poly(float a[], int, float);
5+
6+
int main()
7+
{
8+
float x, a[10], y1;
9+
int d, i;
10+
11+
printf("Enter polynomial equation degree: ");
12+
scanf("%d", &d);
13+
14+
printf("Enter x value for which the equation is to be evaluated: ");
15+
scanf("%f", &x);
16+
17+
for (i = 0; i <= d; i++) {
18+
printf("Enter x coeff to the power %d: ", i);
19+
scanf("%f", &a[i]);
20+
}
21+
22+
y1 = poly(a, d, x);
23+
24+
printf(" value of polynomial equation for the value of x = %.2f is: %.2f", x, y1);
25+
26+
return 0;
27+
}
28+
29+
float poly(float a[], int d, float x)
30+
{
31+
float p;
32+
int i;
33+
34+
p = a[d];
35+
36+
for (i = d; i >= 1; i--) {
37+
p = (a[i - 1] + x * p);
38+
}
39+
40+
return p;
41+
}

0 commit comments

Comments
 (0)