SRM Admission

#include <iostream>
using namespace std;
class Student
{
  public:
  void Identity(char name[100], int id){
  cout<< name<<" "<<id<<endl;   
  }
  void Identity(int id,char name[100]){
  cout<< name<<" "<<id<<endl;   
  }
};
int main()
{
  char name[100];
  int id;
  cin >> name >> id;
  Student s1;
  s1.Identity(name, id);
  cin >> id >> name;
  s1.Identity(id, name);
  return 0;
}

9 comments:

  1. this works

    #include
    #include

    using namespace std;

    class Student{
    public:
    void Identity(int id,char name[100]);
    void Identity(char name[100],int id);
    void Identity(char name[100],char id[100]){
    char temp[100];
    if(isdigit(name[0])) {
    strcpy(temp,name);
    strcpy(name,id);
    strcpy(id,temp);
    }
    cout<>name;
    cin>>id;
    s1.Identity(name,id);
    cin>>name;
    cin>>id;
    s1.Identity(name,id);
    }

    courtesy of the pull request on the repo https://github.com/chilloutwithanas/E-Lab-Object-Oriented-Programming/
    by user Purukitto over here: https://github.com/chilloutwithanas/E-Lab-Object-Oriented-Programming/pull/30/commits/711422513d3b4bdda89708f9095413867d297c6f#diff-171cd36d686896c35fdb0c023a369584R1

    ReplyDelete
  2. pl update its not working 100%

    ReplyDelete
  3. #include
    using namespace std;

    class Student
    {
    public:
    void Identity(char name[100], int id)
    {
    cout<<name<<" "<<id<<endl;
    }
    void Identity(int id, char name[100])
    {
    cout<<name<<" "<<id<<endl;
    }
    };

    ReplyDelete
    Replies
    1. int main()
      {
      char name[100];
      int id;
      cin>>name>>id;
      Student s1;
      s1.Identity(name, id);
      cin>>id>>name;
      s1.Identity(id, name);
      return 0;
      }

      Delete
  4. #include
    using namespace std;
    class TestClass{
    public:
    class Student
    {
    public:
    void identity(char name[100], int id){
    cout<>name>>id;

    s1.identity(name, id);
    cin>>id>>name;
    s1.identity(id, name);
    return 0;
    }



    works 100%

    ReplyDelete