Assignment for Superdogs - Part 1

View previous topic View next topic Go down

Assignment for Superdogs - Part 1

Post by BIT0122-Amit on Sun Aug 21, 2011 12:50 am

Yo kids.

This topic is targeting a certain category of students of current 1st year. So if you don't understand what's going on, don't bother. If you are in the targeted category student, leave a reply immediately after reading this. I want to see how many of you are actually active. Call/Tell your category partners about this one as well.

It is assignment for Superdogs, because I believe all of you have the potential to become great software engineers, as well as programmers. Of course, that is considering that you are willing to achieve that.

Now, currently, you have a bit weak base for programming. So, lets make that as hard as concrete. We are going to start from basics.

You have two days. You need to read every word, type every example, and solve every exercise from Herbert Schildt's Teach yourself C, chapter 1 to 4. I think all of you said that you have done these things before, so normally it would take only one day. Still, I am giving you two days, because all of us have the tendency that, "This is easy. I don't need to solve this exercise".

After you solve them, post under here to tell that you have done this. If you can not solve any of them, or have any questions, post your question here. Don't worry about "Boro vaia ra ki bolben emon stupid question dekhe". If you have problem with English, type in Banglish. But I want your posts. Here.

Whether these are easy or not, I don't care. You have two days.

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0322-Hira on Mon Aug 22, 2011 2:09 pm

ok,vaia.

BIT0322-Hira
Alpha Release
Alpha Release

Course(s) :
  • BIT

Blood Group : O+
Posts : 24
Points : 33

View user profile

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0122-Amit on Wed Aug 24, 2011 1:41 am

হুমম। সবডি ফেইল। অন্ততঃ নাম্বার তো খাবোই।

বাসায় গিয়ে গিয়ে তো আর সবডির থিকা পড়া আদায় করা সম্ভব না।

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0305-tanvir on Wed Aug 24, 2011 6:24 am

Amit vai ami matro delklam....porshu sokal nagad report korbo koddur ki obostha...

BIT0305-tanvir
Pre-Alpha Release
Pre-Alpha Release

Course(s) :
  • N/A

Blood Group : NULL
Posts : 7
Points : 10

View user profile

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0122-Amit on Fri Aug 26, 2011 1:58 am

তা কি করলে তোমরা সাথে সাথে দেখতে? তোমাদের ফেসবুক গ্রুপে আমি পোস্ট দিয়ে আসলে?

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0322-Hira on Fri Aug 26, 2011 7:16 pm

line buffer জিনিস টা দিয়ে কি হয়? এটার কাজ কি? বই এ অনেক কিছু লেখা কিন্তু কিছুই বুঝলাম না

BIT0322-Hira
Alpha Release
Alpha Release

Course(s) :
  • BIT

Blood Group : O+
Posts : 24
Points : 33

View user profile

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0122-Amit on Fri Aug 26, 2011 9:11 pm

কই পেলে এটা? Very Happy বইয়ের কোথাও পেলে বলো, ওটা অনুসারে বুঝাতে সুবিধা হবে। আর এমনি বললে, Buffer হলো‌ একটা যায়গা যেখানে তুমি ডাটা রাখতে পারবে ক্ষনস্থায়ী ভাবে।

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0122-Amit on Sat Aug 27, 2011 1:56 am

নাম্বার কাটার ইচ্ছা ছিল না, এখন তো মনে হচ্ছে নেগেটিভ নাম্বার দেয়া শুরু করা লাগবে।

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0322-Hira on Sat Aug 27, 2011 4:03 am

Teach yourself C বই এর 3.1:INPUT CHARACTERS

BIT0322-Hira
Alpha Release
Alpha Release

Course(s) :
  • BIT

Blood Group : O+
Posts : 24
Points : 33

View user profile

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0122-Amit on Sat Aug 27, 2011 6:30 am

ওখানে যা বলেছে, তার মানে হলো, কোন কোন C compiler এর getchar() টা এমন ভাবে কাজ করে যা একটু ভেজাল পাকায়। কি ভাবে কাজ করে?

ধরো লিখলে,
char c = getchar();

এর পর তুমি ধরো প্রোগ্রামও চালালে। চালানোর সময় সে একটা c character variable এ input রাখতে চাইবে। সমস্যাটা এখানেই। input নেয়া শেষ হবে কবে এটা বিভিন্ন compiler বিভিন্ন ভাবে ঠিক করে। line buffer ইনপুট হলো, তুমি ধরো input নিতে চাইলে লিখলে -
Hello World. তুমি যখন লিখবে, তারপরেও কিছু হবে না। সে তোমার enter টিপার জন্য অপেক্ষা করবে যেটাকে বলা হচ্ছে carriage return. ঝামেলাটাকি ধরতে পারছো?
তার নেবার কথা একটা মাত্র অক্ষর। সে নিবেও একটা অক্ষর। কিন্তু সেই একটা অক্ষর নেয়া শেষ বুঝতে হলে তার কাছে একটা enter যেতে হবে। তা নাহলে সে মোটামুটি একটা দীর্ঘসময় অসীম ধৈর্য্য নিয়ে অপেক্ষা করবে।


