How do i increment statement or decrement statement in C? -


there 2 ways can this. 1 use increment operator ++ , decrement operator –. example, statement “x++” means increment value of x 1. likewise, statement “x –” means decrement value of x 1. way of writing increment statements use conventional + plus sign or – minus sign. in case of “x++”, way write “x = x +1″.

but why incrementing in code , mean?

    for(i=0; < numberofproducts; ++i){              printf("enter product name: ");               scanf("%s", &(pproducts+i)->productname);              printf("enter product price: ");              scanf("%f", &(pproducts+i)->price);    } 

my question why did use ++i work? tried i++ not print.

for(i=0; < numberofproducts; ++i) 

and

for(i=0; < numberofproducts; i++) 

are both equivalent not reading result of operation (like in a = i++ vs a = ++i). latter form more common.

if have different results, have issues in way testing program.


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -