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