1#include <stdio.h>
2int main() {
3 double n1, n2, n3;
4 printf("Enter three different numbers: ");
5 scanf("%lf %lf %lf", &n1, &n2, &n3);
6
7 // if n1 is greater than both n2 and n3, n1 is the largest
8 if (n1 >= n2 && n1 >= n3)
9 printf("%.2f is the largest number.", n1);
10
11 // if n2 is greater than both n1 and n3, n2 is the largest
12 if (n2 >= n1 && n2 >= n3)
13 printf("%.2f is the largest number.", n2);
14
15 // if n3 is greater than both n1 and n2, n3 is the largest
16 if (n3 >= n1 && n3 >= n2)
17 printf("%.2f is the largest number.", n3);
18
19 return 0;
20}
21
1/*Program for adding two numbers*/
2#include <stdio.h>
3int main(){
4 int a, b;
5 printf("Enter the first number: \n"); //Prompts user to enter the first number.
6 scanf("%d", &a);//Accepts input and saves it to variable a
7 printf("Enter the second number: \n");
8 scanf("%d", &b);//Accepts input and saves it to variable a
9 if (a > b){
10 printf("%d is greater than %d", a, b);
11 }
12 else
13 printf("%d is greater than %d", b, a);
14}
1#include <stdio.h>
2int main() {
3 double n1, n2, n3;
4 printf("Enter three numbers: ");
5 scanf("%lf %lf %lf", &n1, &n2, &n3);
6
7 if (n1 >= n2) {
8 if (n1 >= n3)
9 printf("%.2lf is the largest number.", n1);
10 else
11 printf("%.2lf is the largest number.", n3);
12 } else {
13 if (n2 >= n3)
14 printf("%.2lf is the largest number.", n2);
15 else
16 printf("%.2lf is the largest number.", n3);
17 }
18
19 return 0;
20}
21
1#include <stdio.h>
2int main() {
3 double n1, n2, n3;
4 printf("Enter three numbers: ");
5 scanf("%lf %lf %lf", &n1, &n2, &n3);
6
7 // if n1 is greater than both n2 and n3, n1 is the largest
8 if (n1 >= n2 && n1 >= n3)
9 printf("%.2lf is the largest number.", n1);
10
11 // if n2 is greater than both n1 and n3, n2 is the largest
12 else if (n2 >= n1 && n2 >= n3)
13 printf("%.2lf is the largest number.", n2);
14
15 // if both above conditions are false, n3 is the largest
16 else
17 printf("%.2lf is the largest number.", n3);
18
19 return 0;
20}
21