Monday, May 24, 2010

Help in designing simple c program?

I need help designing a program in c that ask's an intiger from the user and determine whether the number is a multiple of 3, 2, or of 3 and 2" yeah i know its freakign easy, but i dont know where to place ";" "{" "}" "else" statements and variables, can someone tell me when i should use those functions (and help me design a code?) thank you

Help in designing simple c program?
#include%26lt;stdio.h%26gt;





void main(void)


{


int a;


printf("Enter the number: ");


scanf("%d",%26amp;a);





if(a%2==0 %26amp;%26amp; a%3==0)


printf("The number is a multiple of 2 and 3");


else if(a%2==0)


printf("The number is a multiple of 2");


else if(a%3==0)


printf("The number is a multiple of 3");


else


printf("The number is not a multiple of 2 or 3");


}
Reply:Example IF:





if (a==1)


{


b = 2;


}


else


{


b=3;


}
Reply:there syntax in C lang








if (condition)


{





statement;


}


else


{


statement;


}








ever statement worte in { } and sholud b completed by " ; "

wedding reception flowers

No comments:

Post a Comment