Lab Programs - C++
Lab Programs - C++
#include<iostream.h>
#include<conio.h>
void main()
{
char ch;
cout<<"Enter the character:";
cin>>ch;
if( ch>='A' && ch<='Z')
cout<<" It is an upper-case character"<<endl;
else
if (ch>='a' && ch<='z')
cout<<"It is a lower-case character"<<endl;
else
cout<<"it is not an alphabet";
getch();
//Program to find the sum of digits of a given number using while loop
#incude<iostream.h>
#include<conio.h>
void main()
{
int n, sum, rem;
clrscr();
cout<<“Enter the number:”;
cin>>n;
sum=0;
while(n!=0)
{
rem=n%10;
sum=sum+rem;
n=n/10;
}
cout<<“Sum of digits=”<<sum;
getch();
}
//Program to check whether given number is Armstrong number or not using do-while
loop.
#incude<iostream.h>
#include<conio.h>
void main()
{
int n, sum, rem,m ;
clrscr();
cout<<“Enter the number:”;
cin>>n;
m=n;
sum=0;
do
{
rem=n%10;
sum=sum+rem*rem*rem;
n=n/10;
} while(n!=0);
if( m==sum)
cout<<“Given number is Armstrong number"<<endl;
else
cout<<"Given number is not Armstrong number"<<endl;
getch();
}