একই বইয়ের চ্যাপ্টার ৮ এ এ বিষয়ে বিস্তারিত বলা হয়েছে।



_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0322-Hira on Sat Aug 27, 2011 7:15 pm

Thanx

BIT0322-Hira
Alpha Release
Alpha Release

Course(s) :
  • BIT

Blood Group : O+
Posts : 24
Points : 33

View user profile

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0122-Amit on Sun Aug 28, 2011 1:31 am

Did you understand or there is still confusion?

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0322-Hira on Mon Aug 29, 2011 2:48 am

I have understood.But what is the advantage of line buffer input? I think nothing.It has only disadvantages.

BIT0322-Hira
Alpha Release
Alpha Release

Course(s) :
  • BIT

Blood Group : O+
Posts : 24
Points : 33

View user profile

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0322-Hira on Mon Aug 29, 2011 2:55 am

What is the difference between non-general function & parameterized function? It seems confusing.I know about parameterized function.We pass parametres through it.But what is about non-general function?Would you help me?
Teach yourself C,4.2

BIT0322-Hira
Alpha Release
Alpha Release

Course(s) :
  • BIT

Blood Group : O+
Posts : 24
Points : 33

View user profile

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0122-Amit on Mon Aug 29, 2011 3:49 am

BIT0322-Hira wrote:I have understood.But what is the advantage of line buffer input? I think nothing.It has only disadvantages.

getche(), getchar(), and getch()
All of them have different ways of working, although they ultimately do the same thing. In different kinds of situation, you need different behaviors of functions

BIT0322-Hira wrote:What is the difference between non-general function & parameterized function? It seems confusing.I know about parameterized function.We pass parametres through it.But what is about non-general function?Would you help me?
Teach yourself C,4.2


Grr.... My C book does not have 113 to 128. So I don't know what is written about non general function in that book.

Is that a function which does not accept any parameter? Or.. can you at least type the definition of non general function from book here?

Arif said he would give me a copy of the book.. grr....

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0322-Hira on Mon Aug 29, 2011 8:54 am

#include

int power(void);

int m, e;

int main(void)
{
m = 2;
e = 3;

printf("%d raised to the %d power is %d", m, e, power());

return 0;
}

/* Non-general version of power. */
int power(void)
{
int temp, temp2;

temp = 1;
temp2 = e;
for( ; temp2> 0; temp2--) temp = temp * m;

return temp;
}





#include

int power(int m, int e);

int main(void)
{
int m, e;
m = 2;
e = 3;

printf("%d to the %d is %d\n", m, e, power(m, e));
printf("4 to the 5th is %d\n", power(4, 5));
printf("3 to the 3rd is %d\n", power(3, 3));

return 0;
}

/* Parameterized version of power. */
int power(int m, int e)
{
int temp;

temp = 1;
for( ; e> 0; e--) temp = temp * m;

return temp;
}

BIT0322-Hira
Alpha Release
Alpha Release

Course(s) :
  • BIT

Blood Group : O+
Posts : 24
Points : 33

View user profile

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0322-Hira on Mon Aug 29, 2011 9:10 am

Can you help me to understand 'low order bits' & 'high order bits'?
Teach yourself C,4.6 seems very hard to me.

BIT0322-Hira
Alpha Release
Alpha Release

Course(s) :
  • BIT

Blood Group : O+
Posts : 24
Points : 33

View user profile

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0122-Amit on Mon Aug 29, 2011 11:45 am

When you are providing codes, please use the code tags. otherwise, they become unreadable.

Like this:


Code:

[code]
#include <stdio.h>

int main(void){
    printf("Hello World");

    return 0;
}


[/code]

You can also use IITDU pastebin. To use this, go to forum shortcuts menu, then iitdu pastebin. You can click on "বাংলায় দেখুন"
as well.

From there, follow instructions.


I will explain about high order and low order bits after I come back from office.

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0322-Hira on Mon Aug 29, 2011 3:26 pm

Code:

#include<stdio.h>

int power(void);

int m, e;

int main(void)
{
m = 2;
e = 3;

printf("%d raised to the %d power is %d", m, e, power());

return 0;
}

/* Non-general version of power. */
int power(void)
{
int temp, temp2;

temp = 1;
temp2 = e;
for( ; temp2> 0; temp2--) temp = temp * m;

return temp;
}





#include<stdio.h>

int power(int m, int e);

int main(void)
{
int m, e;
m = 2;
e = 3;

printf("%d to the %d is %d\n", m, e, power(m, e));
printf("4 to the 5th is %d\n", power(4, 5));
printf("3 to the 3rd is %d\n", power(3, 3));

return 0;
}

/* Parameterized version of power. */
int power(int m, int e)
{
int temp;

temp = 1;
for( ; e> 0; e--) temp = temp * m;

return temp;
}


Last edited by BIT0322-Hira on Tue Aug 30, 2011 1:35 am; edited 1 time in total

BIT0322-Hira
Alpha Release
Alpha Release

