Menus

Saturday 22 October 2022

How to Swap Two Arrays In C Language

 

#include<stdio.h>

void main()

{


  int a[5] = {5,6,7,8,9};

  int b[5] = {1,2,3,4,5};

  

  int i,swap;


  for(i=0;i<5;i++)

  {


    swap = a[i];

    a[i] = b[i];

    b[i] = swap;


  } 


  printf("A = ");

  for(i=0;i<5;i++)

    printf("%d ",a[i]);


  printf("\nB = ");

  for(i=0;i<5;i++)

    printf("%d ",b[i]); 


  printf("\n");

}







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();

}

Saturday 5 March 2022

C language MCQ (Multiple Choise Questions)

Art of C Programming


1 . Address stored in the pointer variable is of type __________
 
 
 
 

 

2. "*" is called as ___________
 
 
 
 


3. Comment on the following pointer declaration?

     int *ptr, p;
 
 
 
 


4. Which of the following are correct syntaxes to send an array as a parameter to function

 
 
 
 


5. Which of the following is not possible in C?

 
 
 
 


 

Answers

1. Integer

2.  

3. ptr is a pointer to integer, p is not.

4. func(&array);

5. None of the mentioned



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();

}