1. Write a Program to take input from user print sum of it's number using while loop c program
2. Write a Program to take input from user print number in reverse order using while loop c program
Ex :- 3586
Output :- 6853
3. Write a Program take number from user and print table of that number using while loop c program
1.
Write a Program to take input from user print sum of it's number using while loop c program - Program Code
/* Write a Program to take input from user print sum of it's number using while loop */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,a,num,sum=0;
clrscr();
printf("Enter number : ");
scanf("%d",&num);
while(num!=0)
{
a=num%10;
sum = sum + a;
num=num/10;
}
printf("Sum of it's number = %d",sum);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,a,num,sum=0;
clrscr();
printf("Enter number : ");
scanf("%d",&num);
while(num!=0)
{
a=num%10;
sum = sum + a;
num=num/10;
}
printf("Sum of it's number = %d",sum);
getch();
}
Download Program source code
2.
Write a Program to take input from user print number in reverse order using while loop c program - Program Code
Ex :- 3586
Output :- 6853
/* Write a Program to take input from user print number in reverse order using while loop
Ex :- 3586
Output :- 6853 */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,num,reverse=0,a;
clrscr();
printf("Enter number : ");
scanf("%d",&num);
while (num!=0)
{
a=num%10;
reverse = reverse*10+a;
num=num/10;
}
printf("Reverse number = %d",reverse);
getch();
}
Ex :- 3586
Output :- 6853 */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,num,reverse=0,a;
clrscr();
printf("Enter number : ");
scanf("%d",&num);
while (num!=0)
{
a=num%10;
reverse = reverse*10+a;
num=num/10;
}
printf("Reverse number = %d",reverse);
getch();
}
Download Program source code
3.
Write a Program take number from user and print table of that number using while loop c Program - Program Code
/* Write a Program take number from user and print table of that number using while loop */
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1,num;
clrscr();
printf("Enter number : ");
scanf("%d",&num);
printf("Table of %d number\n",num);
while(i<=10)
{
printf("%d * %d = %d\n",num,i,num*i);
i++;
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1,num;
clrscr();
printf("Enter number : ");
scanf("%d",&num);
printf("Table of %d number\n",num);
while(i<=10)
{
printf("%d * %d = %d\n",num,i,num*i);
i++;
}
getch();
}
0 Comments
If You have any query, Please let me know..