Pages

Sunday, 25 January 2015

C Program To Find The Sum Of Digits Of A Given Number

/* Find The Sum Of Digits Of A Given Number */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include <stdio.h>  
 #include <conio.h>  
 void main()  
 {  
   int number,sum=0,last_digit;  
   clrscr();  
   printf("Enter a number");  
   scanf("%d",&number);  
   while(number>0)  
   {  
     last_digit=number%10;  
     sum=sum+last_digit;  
     number=number/10;  
   }  
   printf("The sum of digits of given number is: %d",sum);  
   getch();  
 }  

C Program To Find The Reverse of Given Number

/* Find The Reverse of Given Number*/

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include <stdio.h>  
 #include <conio.h>  
 void main()  
 {  
   int number,last_digit,newNumber=0;  
   clrscr();  
   printf("Enter a number");  
   scanf("%d",&number);  
   while(number>0)  
   {  
     last_digit=number%10;  
     newNumber=newNumber*10+last_digit;  
     number=number/10;  
   }  
   printf("Reverse of given number is:%d",newNumber);  
   getch();  
 }  

C Program To Check Given Number Is Prime or Not

/* C Program To Check Given Number Is Prime or Not */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include <stdio.h>  
 #include <conio.h>  
 #include <math.h>  
 void main()  
 {  
   int number,i,flag=0;  
   clrscr();  
   printf("Enter a number");  
   scanf("%d",&number);  
   for(i=2;i<=sqrt(number);i++)  
   {  
     if(number%i==0)  
     {  
       flag=1;  
       break;  
     }  
   }  
   if(flag==1)  
   {  
     printf("Given number is not prime");  
   }  
   else  
   {  
     printf("Given number is prime number");  
   }  
   getch();  
 }  

C Program To Check Given Number Is Palindrome or Not

/* C Program To Check Given Number Is Palindrome or Not */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include <stdio.h>  
 #include <conio.h>  
 void main()  
 {  
   int number,sum=0,last_digit,backupOfNumber;  
   clrscr();  
   printf("\nEnter a number");  
   scanf("%d",&number);  
   backupOfNumber=number;  
   while(number>0)  
   {  
     last_digit=number%10;  
     sum=sum+last_digit;  
     number=number/10;  
   }  
   if(sum==backupOfNumber)  
   {  
     printf("Entered number is Palindrom number");    
   }  
   else  
   {  
     printf("Entered number is not Palindrom number");  
   }  
   getch();  
 }  

C Program To Find Factorial Of Given Number

/* C Program To Find Factorial Of Given Number */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include <stdio.h>  
 #include <conio.h>  
 void main()  
 {  
   int number,i,fact=1;  
   clrscr();  
   printf("\nEnter a number");  
   scanf("%d",&number);  
   for(i=1;i<=number;i++)  
   {  
     fact=fact*i;  
   }  
   printf("Factorial of given number is: %d",fact);  
   getch();  
 }  

C Program To Check Given Number Is Armstrong or Not

/* C Program To Check Given Number Is Armstrong  or Not */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include <stdio.h>  
 #include <conio.h>  
 #include <math.h>  
 void main()  
 {  
   int number,sum=0,last_digit,backupOfNumber;  
   clrscr();  
   printf("\nEnter a number");  
   scanf("%d",&number);  
   backupOfNumber=number;  
   while(number>0)  
   {  
     last_digit=number%10;  
     sum= sum + pow(last_digit,3);  
     number=number/10;  
   }  
   if(sum==backupOfNumber)  
   {  
     printf("Entered number is Armstrong number");    
   }  
   else  
   {  
     printf("Entered number is not Armstrong number");  
   }  
   getch();  
 }  

Saturday, 10 January 2015

C Program To Find The Result of X/1 + X^2 / 2^2 + X^3 / 3^3+.....X^N / N^N

