#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...
Introduction of C-language 1. C-language was developed by Dennis Ritchie . In the year 1972 in Bell Laboratory in USA . C language suitable for system programmings ,it was mainly developed for UNIX operating system . Dennis Ritchie (1941-2011) Books:- The C Programming languages Dennis Ritchie also known as father of C-language. Use of C-language 👉🏿Operating system. 👉🏿Language Compiler. 👉🏿Text editor. 👉🏿Modern Program. 👉🏿Database. 👉🏿Language interpreter. 👉🏿Mobile & desktop application. 👉🏿 Gaming & Animation. ...
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; ...
#include<stdio.h> int main() { int a,b,c,d,x,m,rev; printf("Enter four digit numbers\n"); scanf("%d",&x); m=x; a=x%10; x=x/10; b=x%10; x=x/10; c=x%10; x=x/10; d=x%10; x=x/10; rev=a*1000+b*100+c*10+d; if(rev==m) { printf("Enter Number is Palindrome"); } else { printf("Enter number is not Palindrome"); } } OUTPUT Enter four digit numbers 1771 Enter Number is Palindrome
Nice program
ReplyDelete