C Programming Lab Manual – 17

Write a C program to Generate Multiplication Table

Function Main
    Declare Integer n
    Declare Integer i
    Output "Enter a number: "
    Input n
    For i = 1 to 10
        Output "" & n & "*"  & i  & "=" &n*i
    End
End

#include <stdio.h>
int main() {
  int n, i;
  printf("Enter a number: ");
  scanf("%d", &n);
  for (i = 1; i <= 10; ++i) {
    printf("%d * %d = %d \n", n, i, n * i);
  }
  return 0;
}

Enter a number: 9
9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
9 * 10 = 90

C Programming Lab Manual – 16

Write a C program to Find the Largest Number Among Three Numbers.

Function Main
    Declare Real num1
    Declare Real num2
    Declare Real num3
    Output "Enter three numbers: "
    Input num1
    Input num2
    Input num3
    If num1>=num2
        If num1>=num3
            Output "The larggest numner is: " &num1
        Else
            Output "The larggest numner is: " &num3
        End
    Else
        If num2>=num3
            Output "The larggest numner is: " &num2
        Else
            Output "The larggest numner is: " &num3
        End
    End
End

#include <stdio.h>
#include <stdlib.h>

int main()
{
    double num1;
    double num2;
    double num3;

    printf("Enter three numbers:\n");
    scanf("%lf %lf %lf", &num1, &num2, &num3);

    if (num1 >= num2) {
        if (num1 >= num3) {
            printf("The largest number is: %.2lf\n", num1);
        } else {
            printf("The largest number is: %.2lf\n", num3);
        }
    } else {
        if (num2 >= num3) {
            printf("The largest number is: %.2lf\n", num2);
        } else {
            printf("The largest number is: %.2lf\n", num3);
        }
    }

    return 0;
}
Enter three numbers:
10.0
20.0
30.0
The largest number is: 30.00