Program to reverse a number in C
#include<stdio.h> #include<conio.h> void main() { int long a,n,rev=0; clrscr(); printf("enter any number"); scanf("%lld",&n); while(n>0) { a=n%10; rev=rev*10+a; n=n/10; } printf("%lld",rev); getch(); } Output:
#include<stdio.h> #include<conio.h> void main() { int long a,n,rev=0; clrscr(); printf("enter any number"); scanf("%lld",&n); while(n>0) { a=n%10; rev=rev*10+a; n=n/10; } printf("%lld",rev); getch(); } Output:
#include<stdio.h> #include<conio.h> void main() { long int a,n,sum=0; clrscr(); printf("enter any number"); scanf("%lld",&n); while(n>0) { a=n%10; // storing the remainder sum=sum+a; n=n/10; } printf("%lld",sum); getch(); } Output:
C program to print the table of any number entered by the user. #include<stdio.h> #include<conio.h> void main() { int a,b,c; clrscr(); printf("enter the value of a"); scanf("%d",&a); for (b=1;b<=10;b=b+1) {…
C program to print the absolute value of the given number. Absolute value is the actual value or magnitude without any sign. Suppose user entered a value -12 then the…
C PROGRAM TO ENTER A NUMBER BY USER AND TO CHECK WHETHER IT IS A PRIME NUMBER OR NOT. A prime number is a number that is divisible by itself…
Hello Programmers.....Now a simple program to print the Fibonacci series. Fibonacci series is a series of the numbers in which each number is the sum of two last numbers or two…
#include<stdio.h> #include<conio.h> void main() { int i,j,k; clrscr(); for(i=1;i<=5;i++) { for(k=1;k<=5-i;k++) { printf(" "); } for(j=1;j<=i;j++) { printf(" *"); } printf("\n"); } getch(); } Output:
Simple C program to print the mirrored right triangle pattern in C. #include<stdio.h> #include<conio.h> void main() { int i,j,k; clrscr(); for(i=0;i<=4;i++) { for(k=0;k<=4-i;k++) // for gap -->the gap is in…
A simple C program to print a right triangle pattern by using stars. There are various types of patterns. But i will be uploading the important patterns that will help…
A simple C program to print floyd's triangle. A user enters the number of rows as seen in the output. #include<stdio.h> #include<conio.h> void main() { int i,j,num=1,n; clrscr(); printf("enter the…