Program to print product of digit using while loop in C-language
Get link
Facebook
X
Pinterest
Email
Other Apps
-
#include<stdio.h>
int main()
{
int n,a,p=1;
printf("Enter the number\n");
scanf("%d",&n);
while(n!=0)
{
a=n%10;
n=n/10;
p=p*a;
}
printf("Product of digit=%d",p);
}
Program to show present time and date in C-language. #include <stdio.h> #include <string.h> int main() { char time[10]; char date[12]; strcpy(time, __TIME__); strcpy(date, __DATE__); printf("%s %s\n", time, date); return 0; } OUTPUT 08:17:09 May 25 2020 The above time and date change according to you when you run the program,So it show different time. If you like this program you can share comments and follow.
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. Features of C-language ๐๐ฟ Compiler based. ๐๐ฟCase sensitive. ๐๐ฟ Simple & Powerful. ๐๐ฟ Syntax based. ๐๐ฟ Structure oriented. ๐๐ฟ Middle level. After reading this article you will be able to know about C-language, features,use of c-language,and more things related to C-l
#include<stdio.h> int main() { int a,b,c,x,s; printf("Enter three digit numbers\n"); scanf("%d",&x); a=x%10; x=x/10; b=x%10; x=x/10; c=x%10; x=x/10; s=a*b*c; printf("Product of digit=%d",s); } OUTPUT Enter three digit numbers 234 Product of digit=24
Program to cheque enter number is a perfect number or not in C-language #include<stdio.h> int main() { int a,i,s=0; printf("Enter the number\n"); scanf("%d",&a); for(i=1;i<a;i++) { if(a%i==0) { s=s+i; } } if(s==a) { printf("Enter number is perfect number"); } else { printf("Enter number is not perfect number"); } } OUTPUT Enter the number 28 Enter number is perfect number This program help you to cheque enter number is perfect number or not and also this program help you to make logics of coming program. 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. Visit Homepage
#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
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 used to cube 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
Simple Hello world program in c- language. #include<stdio.h> int main() { printf("Hello world"); } OUTPUT Hello world Hello world is basic program of C-language, from Hello world coding of C-language start. In this program you will be able to print anything like name,text number. 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 i,n,sum=0; printf("Enter the last number\n"); scanf("%d",&n); printf("All even number from 1to %d is\n",n); for(i=2;i<=n;i+=2) { printf("%d ",i); } } OUTPUT Enter the last number 9 All even number from 1 to 9 is 2 4 6 8
Comments
Post a Comment