31/01/2023

Day 21 Generics Hackerrank Solution in C++ | 30 Days of Code
Day 21 Generics Hackerrank Solution in C++ and C. We have to just print the Generics array, we can do this by using the AUTO keyword in our program. I didn't understand why people don't use AUTO Keyword in C++. as you can see that Generics array means all types of data types in an array so for that this is a best practice to use the AUTO keyword in the problem.

Day 21 Generics Hackerrank Solution in C++

Objective: Today we're discussing Generics; be aware that not all languages support this construct, so fewer languages are enabled for this challenge. Check out the Tutorial tab for learning materials and an instructional video!

Task: Write a single generic function named printArray; this function must take an array of generic elements as a parameter (the exception to this is C++, which takes a vector). The locked Solution class in your editor tests your function.

Note: You must use generics to solve this challenge. Do not write overloaded functions.

Input Format: The locked Solution class in your editor will pass different types of arrays to your printArray function.

Constraints: You must have exactly 1 function named printArray.

Output Format: Your printArray function should print each element of its generic array parameter on a new line.

Copy the code and paste it into the Hackerrank editor and click to submit button, but before this process, you have to click the below link, this link takes to you the same problem Now you have to just log in if you are already not logged in and done.

Submit this solution: Click Here

Generics Hackerrank Solution in C++


#include <iostream>

#include <vector>

#include <string>

using namespace std;

template < class T >
  void printArray(vector < T > i) {
    for (int j = 0; j < i.size(); j++)
      cout << i[j] << endl;
  }

void printArray(vector < auto > a) {
  for (auto i: a)
    cout << i << endl;
}

int main() {
  int n;

  cin >> n;
  vector < int > int_vector(n);
  for (int i = 0; i < n; i++) {
    int value;
    cin >> value;
    int_vector[i] = value;
  }

  cin >> n;
  vector < string > string_vector(n);
  for (int i = 0; i < n; i++) {
    string value;
    cin >> value;
    string_vector[i] = value;
  }

  printArray < int > (int_vector);
  printArray < string > (string_vector);

  return 0;
}

Day 21 Generics Hackerrank Solution Output



Day 21 Generics Hackerrank Solution Output

Similar to 30 Days of Code


Top 10 Tips for Improving Your Website Design
Are you looking for ways to improve the design of your website? Many aspiring web designers don't know where to start, so we've put together a list of 10 tips that can help you get started. By following these simple steps, you'll be able to create a more professional-looking website that is easy to navigate and engaging for visitors.

Top 10 Tips for Improving Your Website Design

Top 10 Website Design Tips


  • Get Your Own Web-Making Software
  • Simplicity and Navigation
  • Responsive Design
  • Visual Appeal
  • Quality Content
  • User Experience
  • Add Mobile-Friendly Features
  • Search Engine Optimization (SEO)
  • Integrated Social Media Platforms
  • User Testing and Feedback Loops

From choosing the right colours to optimizing your content for search engines, these tips will make your website stand out from the crowd. So let's get started!

1. Get Your Own Web-Making Software


If you’re serious about web design, you should consider getting your own web-making software. This will give you more control over the look and feel of your website and make it easier to customize the code and add features.

A popular thing these days is to find someone to make you the software you want, and on the Global Software Companies website, you can find many leading software development companies who will help you build the website of your dreams. There are also plenty of websites offering tutorials, tips, and tools to help you with web design and development.

2. Simplicity and Navigation


When it comes to website design, it is important to keep things simple. Visitors should be able to quickly find what they need on your website with minimal clicks and confusion.

Making sure the navigation menu is visible and easy to understand will help visitors move around your site seamlessly. And, if you have multiple pages with similar content, consider adding internal links throughout the page to help visitors move around.

3. Responsive Design


Since mobile browsing has become increasingly popular, any website design must consider the different screen sizes people may use. Responsive design ensures that your website looks and functions properly on all devices, from smartphones to desktop computers.

Responsive Design

Making sure that your website is responsive will ensure a consistent experience for all visitors, no matter what device they use. Having a responsive website is important for your search engine optimization (SEO), too, as Google now uses mobile-first indexing, meaning that websites with a mobile version will be given priority in search rankings.

4. Visual Appeal


While a website should be organized, logical, and practical, there is nothing wrong with making it visually attractive as well. After all, you know what they say: “A picture is worth a thousand words.” So, make sure you include high-quality images with good resolution.

You should also consider adding videos, unique fonts, and other visual elements that can make your site more interesting. Plus, choose colours that match the theme of your website and will make it easier for users to find what they are looking for.

5. Quality Content


