C අවුලක්

isurutmv

Well-known member
  • May 1, 2013
    1,946
    825
    113
    29
    Gampaha


    015+0*72+5=18
    15+0*72+5=20

    මචන් ඔය දෙකට ඔහොම උත්තර දෙකක් එන්න හේතුව මොකක්ද බන් ?




     

    isurutmv

    Well-known member
  • May 1, 2013
    1,946
    825
    113
    29
    Gampaha
    code eka dapan balanna

    24c7hnb.png
     

    topkollek

    Well-known member
  • May 22, 2014
    43,553
    1
    57,675
    113
    ┬┴┬┴┤(·_├┬┴┬┴
    ඇයි ඉතින් 0ක් ඉස්සරහට දාන්නෙ? C වල 015 කියන්නෙ 15 නෙමෙයිනෙ.

    015 කියන්නෙ අටේ පාදයෙන් ලියන විදිහ.
    015 oct = 13 dec
     
    • Like
    Reactions: isurutmv

    dumidu99

    Junior member
  • Sep 27, 2007
    129
    9
    18
    machan 015 kiyanne octal widiyata yanne

    0 1 5
    8^2*0+8^1*1+8^0*5=0+8+5=13 ohoma tamai enne

    issaraha 0 ain karama binary walin yanne. :yes:
     

    isurutmv

    Well-known member
  • May 1, 2013
    1,946
    825
    113
    29
    Gampaha
    ඇයි ඉතින් 0ක් ඉස්සරහට දාන්නෙ? C වල 015 කියන්නෙ 15 නෙමෙයිනෙ.

    015 කියන්නෙ අටේ පාදයෙන් ලියන විදිහ.
    015 oct = 13 dec

    ammatasiri ehema ekak danan hitiye na tnx mcn
     

    isurutmv

    Well-known member
  • May 1, 2013
    1,946
    825
    113
    29
    Gampaha
    #include<stdio.h>
    int main()
    {
    int bsal,allo,bonus,du,sal,ms;
    char c[10];

    printf("Enter basic salary ");
    scanf("%d",&bsal);
    printf("Enter working duration ");
    scanf("%d",&du);
    printf("Monthly sales ");
    scanf("%d",&ms);
    printf("Enter Location ");
    scanf("%s",&c);


    if (du>5)
    allo=((bsal/100)*10);

    if (c=='colombo')
    allo=allo+2500;

    if (ms<25000)
    bonus=(ms*10/100);
    else if ((25000<ms)&&(ms<50000))
    bonus=((ms/100)*12);
    else if (ms>=50000)
    bonus=(ms*15/100);

    sal=(bsal+allo+bonus);
    printf("The salary is %d \n",sal);

    }


    මේකේ C Variable එකේ value එක colombo උනාම 2500 එකතු වෙන්නේ නැහැනේ
     

    HSW

    Well-known member
  • Nov 18, 2016
    3,475
    1
    519
    113
    #include<stdio.h>
    int main()
    {
    int bsal,allo,bonus,du,sal,ms;
    char c[10];

    printf("Enter basic salary ");
    scanf("%d",&bsal);
    printf("Enter working duration ");
    scanf("%d",&du);
    printf("Monthly sales ");
    scanf("%d",&ms);
    printf("Enter Location ");
    scanf("%s",&c);


    if (du>5)
    allo=((bsal/100)*10);

    if (c=='colombo')
    allo=allo+2500;

    if (ms<25000)
    bonus=(ms*10/100);
    else if ((25000<ms)&&(ms<50000))
    bonus=((ms/100)*12);
    else if (ms>=50000)
    bonus=(ms*15/100);

    sal=(bsal+allo+bonus);
    printf("The salary is %d \n",sal);

    }


    මේකේ C Variable එකේ value එක colombo උනාම 2500 එකතු වෙන්නේ නැහැනේ
    Singe quote nathuwa double quote daala balanda. Single quote daanne character 1 kata.
     

    NEMISIS

    Well-known member
  • Nov 13, 2013
    11,391
    19,520
    113
    Colombo
    #include<stdio.h>
    int main()
    {
    int bsal,allo,bonus,du,sal,ms;
    char c[10];

    printf("Enter basic salary ");
    scanf("%d",&bsal);
    printf("Enter working duration ");
    scanf("%d",&du);
    printf("Monthly sales ");
    scanf("%d",&ms);
    printf("Enter Location ");
    scanf("%s",&c);


    if (du>5)
    allo=((bsal/100)*10);

    if (c=='colombo')
    allo=allo+2500;

    if (ms<25000)
    bonus=(ms*10/100);
    else if ((25000<ms)&&(ms<50000))
    bonus=((ms/100)*12);
    else if (ms>=50000)
    bonus=(ms*15/100);

    sal=(bsal+allo+bonus);
    printf("The salary is %d \n",sal);

    }


    මේකේ C Variable එකේ value එක colombo උනාම 2500 එකතු වෙන්නේ නැහැනේ


    c=='colombo'
    C වලදි ඔහොම කම්පෙයා කරන්න බැහැනේ (C වල විතරක් නෙමෙයි සමහර තව ලැන්ග්වේජ් වලත් ඔහොම ස්ට්‍රින්ග් කම්පෙයා කරන්න බැහැ)
    C වලදි ඔහොම කම්පෙයා කරන්න නම් strcmp ෆන්ශන් එක යූස් කරලා කරන්න ඕන
    තනි කැරැක්ටර් එකක් නම් ඔහොම කම්පෙයා කරතහැකි, C වල ස්ට්‍රින්ග් එකක් කියන්නෙ කැරැක්ටර් ඇරේ එකක්නේ එක නිසා ඔහොම කම්පෙයා කරන්න බැහැ
     
    Last edited:

    HSW

    Well-known member
  • Nov 18, 2016
    3,475
    1
    519
    113
    #include<stdio.h>
    int main()
    {
    int bsal,allo,bonus,du,sal,ms;
    char c[10];

    printf("Enter basic salary ");
    scanf("%d",&bsal);
    printf("Enter working duration ");
    scanf("%d",&du);
    printf("Monthly sales ");
    scanf("%d",&ms);
    printf("Enter Location ");
    scanf("%s",&c);


    if (du>5)
    allo=((bsal/100)*10);

    if (c=='colombo')
    allo=allo+2500;

    if (ms<25000)
    bonus=(ms*10/100);
    else if ((25000<ms)&&(ms<50000))
    bonus=((ms/100)*12);
    else if (ms>=50000)
    bonus=(ms*15/100);

    sal=(bsal+allo+bonus);
    printf("The salary is %d \n",sal);

    }


    මේකේ C Variable එකේ value එක colombo උනාම 2500 එකතු වෙන්නේ නැහැනේ

    Pointer nathuwa C variable ekata value eka assign karanda.
     

    Mr UNKNOWN

    Well-known member
  • Jun 19, 2016
    11,792
    30,893
    113
    #include<stdio.h>
    int main()
    {
    int bsal,allo,bonus,du,sal,ms;
    char c[10];

    printf("Enter basic salary ");
    scanf("%d",&bsal);
    printf("Enter working duration ");
    scanf("%d",&du);
    printf("Monthly sales ");
    scanf("%d",&ms);
    printf("Enter Location ");
    scanf("%s",&c);


    if (du>5)
    allo=((bsal/100)*10);

    if (c=='colombo')
    allo=allo+2500;

    if (ms<25000)
    bonus=(ms*10/100);
    else if ((25000<ms)&&(ms<50000))
    bonus=((ms/100)*12);
    else if (ms>=50000)
    bonus=(ms*15/100);

    sal=(bsal+allo+bonus);
    printf("The salary is %d \n",sal);

    }


    මේකේ C Variable එකේ value එක colombo උනාම 2500 එකතු වෙන්නේ නැහැනේ


    ලොකේශන් එක ගාව scanf එකේ %s නැතුව %C දීලා බලහන් ඒත් හරියන්නැත්තං 'colombo' ' ' දෙක අයින් කරලා නිකං දාලා බලහන්.....if එකකට පස්සෙ සගල වරහන් දාන්න ඕනෙ නේද??
     

    NEMISIS

    Well-known member
  • Nov 13, 2013
    11,391
    19,520
    113
    Colombo
    Pointer nathuwa C variable ekata value eka assign karanda.


    ලොකේශන් එක ගාව scanf එකේ %s නැතුව %C දීලා බලහන් ඒත් හරියන්නැත්තං 'colombo' ' ' දෙක අයින් කරලා නිකං දාලා බලහන්.....if එකකට පස්සෙ සගල වරහන් දාන්න ඕනෙ නේද??

    සගල වරහන් අනිවාර්ය නැහැ

    මෙතන අවුල තියෙන්නෙ == දාල ස්ට්‍රින්ග් දෙකක් කම්පෙයා කරන්න බැහැ
    c=='colombo' මෙන්න මේක හැමතිස්සෙම false වෙනවා, ඒ කියන්නෙ c කියන වේරියබල් එකට colombo කියලා ආවත් false ම තමයි, ස්ට්‍රින්ග් කම්පෙයා කරනවා නම් strcmp ෆන්ශන් එක යූස් කරන්න වෙනවා එහෙම නැත්නම් කැරැක්ටර් එකෙන් කැරැක්ටර් එක චෙක් කරලා ස්ට්‍රින්ග් මැච් කරන ෆන්ශන් එකක් ලියා ගන්න වෙනවා

    මේ පාට් එක අයින් කරලා
    if (c=='colombo')
    allo=allo+2500;

    ඒ වෙනුවට මේ විදියට ලියන්න ඕන
    if (strcmp(c,"colombo") == 0)
    allo=allo+2500;
     
    Last edited:

    topkollek

    Well-known member
  • May 22, 2014
    43,553
    1
    57,675
    113
    ┬┴┬┴┤(·_├┬┴┬┴

    c=='colombo'
    C වලදි ඔහොම කම්පෙයා කරන්න බැහැනේ (C වල විතරක් නෙමෙයි සමහර තව ලැන්ග්වේජ් වලත් ඔහොම ස්ට්‍රින්ග් කම්පෙයා කරන්න බැහැ)
    C වලදි ඔහොම කම්පෙයා කරන්න නම් strcmp ෆන්ශන් එක යූස් කරලා කරන්න ඕන
    තනි කැරැක්ටර් එකක් නම් ඔහොම කම්පෙයා කරතහැකි, C වල ස්ට්‍රින්ග් එකක් කියන්නෙ කැරැක්ටර් ඇරේ එකක්නේ එක නිසා ඔහොම කම්පෙයා කරන්න බැහැ

    Pointer nathuwa C variable ekata value eka assign karanda.

    :yes: