If you have have Done C - Programming Language, Let me know
Moderators: Moderators, Junior Moderators
Forum rules
This General Forum is for general discussions from daily chitchat to more serious discussions among Somalinet Forums members. Please do not use it as your Personal Message center (PM). If you want to contact a particular person or a group of people, please use the PM feature. If you want to contact the moderators, pls PM them. If you insist leaving a public message for the mods or other members, it will be deleted.
This General Forum is for general discussions from daily chitchat to more serious discussions among Somalinet Forums members. Please do not use it as your Personal Message center (PM). If you want to contact a particular person or a group of people, please use the PM feature. If you want to contact the moderators, pls PM them. If you insist leaving a public message for the mods or other members, it will be deleted.
If you have have Done C - Programming Language, Let me know
To anyone out here who took C-Programming, I may benefit from your knowledge when I get stuck. Will open a thread everynow and then to ask questions I have on some unclear issues when I have time to visit.
Thanks in Advance.
Thanks in Advance.
- QansaGabeyle
- SomaliNet Super

- Posts: 14164
- Joined: Wed Feb 27, 2002 7:00 pm
- Location: Beled Xawo, Somalia
- Contact:
Re: If you have have Done C - Programming Language, Let me know
If you need help with prolog, let me know. 
Re: If you have have Done C - Programming Language, Let me know
I am serious saxib, here is my first assignment I worked on and I got stuck on some of the questions.
The questions were:
1. How many bytes in a char?
2. How many bytes in a short?
3. How many bytes in an int?
4. How many bytes in a long?
5. How many bytes in a long long
6. What is -1 printed out as a hexadecimal number?
7. What is -1 if printed as an unsigned int?
8. What is the largest positive int?
9. What is the most negative int?
10. What is the printed if you print ‘C’ as an integer?
11. What is printed if you print 0x46 as a char?
So far I have written the program and figured out half of the questions.
printf("sizeof(int) =%d bytes\n", sizeof(int));
printf("sizeof(char) = %d bytes\n", sizeof(char));
printf("sizeof(short) = %d bytes\n", sizeof(short));
printf("sizeof(long) = %d bytes\n", sizeof(long));
printf("sizeof(long long) = %d bytes\n", sizeof(long long));
What I don't know is, How do I answer 8,9,10
Any ideas Qansa?
Damn! I have been doing this homework earlier and I thought it was easy. May be I should go back and do some more reading of the chapters.
Re: If you have have Done C - Programming Language, Let me know
Btw, there is something missing from the program I wrote, i just copied the printfs.
I know I am correct because after compiling and running, I got the answers:
sizeof(int) =4 bytes
sizeof(char) = 1 bytes
sizeof(short) = 2 bytes
sizeof(long) = 4 bytes
sizeof(long long) = 8 bytes
I tried printf("largest positive integer = %d\n" INT_MAX);
But that didn't work, so, how should I do it? Damn! I am cheating, but getting an idea isn't bad
I know I am correct because after compiling and running, I got the answers:
sizeof(int) =4 bytes
sizeof(char) = 1 bytes
sizeof(short) = 2 bytes
sizeof(long) = 4 bytes
sizeof(long long) = 8 bytes
I tried printf("largest positive integer = %d\n" INT_MAX);
But that didn't work, so, how should I do it? Damn! I am cheating, but getting an idea isn't bad
- QansaGabeyle
- SomaliNet Super