Course(s) :
  • BIT

Blood Group : O+
Posts : 24
Points : 33

View user profile

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0220-Iftekhar on Mon Aug 29, 2011 5:07 pm

BIT0322-Hira, I think you miscued to use the code tags. You need to finish the tag with [/code] like, ........[/code]
And you don't need to re-post the codes. You can edit your post (look for a edit button towards the head of your post)and use code tags from there Smile


However, I think I can explain the non-general function and parameterized function from the two example codes you have given here.

A non-general function has no parameter. It doesn't need any argument to pass in it. Instead,it uses global variables (variables that are declared above the main() function) for any calculation inside it. Again,global variables are visible from any user-defined function. So there is no need to pass variables through a non-general function when those variables are declared globally.

Observe this from your own example,the first one. m and e are two integers declared globally and the function power() has no parameter. Still it is able to calculate 2^3 as m and e are visible(or has scope) from this function.
Remember,variables that are not globally declared(called as local variables) won't have scope inside non-general functions.

This way of using function is generally prohibited as glo-vars can change in their values from other function calls at that time.


On the other hand,a parameterized(or general) function simply has got one or more parameter. It can work with both the parameterized variables and the global variables. The parametirized variables works locally inside the function. Nothing more to tell as you already know about it.

Observe this from your second example. In this case, m and e are passed as arguments of function power() and they ain't global variables any more.

In both cases,remember that you can't work with variables that are not declared globally or declared inside other functions(like the main() function).

Hoping to get response from you. Smile


Last edited by BIT0220-Iftekhar on Mon Aug 29, 2011 5:18 pm; edited 1 time in total (Reason for editing : explaining the use of code tags)
avatar
BIT0220-Iftekhar
Administrator-RC

Course(s) :
  • BIT

Blood Group : B+
Posts : 434
Points : 630

View user profile http://iftekharunplugged.blogspot.com

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0322-Hira on Tue Aug 30, 2011 1:44 am

Thanks a lot Iftekhar vaia ..It's really helpful.


Last edited by BIT0322-Hira on Tue Aug 30, 2011 4:01 am; edited 1 time in total

BIT0322-Hira
Alpha Release
Alpha Release

Course(s) :
  • BIT

Blood Group : O+
Posts : 24
Points : 33

View user profile

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0122-Amit on Tue Aug 30, 2011 1:46 am

Thank you for the explanation Iftekhar Very Happy

Although I think I can explain it too.

Say, you are writing a program and it does many things. Thing is, all of those things are fixed. And the program does these things in random order. For example, it is a help program which has over 500 help articles. Noone knows which one of them will be requested by user.

Does any of them require any parameter? Nope.
Is it a good idea to include them in the main function? Nope. Because we want to call them only when we want to.
I hope I explained in a way you can understand. Very Happy

BTW, you should add Vaia/Apu after elder people's username.

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0322-Hira on Tue Aug 30, 2011 4:06 am

vaia pls help me to understand high order and low order bits.Teach yourself C,4.6 seems very hard to me.

BIT0322-Hira
Alpha Release
Alpha Release

Course(s) :
  • BIT

Blood Group : O+
Posts : 24
Points : 33

View user profile

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0122-Amit on Tue Aug 30, 2011 4:12 pm

জিনিষটা বুঝাতে হলে আগে তোমার এই লিংকে ঘুরে আসতে হবে-

[You must be registered and logged in to see this link.]

কম্পিউটারে সব কিছুই bit দিয়ে হিসাব হয়, এটা তো জানোই। কাজেই সে char, বা int সবই চিনে bit দিয়ে।

এখন char রাখতে ৮ বিট ব্যবহার করা হয়। int রাখতে ১৬ বিট সাধারণত।

আমরা যখন লিখি, a = b, ধরো a একটা বালতি, b আরো একটা বালতি। b এর টা a তে রাখা হচ্ছে।

এখন যদি a বালতির ধারণ ক্ষমতা b এর সমান বা বেশি হয়, b এর সবটুকুই a তে রাখা যাবে।
কিন্তু যদি তা না হয়?
তখন b এর যতটুকু a তে ভরা যাবে, তা ভরে বাকিটা বাইরে পরে যাবে।

এখন int এর সাইজ হলো ১৬ বিট, আমি রাখতে চাইলাম ৮ বিট char এ। তাহলে সবটুকু ত ভরা যাবে না, তাই না?
কাজেই শেষের ৮ বিট ভরা হবে, যেটাকে বলা হচ্ছে low order bits আর বাকি উপরের বাকি ৮ বিট (high order bits) ভরা যাবে না।

এটা বুঝলে বাকিগুলাও বুঝতে পারবে।

এখন বলো দেখি, তোমরা না এসব পড়েছো প্রথম সেমিস্টারে? এসব কঠিন লাগছে কেন?

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by BIT0122-Amit on Tue Sep 06, 2011 1:23 am

হুমম। নাম্বার সব কেটে কুটে ভাসায়ে দিবো।

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Assignment for Superdogs - Part 1

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum