473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Loop optimization and execution

th equestion goes like

Q1.

for(i=0;i<=50;,i++)
for(j=0;,j<=100,j++)

for(j=0;j<=100;,j++)
for(i=0;i<=50,i++)

for these type of loop which will be faster ??

options are
same
first
second
depends on s/w and h/w

Q2

#define putchar(%f,c)
int c='p'';
putchar(c);

what wil b the o/p??
a...some nos.
b..some nos.
c. cmpiling error
d. segmentation error
Aug 23 '07 #1
3 1531
Meetee
931 Expert Mod 512MB
th equestion goes like

Q1.

for(i=0;i<=50;,i++)
for(j=0;,j<=100,j++)

for(j=0;j<=100;,j++)
for(i=0;i<=50,i++)

for these type of loop which will be faster ??

options are
same
first
second
depends on s/w and h/w

Q2

#define putchar(%f,c)
int c='p'';
putchar(c);

what wil b the o/p??
a...some nos.
b..some nos.
c. cmpiling error
d. segmentation error
AFAIK, Q.1 output will be first. I afraid Q.2 has some syntax errors. Please check it and try by your own to compile the code.

Regards
Aug 23 '07 #2
q.
recursive function
count(n){
if count<=1
then result = 1;
else
result = count(n-3) + count(n-1)
}
for count(6) ans is:
a. 3
b. 6
c. 9
d. 12

q
#define putchar(%f,c)
int c='d';
putchar(c);
what is the output?
a. ,b. some numbers
c. compiler error
d. segmentation error

q

file a
test()
{ int a; }
file b
void main(void)
{ int b;
b= test();
}
what is the output
a. a
b. b
c. not compiled,error
d. compiles sucessfully,but give linker error
Aug 23 '07 #3
Meetee
931 Expert Mod 512MB
q.
recursive function
count(n){
if count<=1
then result = 1;
else
result = count(n-3) + count(n-1)
}
for count(6) ans is:
a. 3
b. 6
c. 9
d. 12

q
#define putchar(%f,c)
int c='d';
putchar(c);
what is the output?
a. ,b. some numbers
c. compiler error
d. segmentation error

q

file a
test()
{ int a; }
file b
void main(void)
{ int b;
b= test();
}
what is the output
a. a
b. b
c. not compiled,error
d. compiles sucessfully,but give linker error
I think you are taking test of TSDN!!! Better you compile and check the answers by yourself.

Regards
Aug 23 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: MiniDisc_2k2 | last post by:
The post C++ Scope reminded me of a question which has been bothering me for very long. My compiler decided to do this: for (int x = 0; x < 10; x++) std::cout << x; for (int x = 0; x < 20;...
5
by: John Edwards | last post by:
Hello, I have sort of a newbie question. I'm trying to optimize a loop by breaking it into two passes. Example: for(i = 0; i < max; i++) {
4
by: hall | last post by:
Hi. I've come across someting strange. I was trying to make a for-loop execute repetadly until the function called inside it does not return true during the entire loop (see program below). ...
2
by: smauldin | last post by:
Why does the execution plan have a nested loop join for a simple select with an UDF in the where clause? Here is the query: select * from test_plan where vCol = my_udf('test') Here is the...
33
by: apropo | last post by:
what is wrong with this code? someone told me there is a BAD practice with that strlen in the for loop, but i don't get it exactly. Could anyone explain me in plain english,please? char...
34
by: sushant | last post by:
hi all, suppose i have 2 loops one inside the other, like this 1) for(i=0;i<=100;i++) { for(j=0;j<=10;j++) { some code; }
10
by: MariusI | last post by:
I stumbled over an optimization (or lack of one, to be specific) when viewing IL opcodes generated by the compiler using ms .net 2003. I was testing fast pixel manipulation using Bitmap.LockBits...
8
by: Terry Olsen | last post by:
How do I loop back to the beginning of a for/next loop before getting to the end of it? Isn't there an "iterate" command or something like that? For Each This in That ...code if This = False...
102
by: tom fredriksen | last post by:
Hi I was doing a simple test of the speed of a "maths" operation and when I tested it I found that removing the loop that initialises the data array for the operation caused the whole program to...
26
by: a.mil | last post by:
I am programming for code-speed, not for ansi or other nice-guy stuff and I encountered the following problem: When I have a for loop like this: b=b0; for (a=0,i=0;i<100;i++,b--) { if (b%i)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.