- Posts: 14164
- Joined: Wed Feb 27, 2002 7:00 pm
- Location: Beled Xawo, Somalia
- Contact:
Re: If you have have Done C - Programming Language, Let me know
It didn't work because you are missing a comma after %d\n".......
printf("largest positive integer = %d\n", INT_MAX);
printf("largest positive integer = %d\n", INT_MAX);
Re: If you have have Done C - Programming Language, Let me know
I got the Bloodshed Dev-C++ installed on my computer, added to the comma and it gives me errors.
I am googling something and will check into the text book here, if you find the solution before I do, let me know.
Thanks saxib.
I am googling something and will check into the text book here, if you find the solution before I do, let me know.
Thanks saxib.
Re: If you have have Done C - Programming Language, Let me know
Here is my entire program and it works, see if you can add to that largest positive integer printf line:
#include <stdlib.h>
#include <stdio.h>
int main()
{
int i = -2147483648;
char ch;
float x;
printf("sizeof(int) =%d bytes\n", sizeof(int));
printf("sizeof(char) = %d bytes\n", sizeof(char));
printf("sizeof(short) = %d bytes\n", sizeof(short));
printf("sizeof(long) = %d bytes\n", sizeof(long));
printf("sizeof(long long) = %d bytes\n", sizeof(long long));
printf("largest positive integer = %d\n", INT_MAX);
system("pause");
return 0;
}
So far so good, I am trying to add the rest, compile and run.
#include <stdlib.h>
#include <stdio.h>
int main()
{
int i = -2147483648;
char ch;
float x;
printf("sizeof(int) =%d bytes\n", sizeof(int));
printf("sizeof(char) = %d bytes\n", sizeof(char));
printf("sizeof(short) = %d bytes\n", sizeof(short));
printf("sizeof(long) = %d bytes\n", sizeof(long));
printf("sizeof(long long) = %d bytes\n", sizeof(long long));
printf("largest positive integer = %d\n", INT_MAX);
system("pause");
return 0;
}
So far so good, I am trying to add the rest, compile and run.
- QansaGabeyle
- SomaliNet Super

- Posts: 14164
- Joined: Wed Feb 27, 2002 7:00 pm
- Location: Beled Xawo, Somalia
- Contact:
Re: If you have have Done C - Programming Language, Let me know
Just add this line to the top and it should compile fine.
#include <limits.h>
#include <limits.h>
Re: If you have have Done C - Programming Language, Let me know
Oh Sh!t, how the fock did I forget that? it explicitly tells me to use that on the assigment, Damn! You know the stuff saxib
Wait now, let me compile and run, be right back
Shaah is on me if it works 
Wait now, let me compile and run, be right back

Re: If you have have Done C - Programming Language, Let me know
It gets complicated bro, still giving me errors, plus the file extension needs to end with .c instead of .cpp for me to get this program to work, compile and run.
Anyway, you saw the questions above which are my assignment, when i finish I will drop by and post how it worked completely.
Thanks for the help Qansa.
Anyway, you saw the questions above which are my assignment, when i finish I will drop by and post how it worked completely.
Thanks for the help Qansa.
- QansaGabeyle
- SomaliNet Super

- Posts: 14164
- Joined: Wed Feb 27, 2002 7:00 pm
- Location: Beled Xawo, Somalia
- Contact:
Re: If you have have Done C - Programming Language, Let me know
I try something like this.......if that other way does not work.
int main() {
long max_num = 2147483647;
long min_num = -2147483648;
printf("largest positive integer = %d\n", max_num);
printf("largest negative integer = %d\n", min_num);
return 0;
}
int main() {
long max_num = 2147483647;
long min_num = -2147483648;
printf("largest positive integer = %d\n", max_num);
printf("largest negative integer = %d\n", min_num);
return 0;
}
Re: If you have have Done C - Programming Language, Let me know
Your program works, I just compiled and executed, however, both maxims, the negtaive and the positive are exactly the same as the ones you assigned before printf commands.
This tells me that the largest positive integer is given and that it is 2147483647. Am I wrong to assume that?
Cause, I replaced the number above with 1 and -1 to see if the printf will return a different value than what I assigned to it. It just gave the same values as I put in, 1 and -1.
Interesting lesson. Thanks saxib.
This tells me that the largest positive integer is given and that it is 2147483647. Am I wrong to assume that?
Cause, I replaced the number above with 1 and -1 to see if the printf will return a different value than what I assigned to it. It just gave the same values as I put in, 1 and -1.
Interesting lesson. Thanks saxib.
- QansaGabeyle
- SomaliNet Super