/* C Program To Find The Result of X/1 + X^2 / 2^2 + X^3 / 3^3....X^N / N^N */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int i=0,sum=0,x,y,n;  
   clrscr();  
   printf("Enter the value of X: ");  
   scanf("%d",&x);  
    printf("Enter the value of n: ");  
   scanf("%d",&n);  
   for(i=1;i<=n;i++)  
   {  
       sum=sum+pow(x,i)/pow(i,i);  
   }  
   printf("The sum of given series is: %d",sum);  
   getch();  
 }  

C Program To Find The Result of X + X3 + X5 + X7

/* C Program To Find The Result of X + X3 + X5 + X7 */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int i=0,sum=0,x,n;  
   clrscr();  
   printf("Enter the value of X: ");  
   scanf("%d",&x);  
   printf("Enter the value of n: ");  
   scanf("%d",&n);   
   for(i=1;i<=n;i++)  
   {  
     if(i%2!=0)  
       sum=sum+pow(x,i);  
   }  
   printf("The sum of given series is: %d",sum);  
   getch();  
 }  

C Program To Find The Result of X + X^2 + X^3+....+ X^n

/* C Program To Find The Result of X + X^2 + X^3+....+ X^n */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int i=0,sum=0,x,n;  
   clrscr();  
   printf("Enter the value of X: ");  
   scanf("%d",&x);  
   printf("\nEnter the value of n: ");  
   scanf("%d",&n);  
   for(i=1;i<=n;i++)  
   {  
     sum=sum+pow(x,i);  
   }  
   printf("The sum of given series is: %d",sum);  
   getch();  
 }  

C Program To Find The Result of 1/2+2/3+3/4+..+10/11

/* C Program To Find The Result of 1/2+2/3+3/4+..+10/11 */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int i=0,sum=0;  
   clrscr();  
   for(i=1;i<=10;i++)  
   {  
     sum=sum+(i/i+1);  
   }  
   printf("The sum of given series is: %d",sum);  
   getch();  
 }  

C Program To Find The Result of 1+2-3+4+5-6+7...Up To 10

/* C Program To Find The Result of 1+2-3+4+5-6+7..Up To 10 */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int i=0,sum=0;  
   clrscr();  
   for(i=1;i<=10;i++)  
   {  
     if(i%3==0)  
       sum=sum-i;  
     else  
       sum=sum+i;  
   }  
   printf("The sum of given series is: %d",sum);  
   getch();  
 }  

C Program To Find The Result of 1-2+3-4+5-6+..Up To 10

/* C Program To Find The Result of 1-2+3-4+5-6+..Up To 10*/

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int i=0,sum=0;  
   clrscr();  
   for(i=1;i<=10;i++)  
   {  
     if(i%2==0)  
       sum=sum-i;  
     else  
       sum=sum+i;  
   }  
   printf("The sum of given series is: %d",sum);  
   getch();  
 }  

C Program To Find The Result of 1^2 + 2^2 + 3^3 + ....Up To 10

/*  C Program To Find The Result of 1^2 + 2^2 + 3^3 + .... Up To 10 */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int i=0,sum=0;  
   clrscr();  
   for(i=1;i<=10;i++)  
   {  
     sum=sum+i*i;  
   }  
   printf("The sum of given series is: %d",sum);  
   getch();  
 }  

Friday, 9 January 2015

C Progarm To Print Sum of First 10 Even Numbers

/*  C Progarm To Print Sum of First 10 Even Numbers  */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int i=0,sum=0;  
   clrscr();  
   for(i=1;i<=20;i++)  
   {  
     if(i%2==0)  
       sum=sum+i;  
   }  
   printf("The sum of given series is: %d",sum);  
   getch();  
 }  

C Program To Print The Sum of 1 to 10

/* C Program To Print The Sum of 1 to 10 */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int i=0,sum=0;  
   clrscr();  
   for(i=1;i<=10;i++)  
   {  
     sum=sum+i;  
   }  
   printf("The sum of 1-10 is: %d",sum);  
   getch();  
 }  

C Program To Print Even Numbers From 1 to 10

