Skip to content

Instantly share code, notes, and snippets.

@Vijay-Kumavat
Created December 28, 2020 15:09
Show Gist options
  • Save Vijay-Kumavat/1b2feb4f5a701a74c7a4f6739f62271c to your computer and use it in GitHub Desktop.
Save Vijay-Kumavat/1b2feb4f5a701a74c7a4f6739f62271c to your computer and use it in GitHub Desktop.
The all programs of c language : Addition and multiply || Quotient and Remainder || Swap || Positive and Negative || Even and Odd || Vowel || Check Leap Year || check Alphabet || Sum of number || Factorial || Multiplication table || Factorial using function || Sum of N natural numbers || Prime || Strong || Armstrong || Factorial || Reverse || Pa…
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<string.h>
// #include<limit.h>
// int fact(int n);
// bool isprime(int n);
int factorial(int);
// int fibo(int);
// int prime(int);
int a(int);
int b(int);
int main(){
// clrscr();
printf("Hello\n");
// Addition and multipy
double a,b,c;
printf("Enter the two number : ");
scanf("%lf%lf",&a,&b);
c=a*b;
printf("The Addition of two number is : %lf",c);
getch();
}
// Quotient and Remaimder
// int a,b,c,d;
// printf("Enter the divisdend: ");
// scanf("%d",&a);
// printf("Enter the divisor: ");
// scanf("%d",&b);
// c=a/b;
// d=a%b;
// printf("The Quotient is : %d\n", c);
// printf("The remaimder is : %d", d);
// Sizeof
// int intType;
// printf("%d Btyes",sizeof(intType));
//Swap
// int a,b;
// printf("Enter the Two Value : ");
// scanf("%d%d",&a,&b);
// a=a+b;
// b=a-b;
// a=a-b;
// printf("The swap value is : %d %d",a,b);
//Positve and Negetive
// int a,b;
// printf("Enter the Any Two number : ");
// scanf("%d%d",&a,&b);
// if(a>0 && b>0){
// printf("It is Positive : %d and It is Positive : %d",a,b);
// }
// if(a>0 && b<0){
// printf("It is Positive : %d and It is Negative : %d",a,b);
// }
// if(a<0 && b>0){
// printf("It is Negative : %d and It is Positive : %d",a,b);
// }
// if(a<0 && b>0){
// printf("It is Negative : %d and It is Negative : %d",a,b);
// }
// Even and Odd
// int a;
// printf("Enter the value : ");
// scanf("%d",&a);
// if(a%2==0)
// {
// printf("The value is Even");
// }
// else
// {
// printf("The Value is Odd");
// }
// Vowel
// int lowercase , uppercase;
// char c;
// printf("Enter the any Character : ");
// scanf("%c",&c);
// lowercase = (c=='a' || c=='e' || c=='i' || c=='o' || c=='u');
// uppercase = (c=='A' || c=='E' || c=='I' || c=='O' || c=='U');
// if (lowercase || uppercase)
// {
// printf("%c is vowel.",c);
// }
// else
// {
// printf("%c is consonant.",c);
// }
// Check Leap Year
// int i,j;
// printf("Enter the Year : ");
// scanf("%d",&i);
// if(i%400==0)
// {
// printf("%d is Leap year",i);
// }
// else if(i%100==0)
// {
// printf("%d is not a Leap year",i);
// }
// else if(i%4==0)
// {
// printf("%d is Leap year",i);
// }
// else if(i%100==0)
// {
// printf("%d is not a Leap year",i);
// }
//check Alphabet
// char c;
// printf("Enter the any Alphabet : ");
// scanf("%c",&c);
// if((c>='a' && c<='z')||(c>='A' && c<='Z'))
// {
// printf("%c is Alphabet",c);
// }
// else
// {
// printf("%c is Not Alphabet",c);
// }
//Sum of number
// int i,n,sum=0;
// printf("Enter the number : ");
// scanf("%d",&n);
// for(i=1;i<=n;i++){
// sum=sum+i;
// }
// printf("The Sum of : %d",sum);
//Factorial
// int fact=1,n,i;
// printf("Enter the value : ");
// scanf("%d",&n);
// for (i = 1; i <= n; i++)
// {
// fact=fact*i;
// }
// printf("The Factorials is : %d",fact);
//Multiplication table
// int a;
// printf("Enter the number : ");
// scanf("%d",&a);
// for(int i=1;i<=10;i++)
// {
// printf("%d * %d = %d \n",a,i,a*i);
// }
// Factorial using function
// int n;
// printf("Enter the number : ");
// scanf("%d",&n);
// printf("%d Factorial = %d",n,fact(n));
//Sum of N nutural numbers
// int n,sum=0;
// printf("Enter the number : ");
// scanf("%d",&n);
// for(int i=1;i<=n;i++)
// {
// sum=sum+i;
// }
// printf("The N nutural number sum is : %d",sum);
//Factors
// int n;
// printf("Enter the number : ");
// scanf("%d",&n);
// for(int i=1;i<=n;i++)
// {
// if(n%i==0)
// {
// printf("%d ",i);
// }
// }
//Power of given numbers
// int n,i;
// printf("Enter the number : ");
// scanf("%d",&n);
// printf("Enter the power of number : ");
// scanf("%d",&i);
// int a = pow(n,i);
// printf("%d",a);
//Prime number or not
// int n,i;
// printf("Enter the number : ");
// scanf("%d",&n);
// for(i=2;i<n;i++)
// if(n%i==0)
// break;
// if(i==n)
// printf("The number is prime");
// else
// printf("The number is not prime");
//Prime or not using fuction
// int n,i;
// printf("Enter the number : ");
// scanf("%d",&n);
// if(isprime(n))
// printf("The number is prime");
// else
// printf("the number is not prime");
//Fibonacci series
// int a=0,b=1,c,n,i;
// printf("Enter the number : ");
// scanf("%d",&n);
// printf("%d %d ",a,b);
// for(i=2;i<n;i++)
// {
// c=a+b;
// printf("%d ",c);
// a=b;
// b=c;
// }
// return 0;
// }
//Armstrong number
// int a,m,n,i,sum=0;
// printf("Enter the number : ");
// scanf("%d",&n);
// m=n;
// for(i=1;i<n;i++)// while(m>0)
// {
// a=m%10;
// m=m/10;
// sum = sum + a*a*a;
// }
// if(sum==n)
// printf("%d is number is armstrong",n);
// else
// printf("%d is number is not armstrong",n);
//Sum of digits
// int a,m,n,i,sum=0;
// printf("Enter the number : ");
// scanf("%d",&n);
// m=n;
// for(i=1;i<n;i++)// while(m>0)
// {
// a=m%10;
// sum = sum + a;
// m=m/10;
// }
// printf("The %d sum of digits is : %d",n,sum);
//Reverse
// int a,m,n,i,rev=0;
// printf("Enter the number : ");
// scanf("%d",&n);
// m=n;
// while(m>0)
// {
// a=m%10;
// m=m/10;
// rev=rev*10+a;
// }
// printf("The %d reverse is : %d",n,rev);
//Palindrome
// int a,m,n,i,rev=0;
// printf("Enter the number : ");
// scanf("%d",&n);
// m=n;
// while(m>0)
// {
// a=m%10;
// m=m/10;
// rev=rev*10+a;
// }
// if(n==rev)
// printf("The %d is palimdrome number",n);
// else
// printf("The %d is not palimdrome number",n);
// Count digit
// int count=0,ln,n;
// printf("Enter the first number : ");
// scanf("%d",&n);
// while(n!=0)
// {
// ln=n%10;
// count++;
// // fact=factorial(ln);
// // sum=sum+fact;
// n=n/10;
// }
// printf("%d",count);
// Hello world without semicolunm
// if(printf("Hello1"))
// return 0;
// Area of triangle
// int a,b,c,s,area;
// printf("Enter the a : ");
// scanf("%d",&a);
// printf("Enter the b : ");
// scanf("%d",&b);
// printf("Enter the c : ");
// scanf("%d",&c);
// s=(a+b+c)/2;
// area=sqrt(s*(s-a)*(s-b)*(s-c));
// printf("The traiangle area is : %d",area);
// Area of volume
// int a,area;
// printf("Enter the a : ");
// scanf("%d",&a);
// area=(4.0/3.0)*(22.0/7)*(a*a*a);
// printf("The traiangle area is : %d",area);
// Binary to decimal // 1001 to 9
// int n,r,i=1,d=0;
// printf("Enter the number : ");
// scanf("%d",&n);
// while(n!=0)
// {
// r=n%10; // remainder
// d=d+r*i; // store in decimal
// n=n/10; //divide the 1001
// i=i*2; //max to the weight
// }
// printf("%d",d);
// Decimal to binary // 12 to 1100
// int d,r,i;
// long int b=0;
// printf("Enter the number : ");
// scanf("%d",&d);
// for(i=1;d!=0;i=i*10)
// {
// r=d%2; // rem =0
// b=b+r*i; // b=0
// d/=2; //d=6 , then repeart the loop
// }
// printf("%d",b);
// Decimal to octal // 12 to 1100 to 10
// int i=1,d,o=0,r;
// printf("Enter the decimal number : ");
// scanf("%d",&d);
// while(d!=0)
// {
// o=(d%8)*i; // d=64,o=0;o=0;o=1*100=100 , then after print
// d/=8; // d=8;d=1;
// i*=10; // i=10;i=100
// }
// printf("%d",o);
// Octal to Decimal // 100 to 64
// int i=0,d=0,o;
// printf("Enter the octal number : ");
// scanf("%d",&o);
// while(o!=0)
// {
// d=d+(o%10)*pow(8,i);
// i++;
// o/=10;
// }
// printf("%d",d);
// Binary to octal // 1100 to 14
// int b=0,d=0,n,i=0,o;
// printf("Enter the binary number : ");
// scanf("%d",&b);
// binary to decimal
// while(b!=0) //not equal to zero
// {
// d=d+(b%10)*pow(2,i); // b=1100,d=0
// i++; //i=0
// b/=10; //b=110
// }
// i=1;
// Decimal to octal
// while(d!=0)
// {
// o=o+(d%8)*i; // d=12
// i=i*10;
// d/=8;
// }
// printf("%d",o);
// Octal to binary // 14 to 1100
// int d=0,i=0,o;
// long int b=0;
// printf("Enter the octal number : ");
// scanf("%d",&o);
// // octal to decimal
// while(o!=0) //not equal to zero
// {
// d=d+(o%10)*pow(8,i); //
// i++; //i=0
// o/=10; //b=110
// }
// i=1;
// // Decimal to binary
// while(d!=0)
// {
// b=b+(d%2)*i; // d=12
// i=i*10;
// d/=2;
// }
// printf("%d",b);
// return 0;
// }
// LCM of two number
// int a,b,low,lcm;
// printf("Enter the number : ");
// scanf("%d",&a);
// printf("Enter the number : ");
// scanf("%d",&b);
// low=(a<b)?a:b; // low=(a>b)?a:b;
// while(1)
// {
// if(low%a==0 && low%b==0)
// {
// lcm=low;
// break;
// }
// low++;
// }
// printf("The LCM of %d and %d is : %d",a,b,lcm);
// return 0;
// }
// HCL of two number
// int a,b,i,gcb;
// printf("Enter the number : ");
// scanf("%d",&a);
// printf("Enter the number : ");
// scanf("%d",&b);
// for(i=1;i<=a,i<=b;i++)
// {
// if(a%i==0 && b%i==0)
// {
// gcb=i;
// }
// }
// printf("The gcb of %d and %d is : %d",a,b,gcb);
// Pattern - wegde
// int i,j,n;
// printf("Enter the number : ");
// scanf("%d",&n);
// for(i=0;i<n;i++)
// {
// for(j=1;j<=i;j++)
// {
// printf("*");
// }
// printf("\n");
// }
// Pattern - Pyramid
// int i,j,n,k=1;
// printf("Enter the number : ");
// scanf("%d",&n);
// for(i=10;i>0;i=i-2)
// {
// for(j=i;j>=0;j--)
// {
// printf(" ");
// }
// for(j=k;j>0;j--)
// {
// printf("%d",1);
// }
// k=k+2;
// printf("\n");
// }
//Larget and smallest number is find in array
// int a[10]={3,4,2,12,45,23,-5,11,392,87};
// int smallest,larget;
// int arr_size=sizeof(a);
// smallest=INT_MIN;
// larget=INT_MAX;
// for(i=0;i<arr_size;i++)
// {
// if(smallest>a[i])
// {
// smallest=a[i];
// }
// if(larget<a[i])
// {
// larget=a[i];
// }
// printf("%d %d",smallest,larget);
// }
// void fibonacci(int n)
// {
// int i, t1 = 0, t2 = 1, nextTerm;
// for (i = 1; i<=n; i++)
// {
// nextTerm = t1 + t2;
// t1 = t2;
// t2 = nextTerm;
// }
// printf("%d", t1);
// }
// #define MAX 1000
// void prime(int n)
// {
// int i, j, flag, count =0;
// for (i=2; i<=MAX; i++)
// {
// flag = 0;
// for (j=2; j<i; j++)
// {
// if(i%j == 0)
// {
// flag = 1;
// break;
// }
// }
// if (flag == 0)
// if(++count == n)
// {
// printf("%d", i);
// break;
// }
// }
// }
// int n;
// scanf("%d", &n);
// if(n%2 == 1)
// fibonacci (n/2 + 1);
// else
// prime(n/2);
//Prime number
// int a,b,i,flag;
// printf("Enter the first number : ");
// scanf("%d",&a);
// printf("Enter the second number : ");
// scanf("%d",&b);
// printf("The prime number is between %d and %d : ",a,b);
// while(a<b)
// {
// flag=0;
// for(i=2;i<=a/2;i++)
// {
// if(a%i==0)
// {
// flag=1;
// break;
// }
// }
// if(flag==0)
// {
// printf(" %d",a);
// }
// ++a;
// }
// printf("\n");
// Strong number
// int i,n,q,rem,fact=1,res=0;
// printf("Enter the number : ");
// scanf("%d",&n);
// q=n;
// while(q!=0)
// {
// rem=q%10;
// for(i=1;i<=rem;i++)
// {
// fact=fact*i;
// }
// res=res+fact;
// fact=1;
// q=q/10;
// }
// if(res==n)
// {
// printf("The strong number is : %d",n);
// }
// else{
// printf("It is not a strong number : %d",n);
// }
//Plimdrome string
// char a[100],b[100];
// printf("Enter the string : ");
// gets(a);
// strcpy(b,a);
// strrev(b);
// if(strcmp(a,b)==0)
// {
// printf("The string is plimdrome");
// }
// else{
// printf("The string is not plimdrome");
// }
// Reverse string
// char s[100],r[100];
// int i,j,count=0;
// printf("Enter the String : ");
// scanf("%s",&s);
// //find the string lengh
// while(s[count]!=0)
// {
// count++;
// }
// j=count-1;
// //store the character in r
// for(i=0;i<count;i++)
// {
// r[i]=s[j];
// j--;
// }
// printf("%s",r);
// 1, 1, 2, 3, 4, 9, 8, 27, 16, 81, 32, 243, 64, 729, 128, 2187…
// int n;
// printf("Enter the nth term : ");
// scanf("%d",&n);
// if(n%2==0){
// a(n/2);
// }
// else{
// b(n/2+1);
// }
// return 0;
// }
// int a(int n){ // even place
// int x;
// x=pow(3,n-1);
// printf("%d",x);
// }
// int b(int n){ // odd place
// int x;
// x=pow(2,n-1);
// printf("%d",x);
// }
// 3, 7, 13, 21, 31, …….
// int n,i,x;
// printf("Enter the any number : ");
// scanf("%d",&n);
// for(i=1;i<=n;i++)
// {
// x = (pow(n,2) + n + 1);
// }
// printf("The %dth term is : %d",n,x);
// 1, 3, 12, 60, 360…
// int i,n,x=3;
// printf("Enter the nth term : ");
// scanf("%d",&n);
// for(i=1;i<=n;i++)
// {
// x=(factorial(n+1))/2; // N=[(N+1)!]/2;
// }
// printf("%d",x);
// }
// int factorial(int n)
// {
// int i,fact=1;
// for(i=1;i<=n;i++)
// {
// fact=fact*i;
// }
// return fact;
// }
//-1, 2, 11, 26, 47, 74, .....
// int n,i,x;
// printf("Enter the any number : ");
// scanf("%d",&n);
// for(i=1;i<=n;i++)
// {
// x = ((3*n*n)-(6*n)+2);
// }
// printf("The %dth term is : %d",n,x);
// 0, 0, 2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8,…..
// int n;
// printf("Enter the nth term : ");
// scanf("%d",&n);
// if(n%2==0)
// {
// // Even place
// n=n/2;
// n=2*(n-1);
// printf("%d",n/2);
// }
// else{
// // Odd place
// n=n/2+1;
// n=2*(n-1);
// printf("%d",n);
// }
// 9, 23, 45, 75, 113, 159......
// int n,i,x;
// printf("Enter the number : ");
// scanf("%d",&n);
// for(i=1;i<=n;i++)
// {
// x=(((2*n)+3)*((2*n)+3)-(2*n));
// }
// printf("%d",x);
// 0, 2, 1, 3, 1, 5, 2, 7, 3, …
// int n;
// printf("Enter the nth term : ") ;
// scanf("%d",&n);
// if(n%2==0)
// {
// b(n/2);
// }
// else
// {
// a(n/2+1);
// }
// return 0;
// }
// int a(int n)
// {
// int x=0,y=1,z,i;
// for(i=1;i<=n;i++)
// {
// z=x+y;
// x=y;
// y=z;
// }
// printf("%d",x);
// }
// int b(int n)
// {
// int i;
// for(i=1;i<=n;i++)
// {
// if(n%i==0)
// {
// break;
// }
// }
// if(n==i)
// {
// printf("%d",n);
// }
// }
// int fact(int n)
// {
// int i,fact=1;
// for(i=1;i<=n;i++)
// {
// fact=fact*i;
// }
// return fact;
// }
// int fact(int n)
// {
// if(n==0)
// return 1;
// else
// return n * fact(n-1);
// }
// bool isprime(int n){
// int i,n;
// for(i=2;i<n;i++)
// {
// if(n%1==0)
// break;
// }
// if(i==n)
// return true;
// else
// return false;
// }
@Vijay-Kumavat
Copy link
Author

All phase are under the comments, reason is error.
Sometime, If you can any two phase are uncomment, then in any one program phase are show the error.
If you don't trust me, then try it 👩‍💻.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment