Menus

Showing posts with label C program. Show all posts
Showing posts with label C program. Show all posts

Saturday 23 April 2022

Largest of three numbers in C

 #include <stdio.h>

int main()

{

 int x,y,z;

 clrscr();

 printf("Enter three numbers :");

 scanf("%d,%d,%d",&x,&y,&z);


 if(x>y)

 {

   if(x>z)

     printf("Largest value : %d ",x);

   else

     printf("Largest value : %d ",z);

 }

 else

 {

   if(y>z)

     printf("Largest value : %d",y);

   else

     printf("Largest value : %d",z);

 }


 getch();

}

Wednesday 23 February 2022

Printing Pattern in C | Inverted Half Pyramid

 


#include<stdio.h>

void main()

{

int i,j,r=6;

clrscr();


  for(i=1;i<=r;i++)

  {

   for(j=r;j>=i;j--)

   {

     printf("*");

   }

   printf("\n");

  }


getch();

}





Saturday 17 April 2021

Printing Pattern in C


Output



Source Code

 

#include<stdio.h>

void main()

{

int i,j,k,rows=7;

clrscr();

  for(i=1;i<=rows;i++)

  {

   //print blank space

   for(j=1;j<=rows;j++)

   {

     if((i+j)<=rows)

       printf(" ");

     else

       printf("*");

   }

   printf("\n");

  }

  getch();

}


Video




Friday 13 December 2019

Write a c program to find whether a number odd or even


Code


#include<stdio.h>

void main()
{
int a;
printf("Enter a number ");
scanf("%d",&a);

if(a%2==0)

  printf("The %d is even number\n",a);

else

  printf("The %d is odd number\n",a);

}

Video