To create a website that is both attractive and successful, having quality content is essential. This means having high-quality images, compelling copy, and relevant information that engages visitors.

Read: 5 Professional Tips for a Faster Website Design

Also, it's important to create content with SEO in mind. Using targeted keywords throughout your site can help ensure your website appears in search results when people are looking for your services or products. Lastly, ensure all content is regularly updated and fresh to keep visitors returning.

6. User Experience


One key aspect of website design is ensuring users have a positive experience while on your site. This means having user-friendly navigation and a layout that makes it easy to find information quickly.

Additionally, make sure the design is responsive so visitors can view your site properly, no matter which device they are using. Use analytical tools to track user activity and identify areas that may need improvement.

7. Add Mobile-Friendly Features


Of course, with most of the web traffic coming from mobile devices, it’s important to ensure that your website is designed with attention to how users access content on their smartphones and tablets. Make sure your website is responsive – that it can resize depending on the device being used to view it.

Furthermore, consider using menus or navigation bars optimized for mobile, as well as click-to-call and click-to-map features. This will give your website visitors a seamless experience, no matter what device they use to view it.

8. Search Engine Optimization (SEO)


Incorporating SEO into your website design can benefit both the user experience and your search engine rankings. Using keywords strategically throughout your content can help ensure that your website appears in relevant searches.

Search Engine Optimization

This can increase the likelihood of people finding and visiting your site and improve overall user experience by providing them with more accurate results when they search. Plus, optimizing your site for specific keywords can help drive more organic traffic to your site and improve visibility on search engine results pages (SERPs).

9. Integrated Social Media Platforms


Nowadays, social media is an integral part of most people’s lives. As such, integrating them into your website can help you reach a wider audience and increase engagement. There are many ways to do this, including adding social sharing buttons to your pages or featuring a live stream of posts from popular platforms like Twitter or Instagram on your homepage.

This way, visitors can easily like and share your content, as well as leave comments. Not to mention, you could provide a link to your social media profiles so users can connect with you on these platforms.

10. User Testing and Feedback Loops


Lastly, one of the best ways to ensure your website design is effective and well-received is by continuously testing it with users and listening to their feedback.

Invite members of your target audience to test out the website and provide honest opinions on what they like, don’t like, or would improve. This direct feedback loop can help you identify any usability issues and ensure your design serves its purpose.

There Are Always Ways to Improve Your Website Design

Improve Your Website Design

When it comes to website design, there is always room for improvement. Whether you are just starting out or have been in the game for a while, there are always ways to make your site better and boost its functionality and appeal.

So, don't be afraid to keep pushing yourself and your website design skills further. Good luck!
School Management System Project in C++With Source Code
School Management System Project in C++With Source Code. This School Management System project has seven sections, first Create and Modify Admission Criteria, Student Data, Allotment of Stream, Display Criteria for Selection, Display allotment of Student Stream, Display all registered students and Create and display Merit list. 

School Management System Project in C++With Source Code

