Skip to main content

Featured

C Pattern Programs: Square Number and Alphabet Patterns Explained

๐Ÿ”ท Square Star Pattern ๐Ÿ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { printf("* ");//keep"* " } printf("\n"); } return 0; } ๐Ÿ”ท Reverse Square Alphabet Pattern (Column-wise) ๐Ÿ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = num; i >= 1; i--) { for(int j = num; j >= 1; j--) { printf("%c ", j + 64);//%c for Character and 64 will be ASIIC VALUE } printf("\n"); } return 0; } ๐Ÿ”ท Reverse Square Alphabet Pattern (Row-wise) ๐Ÿ“‹ Copy Code #include <stdio.h> int main() { int num; ...

Write a program to find the max of two numbers in c

 Description : 

You have to read two integers from user and find the maximum of two integers.

Sample Execution : 

Test case 1 : 

Enter the num1 : 10

Enter the num2 : 20 

Max of two numbers is 20

Test case 2 :

Enter the num1 : 95

Enter the num2 : 25 

Max of two numbers is 95

PROGRAM:

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

#include<stdio.h>

int main()

{

    int num1,num2;

      printf("Enter the num1:");

     scanf("%d",&num1);

   printf("Enter the num2:");

    scanf("%d",&num2);

   if(num1>=num2)

    {

    printf("max of two numbers is %d",num1);

    }

else if(num2>=num1)

{

printf("max of two numbers is %d",num2);

}

}

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

Comments

Popular Posts

๐ŸŒ™