1- Write a program to print table for the given number using while loop in C language.
#include<stdio.h>
#include<conio.h>
int main()
{
int i=1, number ;
clrscr();
printf(“Enter a number :”);
scanf(“%d”,&number);
while(i<=10)
{
Printf(“%d\n”,(number * i));
I++;
}
getch();
}
Output:-
Enter a number: 5
5 10 15 20 25 30 35 40 45 50
Write a program in C language using for loop.
#include<stdio.h>
#include<conio.h>
int main()
{
int i=1;
while(i<=10)
{
printf(“%d ”, i );
i++;
}
getch();
}
Output:- 1 2 3 4 5 6 7 8 9 10
Program in c language using if-else condition.
3-write a c lamguage program to print “Hello world!” using while loop.
#include<stdio.h>
#include<conio.h>
int main()
{
int i=1;
while(i<=5)
{
printf(“Hello world!” );
i++;
}
getch();
}
Output:- Hello world! Hello world! Hello world! Hello world! Hello world!
Example- 0, 1, 153, 370, 371, 407 …….
4-Write a program in c language to check Armstrong Number.
#include<stdio.h>
#include<conio.h>
int main()
{
int n, r, sum=0, temp;
clrscr();
printf(“Enter the number=”);
scanf(“%d”, &n);
temp=n;
while(n>0)
{
r=n%10;
sum = sum+ (r*r*r);
n=n/10;
}
if ( temp= =sum )
printf(“Armstrong number”);
else
printf(“Not Armstrong number”);
getch();
}
Output:-
Enter the number= 153
Armstrong number
Write a C-language program for Addition,Substraction,Multiplication and Division.
5- Write a program in C language for Factorial of a number.
#include<stdio.h>
#include<conio.h>
void main()
{
int n, i=1, f=1;
clrscr();
printf(“\n Enter a number for factorial:-”);
scanf(“%d”,&n);
while(i<=n)
{
f=f * i ;
i++;
}
printf(“ The Factorial of %d is %d”,n, f);
getch();
}
Output:- Enter a number for factorial:- 6
The Factorial of 6 is 720
#include<iostream.h>
using namespace std;
int main()
{
int i=1, number ;
clrscr();
cout<<“Enter a number :”;
cin>>(“%d”,&number) ;
while(i<=10)
{
cout<<“%d\n”,(number * i) ;
I++;
}
getch();
}
Output:-
Enter a number: 2
2 4 6 8 10 12 14 16 18 20
How to WAP in C-language program to find out area of rectangle,square,triangle,circle.
While loop concept program |
#include<stdio.h>
#include<conio.h>
int main()
{
int i=1, number ;
clrscr();
printf(“Enter a number :”);
scanf(“%d”,&number);
while(i<=10)
{
Printf(“%d\n”,(number * i));
I++;
}
getch();
}
Output:-
Enter a number: 5
5 10 15 20 25 30 35 40 45 50
Write a program in C language using for loop.
2-write a c lamguage program to print 1 to 10 numbers using while loop.
#include<stdio.h>
#include<conio.h>
int main()
{
int i=1;
while(i<=10)
{
printf(“%d ”, i );
i++;
}
getch();
}
Output:- 1 2 3 4 5 6 7 8 9 10
Program in c language using if-else condition.
3-write a c lamguage program to print “Hello world!” using while loop.
#include<stdio.h>
#include<conio.h>
int main()
{
int i=1;
while(i<=5)
{
printf(“Hello world!” );
i++;
}
getch();
}
Output:- Hello world! Hello world! Hello world! Hello world! Hello world!
::-Armstrong Number:-
Armstrong Number is a number that is equel to the sum of cubes of its all digits.Example- 0, 1, 153, 370, 371, 407 …….
4-Write a program in c language to check Armstrong Number.
#include<stdio.h>
#include<conio.h>
int main()
{
int n, r, sum=0, temp;
clrscr();
printf(“Enter the number=”);
scanf(“%d”, &n);
temp=n;
while(n>0)
{
r=n%10;
sum = sum+ (r*r*r);
n=n/10;
}
if ( temp= =sum )
printf(“Armstrong number”);
else
printf(“Not Armstrong number”);
getch();
}
Output:-
Enter the number= 153
Armstrong number
Write a C-language program for Addition,Substraction,Multiplication and Division.
5- Write a program in C language for Factorial of a number.
#include<stdio.h>
#include<conio.h>
void main()
{
int n, i=1, f=1;
clrscr();
printf(“\n Enter a number for factorial:-”);
scanf(“%d”,&n);
while(i<=n)
{
f=f * i ;
i++;
}
printf(“ The Factorial of %d is %d”,n, f);
getch();
}
Output:- Enter a number for factorial:- 6
The Factorial of 6 is 720
6- Write a program to print table for the given number using while loop in C++ language.
#include<iostream.h>
using namespace std;
int main()
{
int i=1, number ;
clrscr();
cout<<“Enter a number :”;
cin>>(“%d”,&number) ;
while(i<=10)
{
cout<<“%d\n”,(number * i) ;
I++;
}
getch();
}
Output:-
Enter a number: 2
2 4 6 8 10 12 14 16 18 20
How to WAP in C-language program to find out area of rectangle,square,triangle,circle.
0 Comments