help! C language

RaVa

Active member
  • Jan 29, 2016
    372
    168
    43
    මචංලා .. කවුරුහරි ඉන්නවද C හරි C++ හරි කරපු .. උදව්වක් ඕනේ . ID card එකෙන් birthday එකයි gender එකයි generate කරගන්න program එකක් ලියන්න ඕනේ. පොඩි assessment එකකට මචංලා. දන්න කෙනෙක් ඉන්නවනම් please help එකක් දියල්ලකෝ..
    Format -:
    1.Digits 1 and 2: The year of birth
    2.Digits 3-5: The number of the day in the year on which the person's birth date falls.
    A male would be assigned the number 1-366 and a female the number 501-866. This is a way of confirming if the person's listed birth date is accurate. A male's birth date would be represented by the exact number of days, a female's birth date would be represented by the exact number of days + 500.
    Example: The first five digits of the NIC for a male born on 1 January 1997 would be 97001; however, a female born on that same date would be 97501.
    3.Digits 6-8 are the serial number from the Record book maintained at the Department [for the Registration of Persons].
    4.Digit 9 is a check digit
     

    CorD SaC

    Well-known member
  • Feb 4, 2015
    15,724
    28,085
    113
    මම මේක ටර්යි කලා Using C language,බලපන් ගොඩද කියලා.... :cool:
    Date එක ගන්න එක පොඩ්ඩක් අවුල්, :confused: Month,Year,Sex ok :yes::yes:

    PHP:
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
        int j,i=0,year =0,month =0,sum=0,c=0,count=0,date=0;
        int months[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
        int no =10000000;
        char idNo[10],sub[10];
    
        printf("Enter Your Identity card Number : ");
        gets(idNo);
    
        year = atoi(idNo)/no;
    
        while (c < 3)
        {
          sub[c] = idNo[3+c-1];
          c++;
        }
        sum = atoi(sub);//convert string to int
    
        if(sum>500){
        sum = sum-500;//For female
        printf("\n\nCard holder is female\n\n");
       }
        else{
        printf("\n\nCard holder is male\n\n");
       }
    
       printf("Year is: %d\n\n",year);
        while(month<sum)
       {
        month = month + months[i];
        i++;
        count++;
       }
    
       date = sum - month;
       printf("\nMonth is: %d\n",count);
       return 0;
    }
    තව දෙයක්,ගත්ත variables නම් පොඩ්ඩක් අවුල් ඇති, :sorry: හදිස්සියට කලේ උඹට Assignment එකක් කිව්ව නිසා...අවුල් නම් අහපන් :yes:
     

    RaVa

    Active member
  • Jan 29, 2016
    372
    168
    43
    මම මේක ටර්යි කලා Using C language,බලපන් ගොඩද කියලා.... :cool:
    Date එක ගන්න එක පොඩ්ඩක් අවුල්, :confused: Month,Year,Sex ok :yes::yes:

    PHP:
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
        int j,i=0,year =0,month =0,sum=0,c=0,count=0,date=0;
        int months[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
        int no =10000000;
        char idNo[10],sub[10];
    
        printf("Enter Your Identity card Number : ");
        gets(idNo);
    
        year = atoi(idNo)/no;
    
        while (c < 3)
        {
          sub[c] = idNo[3+c-1];
          c++;
        }
        sum = atoi(sub);//convert string to int
    
        if(sum>500){
        sum = sum-500;//For female
        printf("\n\nCard holder is female\n\n");
       }
        else{
        printf("\n\nCard holder is male\n\n");
       }
    
       printf("Year is: %d\n\n",year);
        while(month<sum)
       {
        month = month + months[i];
        i++;
        count++;
       }
    
       date = sum - month;
       printf("\nMonth is: %d\n",count);
       return 0;
    }
    තව දෙයක්,ගත්ත variables නම් පොඩ්ඩක් අවුල් ඇති, :sorry: හදිස්සියට කලේ උඹට Assignment එකක් කිව්ව නිසා...අවුල් නම් අහපන් :yes:
    million thanks machan...try karala balannam.......
     

    RaVa

    Active member
  • Jan 29, 2016
    372
    168
    43
    මම මේක ටර්යි කලා Using C language,බලපන් ගොඩද කියලා.... :cool:
    Date එක ගන්න එක පොඩ්ඩක් අවුල්, :confused: Month,Year,Sex ok :yes::yes:

    PHP:
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
        int j,i=0,year =0,month =0,sum=0,c=0,count=0,date=0;
        int months[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
        int no =10000000;
        char idNo[10],sub[10];
    
        printf("Enter Your Identity card Number : ");
        gets(idNo);
    
        year = atoi(idNo)/no;
    
        while (c < 3)
        {
          sub[c] = idNo[3+c-1];
          c++;
        }
        sum = atoi(sub);//convert string to int
    
        if(sum>500){
        sum = sum-500;//For female
        printf("\n\nCard holder is female\n\n");
       }
        else{
        printf("\n\nCard holder is male\n\n");
       }
    
       printf("Year is: %d\n\n",year);
        while(month<sum)
       {
        month = month + months[i];
        i++;
        count++;
       }
    
       date = sum - month;
       printf("\nMonth is: %d\n",count);
       return 0;
    }
    තව දෙයක්,ගත්ත variables නම් පොඩ්ඩක් අවුල් ඇති, :sorry: හදිස්සියට කලේ උඹට Assignment එකක් කිව්ව නිසා...අවුල් නම් අහපන් :yes:

    Ela mcn working. Ithuru tika kohomahri goda daganna puluwan. mama wenuwen weya karapu kalayata godak sthuthi yaluwa...