Showing posts with label Two. Show all posts
Showing posts with label Two. Show all posts

Write a c program to find out H.C.F. of two numbers.

How To Write a c program to find out H.C.F. of two numbers in C Program.


#include<stdio.h>
int main(){
int x,y,m,i;
printf("Insert any two number: ");
scanf("%d%d",&x,&y);
m=x
for(i=m;i>=1;i--){
if(x%i==0&&y%i==0){
printf("\nHCF of two number is : %d",i) ;
break;
}
}
return 0;
}

Write a C program to find maximum or equal between two numbers ?

How to Write a C program to find maximum or equal between two numbers ?


  1. /*Write a C program to find maximum or equal between two numbers */
  2.  
  3.  
  4. #include <stdio.h>
  5.  
  6. int main ()
  7.  
  8. {
  9.     int a,b;
  10.     printf("Find the maximum between two number: ");
  11.     scanf("%d %d", &a, &b);
  12.  
  13.     if ( a > b ){
  14.         printf("Minimum Number: %d\n",a);
  15.     }
  16.  
  17.     if ( b > a ){
  18.         printf("Maximum Number: %d\n",b);
  19.     }
  20.  
  21.     if ( a == b ){
  22.         printf("Number is equal");
  23.     }
  24.  
  25.     return 0;
  26. }

C Program To Find Product Of Two No Using MACRO

How to write a C Program To Find Product Of Two No Using MACRO in C Programming Language ?


Solution For C Program :

/*C Program To Find Product Of Two No Using MACRO.*/

#include<stdio.h>
#include<conio.h>
#define prod(t,r) t*r
void main()
{
int a,b,c;
printf("enter two no. for finding product\n");
scanf("%d%d",&a,&b);
c=prod(a,b);
printf("%d",c);
getch();
}

You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

C Program To Swap Two Numbers Without Using Third Variable

How to write a C Program To Swap Two Numbers Without Using Third Variable in C Programming Language ?


Solution For C Program :

/*C Program To Swap Two Numbers Without Using Third Variable.*/

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter the first no. a=");
scanf("%d",&a);
printf("Enter the second no. b=");
scanf("%d",&b);
a=a+b;
b=a-b;
a=a-b;
printf("After swaping numbers are:\na=%d\tb=%d",a,b);
getch();
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable


C Program Concatenating Two Strings Into A Third System

How to write a C Program Concatenating Two Strings Into A Third System in C Programming Language ?

Solution For C Program : 

/*C Program Concatenating Two Strings Into A Third System.*/

#include<stdio.h>
void main()
{
char str1[40], str2[40], str3[81];
int k = 0, j = 0;
printf ("\nEnter The First String : ");
scanf ("%s", str1);
printf ("\nEnter The Second String : ");
scanf ("%s", str2);
for (k = 0; str1[k] != '\0'; k++)
str3[k] = str1[k];
for (j = 0; str2[j] != '\0'; j++, k++)
str3[k] = str2[j];
str3[k] = '\0';
printf ("\nThe Two Stings Are : \n\n%s \t %s\n\n", str1, str2);
printf ("\nThe Concatenated Sting is : %s", str3);
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

C Program to concatenate two strings without using string functions

How to write a C Program to concatenate two strings without using string functions in C Programming Language ?

This C Program to concatenate two strings without using string functions.

Solution:

  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5.     char a[50],b[50];
  6.     int i,j,n,k;
  7.     clrscr();
  8.     printf("\n Please Give The STRING OF A : ");
  9.     scanf("%s",a);
  10.     printf("\n Please Give The STRING OF B : ");
  11.     scanf("%s",b);
  12.     for(i=0,k=0;a[i]!='\0';i++)
  13.         k++;
  14.     for(j=0,n=0;b[j]!='\0';j++)
  15.         n++;
  16.     printf("VALUE OF K=%d",k);
  17.     printf("VALUE OF N=%d",n);
  18.     for(i=k,j=0;i<=n+k;i++,j++)
  19.             a[i]=b[j];
  20.     printf("\n THE Concatenated string is %s .",a);
  21.     getch();
  22. }