prowessapps.in C++ utility programs

#include <ctime>
#include <iostream>
using namespace std;

int main() {
  time_t t = time(0);   // get time now
  struct tm * now = localtime( & t );
  cout<<"Today's Date is:\n";
  cout << (now->tm_year + 1900) << '-'
       << (now->tm_mon + 1) << '-'
       <<  now->tm_mday
       << endl;
  return 0;
}
OUTPUT
Today's Date is:
2017-3-24

#include< iostream>
#include< ctime>
using namespace std;
int main() {
 time_t now = time(0);
 tm *t = localtime(&now);
 cout << "Time: "<< ltm->tm_hour << ":";
 cout << ltm->tm_min << ":";
 cout << ltm->tm_sec << endl;
 return 0;
}
OUTPUT
Time: 23:12:20

#include< iostram>
#include< ctime>
#include< cstdlib>
using namespace std;
int main() {
 srand((unsigned)time(0));
 int x,n;
 int low, high;
 cout<<"Enter Range: ";
 cin>>low>>high;
 cout<<"Enter Number ";
 cin>>n;
 int r=(high-low)+1;
 for(int i=0; i< n; i++){
  x = low+int(r*rand()/(RAND_MAX+1));
  cout << x << endl;
 }
return 0;
}

OUTPUT
Enter Range: 10 100
Enter Number 5
61
44
44
49
53

#include< iostream>
#include< windows.h>
#include< stdlib.h>
using namespace std;
int main() {
 HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
 SetConsoleTextAttribute(hConsole, 12);
 cout <<"pwessapps.in"<< endl;
 return 0;
}

OUTPUT
C Prowess!!

#include< iostream>
using namespace std;
int main(int c, char *v[])
{
 if(c!=2) {
   cout<<"NO-NAME!!";
 }
 else {
  cout<<"Hello "<< v[1];
 }
  return 0;
}


OUTPUT
ATTEMPT:1
 ~Desktop$ g++ demo.cpp
 ~Desktop$ ./a.out

  NO-NAME!!

ATTEMPT:2
 ~Desktop$ g++ demo.cpp
 ~Desktop$ ./a.out AYAN

  Hello AYAN!!

#include< stdarg.h>
#include< iostream>
using namespace std;
void sum(int, ...);

int main( )
{
 sum(10,20);
 sum(10,20,30,40);
 return 0;
}

void sum(int c, ...)
{
   int val = 0;
   va_list ap;
   int i;

   va_start(ap,c);
   for(i = 0; i < c; i++)
   {
      val += va_arg(ap, int);
   }
   cout<<"Sum = "<< val<< endl;
   va_end(ap);
}

OUTPUT
Sum = 30
Sum = 100

#include< iostream>
#include< string>
#include< conio.h>
using namespace std;
int main(){
 string pass ="";
 char ch;
 cout <<"Enter pass\n";
 ch = _getch();
 while(ch != 20){//character 13 is enter
  pass.push_back(ch);
  cout << '*';
  ch = _getch();
 }
 cout<<"Password : "<< pass;
 return 0;
}
OUTPUT
Enter password : *******
Password : Prowess

#include< iostream>
using namespace std;
int main() {
 float c,f;
 cout<<"Enter Temp in (F): ";
 cin>>f;
 c = (5.0/9.0)*(f-32);
 cout<<"Temp in Celcious = "<< c;
 return 0;
}

OUTPUT
Enter Temp in (F): 35
Temo in Celcious = 1.6667

#include< iostream>
using namespace std;
int main() {
 int tms, ts, tm;
 cout<<"Enter Time in millis: ";
 cin>>tms;
 ts = tms/1000;
 tm = ts/60;
 ts = ts%60;
 cout<<"Time- "<< tm<<":"<< ts;
 return 0;
}

OUTPUT
Enter Time in millis: 72014
Time- 1:12

#include< iostream>
using namespace std;
int main() {
 int a,b;
 cout<<"Enter Value for A: ";
 cin>>a;
 cout<<"Enter Value for B: ";
 cin>>b;
 (a>b)?cout<<"A is Greater":cout<<"B is greater ";
 return 0;
}

OUTPUT
Enter Value for A: 10
Enter Value for B: 20
B is Greater

#include< iostream>
using namespace std;
int main() {
 int a,b,diff;
 cout<<"Enter value for A: ";
 cin>>a;
 cout<<"Enter value for B: ";
 cin>>b;
 diff = (a>b)?(a-b):(b-a);
 cout<<"Diff. = "<< diff;
 return 0;
}

OUTPUT
Enter Value for A: 10
Enter Value for B: 20
Diff. = 10

#include<stdio.h>
#include <time.h>
#include <unistd.h>
#include<iostream>
using namespace std;

int main(void)
{
  while(1)
    {
     time_t t = time(0);   // get time now
     struct tm * now = localtime( & t );
     cout<< (now->tm_hour)
         <<":"<< (now->tm_min)<<":"
         <<(now->tm_sec)<<"\r";
     sleep(1);
	}
 return 0;
}



Get it on Google Play


CONTACT DETAILS

info@prowessapps.in
(8AM to 10PM):

+91-9026070669 , +91-9451396824

© 2016, prowessapps.in, All rights reserved