Skip to main content

Featured

Mastering Hollow Square Patterns in C: Stars, Numbers, Alphabets & Binary

๐Ÿ”ข C Program to Print Hollow Continuous Number Square ๐Ÿ“„ Source Code: #include <stdio.h> int main() { int num, k = 0; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { if(i == 1 || i == num || j == 1 || j == num) { // k increments sequentially only along the borders printf("%d ", k++); } else { printf(" "); } } printf("\n"); } return 0; } ๐Ÿ“‹ Copy Code ๐Ÿ’ป Expected Output (Input: 5): Enter the number: 5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ๐Ÿ”ข C Program to Print Standard Hollow Binary Row Square ๐Ÿ“„ Source Code (Fixed Specifier): #include <stdio.h> int main() { ...

WAP to find the greatest of given 3 numbers

Description :  

You should read 3 integers from user and find the maximum of three numbers.

Sample Execution : 

Test case 1 : 

Enter the three numbers : 10 20 30

Max of three number is 30 

Test case 2 :

Enter the three numbers : 90 20 40

Max of three number is 90 

PROGRAM:

----------------------------------------------------------------------------------------------------------------

#include<stdio.h>

int main()

{

int num1,num2,num3;

    printf("Enter the three numbers:");

    scanf("%d %d %d",&num1,&num2,&num3);

    if(num1>=num2 && num1>num3)

    {

    printf("Max of three number is %d",num1);

    }

    else if (num2>=num1 && num2>=num3)

    {

        printf("Max of three number is %d",num2);

    }

    else if(num3>=num1 && num3>=num2) 

    printf("Max of three number is %d",num3);

}

----------------------------------------------------------------------------------------------------------------

sample input;

Enter three numbers:10 20 30

sample output:

Max of three numberis 30

Comments

Popular Posts

๐ŸŒ™