0% found this document useful (0 votes)
17 views

Lab Programs - C++

Uploaded by

chinnathambi0k4
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Lab Programs - C++

Uploaded by

chinnathambi0k4
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

// Program to check whether the input character is lower-case or upper-case

#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();
}

You might also like