Saturday 25 August 2018

C Program for Sum of Odd and Even Number Separately Using For Loop & If and Else Function | Dev C++ | TurboC |

C Program for Sum of Odd and Even Number Separately Using For Loop & If and Else Function 


#include <stdio.h>
main()
{
int num,i,n,sumodd=0,sumevv=0; /*Declaration of variables and some variables like sumodd & sumevv are also declared and initialised with the value of zero */
printf("Enter A Value for Loop:\n"); /*Need the number or the value of the number of loops in for loop*/
scanf("%d",&n); 
printf("Enter Values to be Sum\n"); /*Enter those numbers that will be added to the for loop at a later time*/
for(i=1;i<=n;i++)
{
scanf("%d",&num); /* provided numbers*/
if(num%2==0) 

/*If else condition for detecting odd and even number*/

/*Even number divided by 2 the remainder will be zero so the even number will go in the IF condition the odd number divided by 2 the remainder will not be zero so the odd number will go for ELSE condition*/

{
if(num>0) /* IF ELSE for Only positive or greater than zero integer will be able for addition less than zero or negative valid integer will be rejected */
{
sumevv+=num; //sumevv=sumevv+num;
}
else
{
continue;
}
}
else
{
if(num>0) /* IF ELSE for Only positive or greater than zero integer will be able for addition less than zero or negative valid integer will be rejected */
{
sumodd+=num; //sumodd=sumodd+num;
}
else
{
continue;
}
}
}
printf("\nODD SUM = %d",sumodd); /*For printing the sum of odd numbers*/ 
printf("\nEVEN SUM = %d",sumevv); /*
For printing the sum of even numbers*/

}

Wednesday 22 August 2018

C Program forCalculate Power & and Inverse of any Variable | C Program to Calculate the Power of a Number | Basic C Program to Calculate the Power of a Number Using For Loop and IF Else

Calculate Power & and Inverse of any Variable C Program

 C Program to Calculate the Power of a Number 

Basic C Program to Calculate the Power of a Number Using For Loop and If - Else

#include <stdio.h>
main()
{
/* This Program is done by Anupam Dutta aka King Anupam dutta */
int i,a,b; /* declaration of variable */
float mult=1.0; /* a float variable "mult" declared and initialised */
printf("\nEnter a Value:\n");
scanf("%d",&a);
printf("\nEnter the Power of the Value (^x):\n");
scanf("%d",&b);
if(b>0)  /*This single program can calculate power of a variable and as well as the inverse of the variable, so I am putting a "if - else" condition to give a choise that if it is less than zero then it will form the inverse calculation & if it will be greater than zero then it will conduct the power calculation of the Veriable*/
{
for(i=1;i<=b;i++)
{
mult=mult*a;
}
}
else if(b<0)
{
for(i=b;i<0;i++)
{
mult=mult/a;
}
}
else  /*If the condition value is equal to zero at any given time then we all know that if  power of  a number is 0, then its value is one, So here we initialised the mult as value 0.*/
{
mult=1.0; /*initialised the mult as value 0.*/
 printf("Enter the Currect Power Value (Value > 0 or Value < 0 ) If Value is Equal to Zero then   Value Will be %f",mult);
}
printf("\n The Value : \n %d ^ %d Will Be = %f \n",a,b,mult); /*Printing the ultimate result*/
main();/*Calling the main function for creating a loop & Continuing the whole program*/
getch();
}

PubG

PUBG Live

Tuesday 21 August 2018

Calculator Using C & Function Calling in C Programming | Additaddition & Dvision & Multiplication & Subtraction, Power and Percentage Calculator in one Program Using C |

*Calculator Using C & Function Calling in C Programming*

 Additaddition & Dvision & Multiplication & Subtraction, Power and Percentage Calculator in one Program Using C

How to make a fully functional calculator using C Programming?

***  A function declaration tells the compiler about a function's name, return type, and parameters. A function definition provides the actual body of the function.


#include <stdio.h>
float add(float); /*declaration of Functions */
float sub(float); /*declaration of Functions */
float mut(float);/*declaration of Functions */
float div(float); /*declaration of Functions */
float per(float); /*declaration of Functions */
float power(float); /*declaration of Functions */
float reset(float); /*declaration of Functions */
float result; /*declaration of an Universal float variable*/
main()
{      /* Created By Anupam Dutta aka King Anupam Dutta */
       /* Do not copy the program by close your eyes Read the complete program, analyze the program & then copy*/

          float a;
int fun;
if(result==0.0)
{
printf("\nEnter A Value:\n");
scanf("%f",&a);
}
else
{
a=result;
}
printf("\n\nEnter A Function\n1 for Addition\n2 for Subtraction\n3 for Multiplication\n4 for Division\n5 for Percentage\n6 for to the Power (x^) Function\n7 for Reset\n\n <<Enter Value 0 For HELP!!>> \n");
scanf("%d",&fun);
switch(fun) /*using switch case for calling different function */
{
case 0:
printf("\n Please Contact with Mr. Anupam Dutta \n \n Contacts Details:- \n \n Ph No.- 9163142597 \n Email:- anupamdatta12@gmail.com \n");
getch();
break;
case 1:
add(a);
break;
case 2:
sub(a);
break;
case 3:
mut(a);
break;
case 4:
div(a);
break;
case 5:
per(a);
break;
case 6:
power(a);
break;
case 7:
reset(a);
break;
}
}   /*main function Ends Here*/


float add(float x)
{
float b;
printf("\nEnter A Value:\n");
scanf("%f",&b);
result=x+b;
printf("\nResult:\n %f",result);
main();
}
float sub(float x)
{
float b;
printf("\nEnter A Value:\n");
scanf("%f",&b);
if(x>b)
{
result=x-b;
printf("\nResult:\n %f",result);
main();
}
else
{
result=b-x;
printf("\nResult:\n %f",result);
main();
}
}


float div(float x)
{
float b;
printf("\nEnter A Value:\n");
scanf("%f",&b);
if(x>b)
{
  if(result!=0)
  {
  result=x/b;
printf("\nResult:\n %f",result);
main();
}
else
{
result=1;
result=x/b;
printf("\nResult:\n %f",result);
main();
}
}
else
{
if(result!=0)
{
result=b/x;
printf("\nResult:\n %f",result);
main();
}
else
{
result=1;
result=b/x;
printf("\nResult:\n %f",result);
main();
}
}
}


float mut(float x)
{
float b;
if(result!=0)
{
printf("\nEnter A Value:\n");
scanf("%f",&b);
result=x*b;
printf("\nResult:\n %f",result);
main();
}
else
{
result=1;
printf("\nEnter A Value:\n");
scanf("%f",&b);
result=x*b;
printf("\nResult:\n %f",result);
main();
}
}


float per(float x)
{
if(result==0)
{
result=(x/100);
printf("\nResult:\n %f",result);
main();
}
else
{
float p;
printf("\nPlease Enter a Percent Value:\n");
scanf("%f",&p);
result=(p/100)*result;
printf("\nResult:\n %f",result);
main();
}
}


float power(float x)
{
int i;
float b;
result=x;
float mult=1.0;
printf("\nEnter the Power of the Value (^x):\n");
scanf("%f",&b);
if(b>0)
{
for(i=1;i<=b;i++)
{
mult=mult*x;
}
}
else if(b<0)
{
for(i=b;i<0;i++)
{
mult=mult/x;
}
}
else
{
printf("Enter the Currect Power Value");
}
result=mult;
printf("\n The Value : \n %f ^ %f Will Be = %f \n",x,b,result);
main();
}


float reset(float x)
{
result=0.0;
printf("Result = %f",result);
main();
}