Posts

Showing posts from March, 2018

C++ program show the largest element of the Array:

Image
C++ program show the largest element of the Array: #include <iostream> using namespace std; int main() { int userenter,loopstart,x=1; while (x!=0) { cout<<"Enter the size of the array:"<<"\n";       cin>>userenter;     cout<<"Enter  "<<userenter<<"  number for cheking the greatest element of array:"<<"\n";     int largestelement[userenter];     for(loopstart=0; loopstart<userenter; loopstart++)       {       cin>>largestelement[loopstart];     }     cout<<"Each subscript with its own value:"<<"\n";     for(loopstart=0; loopstart<userenter; loopstart++)     {       cout<<"largestelement"<<"["<<loopstart<<"]"<<"="<<largestelement[loopstart];     cout<<"\n";     }   ...

C++ program to hours, minutes, seconds in 24 hours and 12 hours format.

Image
C++ program to hours, minutes, seconds in 24 hours and 12 hours format. #include <iostream> using namespace std; int main() { int hours,minutes,seconds,update; cout<<"Enter hours:"<<"\n"; cin>>hours; if(hours<24) { cout<<"Enter minutes:"<<"\n"; cin>>minutes; if(minutes<=59) { cout<<"Ente Seconds:"<<"\n"; cin>>seconds; if(seconds<=59) {     if(hours>=12) { cout<<"Time formate of 24 hours:"<<"\n";         cout<<hours<<":"<<minutes<<":"<<seconds<<" "<<"PM"<<"\n\n"; } else {     cout<<"Time formate of 24 hours:"<<"\n";         cout<<hours<<":"<<minutes<...

C++ program to find the prime number...

Image
C++ program to find the prime number... Prime number:                     A number which is only divisible by 1 and itself. e.g 3,5,7 #include <iostream> using namespace std; int main() { int user,count=1; cout<<"Enter a number:"<<"\n"; cin>>user; for(int i=2; i<=user; i++) { for(int j=2; j<=i; j++)     {     if(i%j==0)     {     if(i==2)     {     cout<<"\n"<<i<<"\n"; } break; } else if(i==j+1) { cout<<i<<"\n"; count++; } } } cout<<"\n Above first  "<<count<<"  prime number"<<"\n"; return 0; } output of above code:

C++ program to check that enter number is perfect or not..

Image
  C++ program to check that enter number is perfect or not.. Perfect Number:                     A positive integer that is equal to the sum of its proper divisor.                     e.g  6 is the sum of  1,2 and 3 which are the proper divisor. #include <iostream> using namespace std; int main() { int loopstart,usernum,result,label,x=1; while(x!=0) { int sum=0; cout<<"Enter number to check that the number is perfect number:"<<"\n";     cin>>usernum;     result=usernum;     for(loopstart=1; loopstart<=usernum/2; loopstart++)       {     if(usernum%loopstart==0)     {     sum=sum+loopstart;     }     if(result==sum)     {     cout<<usernum...

3rd lecture of java simple program.

Image

c++ program to show that user enter number is even or odd...?

Image
C++ program to  show that user enter number is even or odd Even number: A number which can divided by two and its remainder is  equal to zero. Odd number:    A number which can divided by two and its remainder is not equal to zero. #include <iostream> using namespace std; int main() { int no,x,y; while(x!=0) { cout<<"Enter a number:"<<"\n"; cin>>no; if(cin.fail()) { cout<<"You enter a wrong data"; break; } else if (no%2==0) { cout<<"This is an even number"<<"\n\n"; } else  { cout<<"This is an odd number"<<"\n\n"; } cout<<"press 0 for exit to programe (OR) for continue to press any key :"<<"\n"; cin>>x; } return 0; } output of the above code: