S2-C-Programs

All major conceptual S2 C-Programs with Algorithms

View the Project on GitHub trulyPranav/S2-C-Programs

Code:

#include<stdio.h>

void main(){
    int num1, num2;
    printf("Enter two numbers:"); //input two numbers for checking the greatest
    scanf("%d %d",&num1, &num2); //accepts two numbers using scanf
    //checks if num1 greater than num2
    if(num1>num2){
      //if yes prints num1 is greatest
      printf("%d is the greatest",num1);
    }
    else{
        //if no print num2 is greatest
      printf("%d is the greatest",num2);
    }
    //you can add an extra else if statement to check whether both the numbers are same
}

Algorithm:

Step 1: Start

Step 2: Read two numbers store it in variables num1 and num2

Step 3: If num1 greater than num2, Display ‘num1 is the greatest’

Step 4: Else Display ‘num2 is the greatest’

Step 5: Stop