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?
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?
#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
So finally this guy has COMPLETED his home work.
congrates...
from which value ur loop is going to start?
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...
#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.
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.
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?
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?
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...
@ 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 { }’
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
but i am not including ny header file then how compiler knows about std?
//#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()....?
R u sure ? will it crash the program? i really want to see it...
friend i m using gcc nd it is not giving ny error.....
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
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
Friend u are suppose to give reason also why will u prefer ur approach?
thnx for reply
salem, if u are asked to implement a stack then what u prefer?
thanks , i got ur point.
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
At which line declaration and statement are mixing?
i don't get salem's argument....i ran ur program on gcc and it's working fine.
no erroe at all.
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.
"you can integrate it with a lot of products via COM,"
what does that means , plz explain it a little...
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 ??
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..