/* C Program To Print Even Numbers From 1 to 10 */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include <stdio.h>  
 #include <conio.h>  
 void main()  
 {  
   int i=0;  
   clrscr();  
   for(i=1;i<=10;i++)  
   {  
     if(i%2==0)  
       printf("%d\n",i);  
   }  
   getch();  
 }  

C Program To Print Number From 10 to 1

/* C Program To Print Number From 10 to 1 */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include <stdio.h>  
 #include <conio.h>  
 void main()  
 {  
   int i=0;  
   clrscr();  
   for(i=10;i>0;i--)  
   {  
     printf("%d\n",i);  
   }  
   getch();  
 }  

C Program To Print Number From 1 to 10

/* C Program To Print 1 to 10 */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include <stdio.h>  
 #include <conio.h>  
 void main()  
 {  
   int i=0;  
   clrscr();  
   for(i=0;i<10;i++)  
   {  
     printf("%d\n",i);  
   }  
   getch();  
 }  

C Program For Calclulator

/* Calculator program in C */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.



 #include <stdio.h>  
 #include <conio.h>  
 void sum(int a, int b);  
 void mul(int a, int b);  
 void div(int a, int b);  
 void sub(int a, int b);  
 void main()  
 {  
   int n1,n2,choice;  
   clrscr();  
   printf("Enter first number: ");  
   scanf("%d",&n1);  
   printf("\nEnter second number: ");  
   scanf("%d",&n2);  
   printf("\n\nChoose your operation: ");  
   printf("\n1.Addition");  
   printf("\n2.Subtraction");  
   printf("\n3.Multiplication");  
   printf("\n4.Division");  
   scanf("%d",&choice);  
   switch(choice)  
   {  
     case 1:  
       sum(n1,n2);  
       break;  
     case 2:  
       sub(n1,n2);  
       break;  
     case 3:  
       mul(n1,n2);  
       break;  
     case 4:  
       div(n1,n2);  
       break;  
     default:  
       printf("Please enter the valid choice next time..");  
   }   
   getch();  
 }  
 void sum(int a, int b)  
 {  
   printf("The sum of %d and %d is: %d",a,b,a+b);  
 }  
 void sub(int a, int b)  
 {  
   printf("The subtraction of %d and %d is: %d",a,b,a-b);  
 }  
 void mul(int a, int b)  
 {  
   printf("The multiplication of %d and %d is: %d",a,b,a*b);  
 }  
 void div(int a, int b)  
 {  
   if(b!=0)  
     printf("The division of %d and %d is: %d",a,b,a/b);  
 }  

Thursday, 8 January 2015

C Program To Calculate Simple Interest

/* Calculating simple interest in C */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int p,r;  
   float n,interest=0.0;  
   clrscr();  
   printf("Enter the value of p: ");  
   scanf("%d",&p);  
   printf("Enter the value of r: ");  
   scanf("%d",&r);  
   printf("Enter the value of n: ")  
   scanf("%f",&n);  
   interest=(p*r*n)/100;  
   printf("The simple interest is: %f",interest);  
   getch();  
 }  

C Program To Convert Temperature From Celsius To Fahrenheit

/* c program to convert temperature from celsius to fahrenheit  */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   float temp_in_cel,temp_in_fr=0.0;  
   clrscr();  
   printf("Enter temperature in Celsius: ");  
   scanf("%f",&temp_in_cel);  
   temp_in_fr=(temp_in_cel*1.8)+32;  
   printf("Temperature in Fahrenheit is: %f",temp_in_fr);  
   getch();  
 }  

C Program To Swap Two Numbers Without Using Third Variable(Using Multiplication)

/* Swapping of two numbers without using third variable in c(using multiplication) */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int first_number, second_number;  
   clrscr();  
   printf("Enter the first number: ");  
   scanf("%d",&first_number);  
   printf("Enter the second number: ");  
   scanf("%d",&second_number);  
   first_number=first_number*second_number;  
   second_number=first_number/second_number;  
   first_number=first_number/second_number;  
   printf("After swapping first number is: %d and \nsecond number is: %d",first_number,second_number);  
   getch();  
 }  

