Program to cheque enter number is even or odd using switch case in C-language
Get link
Facebook
X
Pinterest
Email
Other Apps
-
#include<stdio.h>
int main()
{
int x;
printf("Enter the number\n");
scanf("%d",&x);
switch(x%2)
{
case 0:
printf("Enter numbet is even");
break;
default:
printf("Enter number is odd");
break;
#include<stdio.h> int main() { int a,b,f; printf("Enter the decimal number\n"); scanf("%d",&a); printf("Binary of %d is\n",a); while(a>0) { b=a%2; a=a/2; f=f*10+b; } printf("%d",f); } OUTPUT Enter the decimal number 15 Binary of 15 is 1111 Visit Homepage
Program to cheque enter number is even or odd in c-language #include<stdio.h> int main() { int x; printf("Enter the number\n"); scanf("%d",&x); if(x%2==0) { printf("Enter number %d is even",x); } else { printf("Enter number %d is odd",x); } } OUTPUT Enter the number 17 Enter number 17 is odd Visit Homepage
Program to print the cube of a number in c-language Method-1 #include<stdio.h> main() { int x,y; printf("Enter the number for cube\n"); scanf("%d",&x); y=(x*x*x); printf ("Cube of the number is=%d",y); } Method-2 #include<stdio.h> #include<math.h> main() { int x,y; printf("Enter the number for cube\n"); scanf("%d",&x); y=pow(x,3); printf ("Cube of the number is=%d",y); } OUTPUT Enter the number for cube 5 Cube of the number=125 This program is perfect example of pow function and also describe the math.h header files. By using this function you can find any power of any number. But in this program it is...
Variable & Datatype for C-programming 5 Variable:- Whose value change is known as variable.You can use some specific variable. Ex:-a,b,c A,B,C a1,b2 But 1a,2b, space, special character are not allowed. Underscore is allowed. Datatype:- Before declaration variable you need to define the type of variable i.e. integer, character, float etc Variable declaration:- You can define a variable in following way. Syntax:- datatype variablename; Eg:-int x; int a; float q; Variable intialization:- In this step you have to give the value of variable. During character intialization write character within the ' ' Eg:-int x=1; or int x; x=1; ...
Division of two numbers in C-language #include<stdio.h> int main() { float x,y,z; printf ("Enter two numbers"); scanf("%f%f",&x,&y); z=x/y; printf("Division of two numbers are=%f",z); } OUTPUT Enter two numbers 20 5 Division of two numbers are=4.000000 Division of two number is simple program of C-language.After reading this program you will be able to form simple mathematics division . If you like this program then you can share it and for any issues you can direct contact with me from Home Page . For regular updates you can also follow my site.
#include<stdio.h> int main() { int x,f=1,i; printf("Enter the number\n"); scanf("%d",&x); for(i=1;i<=x;i++) { f=f*i; } printf("Factorial of %d is=%d",x,f); } OUTPUT Enter the number 5 Factorial of 5 is=120
Comments
Post a Comment