School Management System Project in C++With Source Code.


 #include<iostream.h>

 #include<conio.h>

 #include<stdio.h>

 #include<string.h>

 #include<iomanip>

 #include<fstream.h>

 #include<dos.h>

 using namespace std;

 struct marks_criteria {
   int sc_min, com_min, arts_min, seat_sc, seat_com, seat_arts;
 }
 crit;

 struct administrator {
   char user_name[10];
   char password[10];
 }
 admin;

 struct student {
   char name[20];
   int regno, m_eng, m_math, m_sc, m_sst, m_lang;
   int pref_code, stream;
   // Sc=1, Com=2; Arts=3;

   public:
     void new_file();
   void input_data();
   void allot_stream();
   int get_stream();
   void display();
   int show_per() {
     return ((m_eng + m_math + m_sc + m_sst + m_lang) / 5);
   }

 };
 void welcome();
 void menu();
 int verify_password();
 void assign_user();
 void clear();
 void input_criteria();
 void read_criteria();
 void read_student();
 void create_eligible_sc();
 void create_eligible_com();
 void create_eligible_arts();
 void read_eligible_sc();
 void read_eligible_com();
 void read_eligible_arts();
 char * stream_name(int strm);
 void select_list(char * in_file, char * out_file);
 void thanks();

 student s;
 main() {

   //     clrscr();
   welcome();

   // cout<<"welcome";
   fstream fin, fout;
   fstream fsc, fcom, farts;
   int opt = 1, ch;

   while (opt != 8) {
     // clrscr();

     clear();
     cout << "\n\t======================  MAIN   MENU  =======================\n";
     cout << "\n\t[1] CREATE / MODIFY  ADMISSION  CRITERIA(Administrator only)";
     cout << "\n\n\t[2] ENTER STUDENT'S DATA ";
     cout << "\n\n\t[3] ALLOTMENT OF  STREAM";
     cout << "\n\n\t[4] DISPLAY CRITERIA FOR SELECTION";
     cout << "\n\n\t[5] DISPLAY ALLOTMENT OF  STUDENT'S STREAM";
     cout << "\n\n\t[6] DISPLAY ALL  STUDENT'S REGISTERED";
     cout << "\n\n\t[7] CREATE / DISPLAY MERIT LIST";
     cout << "\n\n\t[8] QUIT";
     cout << "\n\t=============================================================\n";
     cout << "\n\n\t\tEnter your  choice : ";
     cin >> opt;
     switch (opt) {
     case 1:
       int p;
       assign_user();
       p = verify_password();
       if (p == 0) {

         input_criteria();
       } else {
         cout << "\n\tU R Not a Valid User.";
         cout << "\n\tU Dont have the Authority to Create Question Bank. Bye\n\n";
       }
       break;

     case 2:
       int option;
       //clrscr();
       cout << "\nWhat do u want --\n\n\n\n\n\tCreate  a new student information  file or Append to the existing file?\n\n\t(press 1 for new creation and 2 for appending)";
       cin >> option;
       if (option == 1) {
         s.new_file();
       } else {
         s.input_data();
       }
       break;

     case 3:
       //clrscr();
       // read_student();
       fin.open("student", ios::in | ios::out);

       fsc.open("elig_sc", ios::out);
       fcom.open("eligcom", ios::out);
       farts.open("eligart", ios::out);

       while (fin.read((char * ) & s, sizeof(s))) {

         s.allot_stream();

         s.get_stream();

         //if(s.get_stream()==0)
         cout << "\nApplication Rejected. Not Eligible\n";

         if (s.get_stream() == 1)
           fsc.write((char * ) & s, sizeof(s));

         if (s.get_stream() == 2)
           fcom.write((char * ) & s, sizeof(s));

         if (s.get_stream() == 3)
           farts.write((char * ) & s, sizeof(s));

       }
       fin.close();
       fsc.close();
       fcom.close();
       farts.close();
       cout << "\n*******************************************";
       cout << "\n\n\tSTREAM ALLOCATION DONE.";
       cout << "\n*******************************************";
       break;
     case 4:
       read_criteria();
       // clear();
       cout << "\n Sc : " << crit.sc_min;
       cout << "\n Com : " << crit.com_min;
       cout << "\n Sc : " << crit.arts_min;

       break;

     case 5:

       cout << "\n Enter 1 for Sc, 2 for Com, 3 for Arts  :  ";
       cin >> ch;
       if (ch == 1)
         read_eligible_sc();

       if (ch == 2)
         read_eligible_com();
       if (ch == 3)
         read_eligible_arts();

       break;
     case 6: //clrscr() ;
       read_student();
       break;
     case 7: {
       char c;
       int k = 1;
       cout << "\n****************************************";
       cout << "\n****************************************";
       cout << "\n    M E R I T  L I S T";
       cout << "\n    ==================";
       cout << "\n\tEnter 1 for MERIT LIST SCIENCE ";
       cout << "\n\tEnter 2 for MERIT LIST COMMERCE ";
       cout << "\n\tEnter 3 for MERIT LIST ARTS \t";
       cout << "\n****************************************";
       cout << "\n****************************************";
       cin >> k;
       if (k == 1) {
         select_list("elig_sc", "sell_sc");
         fin.open("sell_sc", ios::in);
       }
       if (k == 2) {
         select_list("eligcom", "sellcom");
         fin.open("sellcom", ios::in);
       }
       if (k == 3) {
         select_list("eligart", "sellart");
         fin.open("sellart", ios::in);
       }
       if (k >= 1 && k <= 3) {
         while (fin.read((char * ) & s, sizeof(s))) {
           s.display();

           cout << "\n\t Continue (y/n)?";
           cin >> c;
           if (c == 'n')
             break;

         }

       }
       fin.close();
       fin.close();
       fin.close();
       break;
     }
     case 8:
       thanks();
       // cout<<"\nTHANKS BYE ";
       // exit(0);
       break;
     }

   }

 }

 // END OF WHILE

 void assign_user() {

   strcpy(admin.user_name, "rimi");
   strcpy(admin.password, "rimi");

 }
 int verify_password() {
   char u_name[10];
   char u_pwd[10], temp[2];
   int x = 1;
   cout << "\n\n   Enter user name : ";
   cin >> u_name;
   cout << "\n\n   Enter Password : ";
   cin >> u_pwd;
   x = strcmp(admin.user_name, u_name);
   if (x == 0) {
     x = strcmp(admin.password, u_pwd);

   }
   cin.getline(temp, 2);
   return (x);

 }
 void student::allot_stream() {
   int per = (m_eng + m_math + m_sc + m_sst + m_lang) / 5;
   read_criteria();

   switch (pref_code) {
   case 1:
     if (per >= crit.sc_min)
       stream = pref_code;
     else
       stream = 0;

     break;
   case 2:
     if (per >= crit.com_min)
       stream = pref_code;
     else
       stream = 0;
     break;
   case 3:
     if (per >= crit.arts_min)
       stream = pref_code;
     else
       stream = 0;
     break;
   }
 }

 int student::get_stream() {
   return (stream);
 }

 void input_criteria() {
   fstream fout;
   fout.open("criteria", ios::in | ios::out);
   cout << "\nEnter  the  required marks for SCIENCE stream(in percentage)";
   cin >> crit.sc_min;
   cout << "\nEnter  No. of Seats for SCIENCE stream";
   cin >> crit.seat_sc;
   cout << "\nEnter  the  required marks for COMMERCE stream(in percentage)";
   cin >> crit.com_min;
   cout << "\nEnter  No. of Seats for COMMERCE stream";
   cin >> crit.seat_com;
   cout << "\nEnter  the  required marks for ARTS stream(in percentage)";
   cin >> crit.arts_min;
   cout << "\nEnter  No. of Seats for ARTS stream";
   cin >> crit.seat_arts;
   fout.write((char * ) & crit, sizeof(crit));
   fout.close();
 }

 void read_criteria() {
   fstream fin;
   fin.open("criteria", ios::in);
   fin.read((char * ) & crit, sizeof(crit));
   fin.close();

 }

 void student::input_data() { //clrscr();
   fstream fin;
   fin.open("student", ios::app | ios::out);
   char t[2], ans;
   while (1) {
     cout << "\nEnter  the  name of the  student  :  ";
     cin >> name;
     cout << "\n\nEnter  the roll of the  student  :  ";
     cin >> regno;
     cout << "\n\nEnter  marks in eng  :  ";
     cin >> m_eng;
     cout << "\n\nEnter  marks in math  :  ";
     cin >> m_math;
     cout << "\n\nEnter  marks in science  :  ";
     cin >> m_sc;
     cout << "\n\nEnter  marks in sst  :  ";
     cin >> m_sst;
     cout << "\n\nEnter  marks in language  :  ";
     cin >> m_lang;
     cout << "==================STREAM  PREFERED?================ \n";
     cout << "\t" << "[1] for SCIENCE\n";
     cout << "\t" << "[2] for COMMERCE\n";
     cout << "\t" << "[3] for ARTS ";
     cout << "\n================================================= \n\tENTER PREFERENCE CODE : ";
     cin >> pref_code;
     stream = -1;
     fin.write((char * ) & s, sizeof(s));
     cin.getline(t, 2);
     cout << "\n\tEnter More Student ? (y/n)";
     cin >> ans;
     if (ans == 'n')
       break;
   }
   fin.close();
 }
 void student::new_file() { //clrscr();
   fstream fin;
   fin.open("student", ios::out);
   char t[2], ans;
   while (1) {
     cout << "\nEnter  the  name of the  student  :  ";
     gets(name);
     cout << "\n\nEnter  the roll of the  student  :  ";
     cin >> regno;
     cout << "\n\nEnter  marks in eng  :  ";
     cin >> m_eng;
     cout << "\n\nEnter  marks in math  :  ";
     cin >> m_math;
     cout << "\n\nEnter  marks in science  :  ";
     cin >> m_sc;
     cout << "\n\nEnter  marks in sst  :  ";
     cin >> m_sst;
     cout << "\n\nEnter  marks in language  :  ";
     cin >> m_lang;
     cout << "==================STREAM  PREFERED?================ \n";
     cout << "\t" << "[1] for SCIENCE\n";
     cout << "\t" << "[2] for COMMERCE\n";
     cout << "\t" << "[3] for ARTS ";
     cout << "\n================================================= \n\tENTER PREFERENCE CODE : ";
     cin >> pref_code;
     stream = -1;
     fin.write((char * ) & s, sizeof(s));
     cin.getline(t, 2);
     cout << "\n\tEnter More Student ? (y/n)";
     cin >> ans;
     if (ans == 'n')
       break;
   }
   fin.close();
 }
 void student::display() {

   cout << "\n============================================\n";
   cout << "\n\tNAME  : " << name;
   cout << "\n\tREGISTRATION NO. : " << regno;
   cout << "\n\tPERCENTAGE OF MARKS : " << ((m_eng + m_math + m_sc + m_sst + m_lang) / 5) << "%";
   cout << "\n\tSTREAM APPLIED FOR :  " << stream_name(pref_code);
   // cout<<"\n\tSTREAM ALLOTED : "<<stream_name(stream);
   cout << "\n============================================\n";

 }

 void read_student() {
   fstream fin;
   char c;
   fin.open("student", ios::in);
   while (fin.read((char * ) & s, sizeof(s))) {
     s.display();
     cout << "\n\tPress any no. to continue ";
     cin >> c;
     cout << "\n";
   }
   fin.close();

 }

 void read_eligible_sc() {
   char ans;
   fstream fout;
   fout.open("elig_sc", ios::in);
   fout.seekg(0);
   while (fout.read((char * ) & s, sizeof(s))) {
     s.display();
     cout << "\n\t Continue (y/n)? ";

     cin >> ans;

     if (ans == 'n')
       break;

   }
   fout.close();

 }

 void read_eligible_com() {
   char ans;
   fstream fout;
   fout.open("eligcom", ios::in);

   while (fout.read((char * ) & s, sizeof(s))) {
     s.display();
     cout << "\n\t Continue (y/n)? ";

     cin >> ans;

     if (ans == 'n')
       break;

   }
   fout.close();
 }

 void read_eligible_arts() {
   char ans;
   fstream fout;
   fout.open("eligart", ios::in);

   while (fout.read((char * ) & s, sizeof(s))) {
     s.display();
     cout << "\n\t Continue (y/n)? ";

     cin >> ans;

     if (ans == 'n')
       break;

   }
   fout.close();
 }
 void clear() {
   // for(int i=1;i< =24;i++)
   // cout<<"\n";
 }
 char * stream_name(int strm) {
   switch (strm) {
   case -1:
     return ("Not assigned");
     // break;
   case 0:
     return ("Nill");
     // break;
   case 1:
     return ("Science");
     // break;
   case 2:
     return ("Commerce");
     // break;
   case 3:
     return ("Arts");
     // break;
   default:
     return ("None");
   }
 }
 void select_list(char * in_file, char * out_file) {
   fstream sel, fin;
   int n = 0, i, j;
   student sl[100], t;

   sel.open(out_file, ios::out);
   fin.open(in_file, ios::in);

   while (fin.read((char * ) & sl[n], sizeof(s))) {
     n++;

   }
   cout << "\nNo of Eligible Students  = " << n << "\n";
   for (i = 0; i < n; i++) {
     for (j = i + 1; j <= n; j++) {
       if (sl[i].show_per() < sl[j].show_per()) {
         t = sl[j];
         sl[j] = sl[i];
         sl[i] = t;
       }
     }
   }
   for (i = 0; i < n; i++) {
     sel.write((char * ) & sl[i], sizeof(s));
   }
   sel.close();
   fin.close();

 }
 void welcome() {
   //clrscr();
   int z;
   cout << "\t%%      %%      ";
   cout << "\n\t%%      %% %%%%%%% %%      %%%%%%  %%%%%% %%%%  %%%% %%%%%%%";
   cout << "\n\t%%      %% %%      %%      %%      %%  %% %%  %%% %% %%       ";
   cout << "\n\t%%  %%  %% %%%%%   %%      %%      %%  %% %%  %%% %% %%%%%      ";
   cout << "\n\t%%  %%  %% %%      %%      %%      %%  %% %%      %% %%           ";
   cout << "\n\t%%%%%%%%%% %%%%%%% %%%%%%% %%%%%%% %%%%%% %%      %% %%%%%%%     ";
   cout << "\n\n\t\t\t        $$$$$$$$  $$$$$        ";
   cout << "\n\t\t\t           $$     $   $      ";
   cout << "\n\t\t\t           $$     $$$$$    ";

   cout << "\n\n\n\tCOMPUTER   PROJECT  (********  ON STREAM ALLOCATION  *******)";

   cout << " \n\n\n\t\t     press any number and 'ENTER' to continue: ";
   cin >> z;

   // getch();
 }
 void thanks() {
   int w;
   //clrscr();
   cout << "\n\n\n\n\n\n\n\n\n\n\t**********   T H A N K   Y O U   F O R   W O R K I N G   *******";
   cout << "\n\n\n\n\n\n\n\t\t\t Press Any Number And Then 'ENTER' to exit";
   cin >> w;
 }