Pavan_ 16 Light Poster

but 'i' doesn't have any any connection with array...i is an independent value and i think it's value should increase infinitely....

Can u tell at what time ,i 's value is changed?

Pavan_ 16 Light Poster
#include<stdio.h>

int main()
{
int a[100], i=0;
while(1)

{

        a[i++]=5;
        printf("%d\n",i);

}
return 0;
}

on gcc this code doesn't give ny error. but after printing the value of i upto 100 , it restart writing value of i from 6 onward...
my question is how value of i is changing after reaching 100..

plz help

Pavan_ 16 Light Poster

So finally this guy has COMPLETED his home work.
congrates...

jephthah commented: what's your point? -2
Pavan_ 16 Light Poster

from which value ur loop is going to start?

Pavan_ 16 Light Poster

but starting from 3 will add unnecessary numbers in our answer...u have to check whether ur number is not less than ur input number and should not greater than 30...and also u have to reject sum ur calculated numbers

in my each calculated number will be our answer..and we do only compare with input number...

Pavan_ 16 Light Poster
#include<stdio.h>
int main()
{
    int i=10,j=30;

   printf("%d %d",i,j);          // this line printing value of i and j...works fine
   printf("%d %d");             // this line again printing value of i and j 
  printf("%d");                     // this line printing value of i

 return 0;
}

On gcc compiler, 2nd and third printf() call taking value of i and j automatically..
but if in first printf() call ,i don't give i and j as argument then that prints garbage value..
can nyone explain it plz..

one more thing...
if i use scanf("%2d %4f",&g,&f); then what will happen...i normally don't use numeric number with %d..
so plz explain both questions.

Pavan_ 16 Light Poster

dude, i can suggest a different approach for ur problem....
since 30 is divisible by 3 so start ur loop from 30 and subtract 3 each time and print until ur number becomes less than the input number...

this approach will print number between ur input and 30 but in decreasing order..

try it.

Pavan_ 16 Light Poster

Can u plz elaborate what dose a real data mean...

#include<stdio.h>
#include<stdlib.h>

int main()
{
       int  *k;
       k=(int*)malloc(sizeof(int));

       *k=10;
       printf("%d %d",k,*k);

       return 0;
}

After adding malloc ,this code compile and execute perfectly ...
can u explain it?

Pavan_ 16 Light Poster

here is the code....

#include<stdio.h>

int main()
{
       int  *k;
       *k=10;
       printf("%d %d",k,*k);

       return 0;
}

it compile perfectly. but on executing it is giving segmentation fault.
where is the problem?

Pavan_ 16 Light Poster

friend , it still not working. after removing the red std as told by u...it is giving the same error..

i think that g++ is standard compiler and a gud compiler.if it is giving an error then sumthing wrong we r thinking or doing......
or i should say that we can't make class named std in c++.:?

my motive about this question is just understanding the concept of namespace...that's it...
and why u all ppl using namespace std...there is no need to use namespace std...

Pavan_ 16 Light Poster

@ tux4life......

friend ur program is giving error in g++ compiler.....
error are:
error: ‘struct std’ redeclared as different kind of symbol
<built-in>:0: error: previous declaration of ‘namespace std { }’

Pavan_ 16 Light Poster

friend , i just want to create a class whose name is std......is there ny way to make that class.....i don't want to correct my error . i just want to create a class named std....that's it...

plz think and reply

Pavan_ 16 Light Poster

but i am not including ny header file then how compiler knows about std?

Pavan_ 16 Light Poster
//#include<iostream>
class std
{
public:
int i;
};

int main()
{
std A;
//float f=0.0f;
}

error: ‘struct std’ redeclared as different kind of symbol
error: previous declaration of ‘namespace std { }’

on compiling , above error comes.
we are not including any header file.....then how compiler knows about namespace std?
can we make any class having std?

one more question is : can we make ny program that doesn't call main()....?