- Posts: 14164
- Joined: Wed Feb 27, 2002 7:00 pm
- Location: Beled Xawo, Somalia
- Contact:
Re: If you have have Done C - Programming Language, Let me know
Yeah it is given. I got it by compiling your program on my machine and it works fine for me.
http://img237.imageshack.us/img237/4489/untitledzd5.jpg
http://img237.imageshack.us/img237/4489/untitledzd5.jpg
Re: If you have have Done C - Programming Language, Let me know
Thanks Qansa, My compiler is somewhat not executing when I do it the way I wanted and use the printf. Obviously, I am gonna have to assign the values and do it that way although I am afraid the nutty professor will demand to know how I found out the exact values of the largest/smallest positive/negative integers.
I won't look good with a homework I can't explain will I?
But I will show the one that didn't work so he will explain why the compiler wouldn't accept though it works on a different compiler adn teh program is executable. I will make him sweat in explaining. Just for the heck
So, when do you usually show up around here? You are in big trouble for volunteering
But don't be scared, we can do it in private in you wish so though I prefer public.
Thanks bro, Jazakallahu Kheyran man.
I will work on the rest.
I won't look good with a homework I can't explain will I?
But I will show the one that didn't work so he will explain why the compiler wouldn't accept though it works on a different compiler adn teh program is executable. I will make him sweat in explaining. Just for the heck
So, when do you usually show up around here? You are in big trouble for volunteering
But don't be scared, we can do it in private in you wish so though I prefer public.
Thanks bro, Jazakallahu Kheyran man.
I will work on the rest.
Re: If you have have Done C - Programming Language, Let me know
It finally worked for me without assigning values to the Largest and Smallest Integer values
I had syntax errors and used debug/rebuild program.
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
int main()
{
int i = -2147483648;
char ch;
float x;
printf("sizeof(int) =%d bytes\n", sizeof(int));
printf("sizeof(char) = %d bytes\n", sizeof(char));
printf("sizeof(short) = %d bytes\n", sizeof(short));
printf("sizeof(long) = %d bytes\n", sizeof(long));
printf("sizeof(long long) = %d bytes\n", sizeof(long long));
printf("largest positive integer = %d\n",INT_MAX);
printf("most negative integer = %d\n",INT_MIN);
system("pause");
return 0;
}
sizeof(int) =4 bytes
sizeof(char) = 1 bytes
sizeof(short) = 2 bytes
sizeof(long) = 4 bytes
sizeof(long long) = 8 bytes
largest positive integer = 21474836
most negative integer = -2147483648
Press any key to continue . . .
Thanks bro, I will finish the rest inshallah some other time, It is due on Monday but wanted to get head start.
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
int main()
{
int i = -2147483648;
char ch;
float x;
printf("sizeof(int) =%d bytes\n", sizeof(int));
printf("sizeof(char) = %d bytes\n", sizeof(char));
printf("sizeof(short) = %d bytes\n", sizeof(short));
printf("sizeof(long) = %d bytes\n", sizeof(long));
printf("sizeof(long long) = %d bytes\n", sizeof(long long));
printf("largest positive integer = %d\n",INT_MAX);
printf("most negative integer = %d\n",INT_MIN);
system("pause");
return 0;
}
sizeof(int) =4 bytes
sizeof(char) = 1 bytes
sizeof(short) = 2 bytes
sizeof(long) = 4 bytes
sizeof(long long) = 8 bytes
largest positive integer = 21474836
most negative integer = -2147483648
Press any key to continue . . .
Thanks bro, I will finish the rest inshallah some other time, It is due on Monday but wanted to get head start.
-
- Similar Topics
- Replies
- Views
- Last post
-
- 14 Replies
- 2468 Views
-
Last post by IRONm@N
-
- 6 Replies
- 1219 Views
-
Last post by AbdiWahab252
-
- 8 Replies
- 1225 Views
-
Last post by Militant
-
- 2 Replies
- 358 Views
-
Last post by Methylamine
-
- 1 Replies
- 317 Views
-
Last post by Nolol cusub
-
- 8 Replies
- 5453 Views
-
Last post by tightrope
-
- 20 Replies
- 3088 Views
-
Last post by abdalla11
-
- 0 Replies
- 562 Views
-
Last post by Rightwing
-
- 5 Replies
- 547 Views
-
Last post by BVSNet
-
- 8 Replies
- 13034 Views
-
Last post by Caesar