C Program To Swap Two Numbers Without Using Third Variable

/* Swapping of two numbers without using third variable in c(using addition) */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int first_number, second_number;  
   clrscr();  
   printf("Enter the first number: ");  
   scanf("%d",&first_number);  
   printf("Enter the second number: ");  
   scanf("%d",&second_number);  
   first_number=first_number+second_number;  
   second_number=first_number-second_number;  
   first_number=first_number-second_number;  
   printf("After swapping first number is: %d and \nsecond number is: %d",first_number,second_number);  
   getch();  
 }  

C Program To Swap Two Numbers

/* Swapping of two numbers in c using third variable */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int first_number, second_number;  
   clrscr();  
   printf("Enter the first number: ");  
   scanf("%d",&first_number);  
   printf("Enter the second number: ");  
   scanf("%d",&second_number);  
   first_number=first_number*second_number;  
   second_number=first_number/second_number;  
   first_number=first_number/second_number;  
   printf("After swapping first number is: %d and \nsecond number is: %d",first_number,second_number);  
   getch();  
 }  

C Program To Check Number is Odd or Even

/* Check number is odd or even in c */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int n;  
   clrscr();  
   printf("Enter the number: ");  
   scanf("%d",&n);  
   if(n%2==0)  
   {  
     printf("Number is even");  
   }  
   else  
   {  
     printf("Number is odd");  
   }  
   getch();  
 }  

C Program To Find Maximum Out of Three Numbers

/* Addition of two number in c */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   clrscr();  
   printf("Enter the value of first number: ");  
   scanf("%d",&n1);  
   printf("Enter the value of second number: ");  
   scanf("%d",&n2);  
   printf("Enter the value of third number: ");  
   scanf("%d",&n3);  
   if(n1>n2 && n1>n3)  
   {  
     printf("%d is maximum",n1);  
   }  
   else  
   {  
     if(n2>n3)  
     {  
       printf("%d is maximum",n2);  
     }  
     else  
     {  
       printf("%d is maximum",n3)  
     }  
   }  
   getch();  
 }  

C Program To Find Maximum of Two Numbers

/* Maximum of two number in c */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   clrscr();  
   printf("Enter the value of first number: ");  
   scanf("%d",&n1);  
   printf("Enter the value of second number: ");  
   scanf("%d",&n2);  
   if(n1>n2)  
   {  
     printf("%d is maximum",n1);        
   }  
   else  
   {  
     printf("%d is maximum",n2)  
   }    
   getch();  
 }  

C Program To Find The Area of Circle

/*  Find the area of circle */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int r;  
   float area=0.0;  
   clrscr();  
   printf("Enter the radius of circle");  
   scanf("%d",&r);  
   area=3.14*r*r;  
   printf("Area of circle is: %f",area);  
   getch();  
 }  

C Program To Calculate Average of Two Numbers

/* Average of two number in c */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
      int n1,n2;  
      float avg=0.0;  
      clrscr();  
      printf("Enter the first number: ");  
      scanf("%d",&n1);  
      printf("\nEnter the second number");  
      scanf("%d",n2);  
      avg=(n1+n2)/2;  
      printf("\nThe average of two number is: %f",avg);  
      getch();  
 }  

C Program To Add Two Numbers

/* Addition of two numbers in c */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
      int n1,n2,result=0;  
      clrscr();  
      printf("Enter first number: ");  
      scanf("%d",&n1);  
      printf("\nEnter the second number: ");  
      scanf("%d",&n2);  
      result=n1+n2;  
      printf("\nThe sum of two number is: %d",result);  
      getch();  
 }  

C Program To Print Hello World

This post is about to print simple Hello world in C.

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
      clrscr();  
      printf("Hello world..");  
      getch();  
 }  

Format of C Program

Hi friends, This post is about to learn Basic format of c program. If you don't know how to program then you can easily write following code for start up and then start thinking beyond. It is very useful for exam purpuse also.

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
      clrscr();  
      //More code here  
      getch();  
 }