Pavan_ 16 Light Poster

R u sure ? will it crash the program? i really want to see it...

Pavan_ 16 Light Poster

friend i m using gcc nd it is not giving ny error.....

Pavan_ 16 Light Poster

Hello friends,
i have some doubt and hope i will get an satisfactory answer from here.
1) Can memory addresses be negative........i have initialized an array and check the address of element and found it negative...so i want to know can it be negative and if yes then how addresses are assigned to variables.

2)is negative subscript of array allowed in C? if yes then what is the meaning of it?
i found on net that array[-1] will give the last element of array, and also i found that array[-1] equal to *(array-1), then how these two can be same?

One more thing friends....just take a look this code:

#include<stdio.h>

int main()
{
        int i,array[10];

        array[0]=0;
        array[1]=1;
        array[2]=2;
        array[3]=3;
        array[4]=4;
        array[5]=5;
        array[6]=6;

        for(i=-6;i<10;i++)
        printf("%d \t%d\n ",array+i,array[i]);
        printf("\n");
        return 0;
}

And the Out put on my machine is....

-1078159552 0
-1078159548 -1078159552
-1078159544 -1078159552
-1078159540 0
-1078159536 0
-1078159532 0
-1078159528 0
-1078159524 1
-1078159520 2
-1078159516 3
-1078159512 4
-1078159508 5
-1078159504 6
-1078159500 134518452
-1078159496 -1078159464
-1078159492 134513849

Question is how array[-1],array[-2 ] element are zero......is there ny reason???
help plz

Pavan_ 16 Light Poster

For finding prime numbers upto a given no, Use "The Sieve of Eratosthenes algorithm"http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

that is a gud way to find out effectively

tux4life commented: Agreed +8
jephthah commented: gud answer :P +10
Pavan_ 16 Light Poster

Friend u are suppose to give reason also why will u prefer ur approach?
thnx for reply

Pavan_ 16 Light Poster

salem, if u are asked to implement a stack then what u prefer?

Pavan_ 16 Light Poster

thanks , i got ur point.

Pavan_ 16 Light Poster

Hello friends,
I have have found lots of ways to implement a stack using different data structures. But i want to what us the best way (best means code understandability , performance) to implement a stack!!
Share ur thought so i can reach to any final answer.
Different ways ->1. using Link-list
->2. using Array
->3. using pointers.

Also if u know any other method then plz share.

Thanks

Pavan_ 16 Light Poster

At which line declaration and statement are mixing?

Pavan_ 16 Light Poster

i don't get salem's argument....i ran ur program on gcc and it's working fine.
no erroe at all.

Pavan_ 16 Light Poster

When we use getchar() then whatever input we give it goes in a buffer and getchar function reads from that buffer.
when first time u entered ur choice it stored in buffer (say u choose a,then buffer will contain a,\n).so first time , getchar picks the choice u supplied but remember \n is still in buffer.so when getchar() is again called then say u entered ur choice 'b'.then the buffer content will be (\n,b,\n). so this time getchar() picks '\n'. that's y u r getting an error.

Pavan_ 16 Light Poster

sry for my english.... i just want to know that can i use c# for creating any web based application...what ASP.net does?? is it similar to jsp??

both have very similar name!!!!

Pavan_ 16 Light Poster

"you can integrate it with a lot of products via COM,"

what does that means , plz explain it a little...

Pavan_ 16 Light Poster

thnx for ur guidance, for internet point of view , what features c# provide? what can i create for web using c#?

ny gud and easy book aur tutorial for c# and of course for beginner ??

Pavan_ 16 Light Poster

Hello ppl, m computer science student and have learnt c&c++ and want to learn a new language in which i can create gui application with gud performance...i found that java and c# can be 2 option..so which will be best and useful...c# or java???? i found that java is a slow language....i want a gud programming language with gud performance....plz help?? c# or java ...which one will be gud for me...
thnx for ny help..