You are on page 1of 2

Mnemonics to learn programming statement

For Loops: Remember the structure with "FIT," which stands for "For Initialization, Test condition, Increment."

If-Else Statements: Think of "ELF" for "Else, Less, or False." If the condition is false, it goes to the else block.

Switch Statements: Use "CASE" to remember "Control And Select Execution."

While Loops: Think of "WHILE" as "While Holding In Loop Execution."

Functions: Remember "DEF," which stands for "Define, Execute, Function."

Variables: "VAR" can stand for "Value Assignment and Retrieval."

Arrays: Use "LIST" for "List Items Sequentially Together."

Classes and Objects: Think of "COO" for "Class, Object, and Operations."

Try-Catch Blocks (Exception Handling): Remember "TRY" as "Test, React, Yield" to handle errors.

Comments: Use "REM" for "Remember, Explain, Mark" to remind yourself why you added comments.."

If else c programming source code

#include <stdio.h>

int main() {
int number;

// Input from the user


printf("Enter an integer: ");
scanf("%d", &number);

// Check if the number is even or odd


if (number % 2 == 0) {
printf("%d is an even number.\n", number);
} else {
printf("%d is an odd number.\n", number);
}

return 0;
}
In this code:

We include the <stdio.h> header for input and output functions.


We declare an integer variable number to store the user's input.
We prompt the user to enter an integer using printf and read the input with scanf.
The if-else statement checks whether number % 2 is equal to 0 to determine if it's even or odd.
Depending on the result, it prints the appropriate message.
Compile and run this code, and it will tell you whether the input number is even or odd.

"%d" means in c programming


In C programming, "%d" is a format specifier used with functions like printf and scanf to indicate that you are
working with an integer. Here's what it means:

When used with printf, "%d" is a placeholder that tells the printf function to expect an integer argument, and it will
replace "%d" with the actual integer value provided when the printf function is called. For example:

printf("The number is: %d", number);


In this case, "%d" is replaced with the value of number, which is 42, and the output will be "The number is: 42".

When used with scanf, "%d" is a placeholder that tells the scanf function to expect an integer input from the user. It
will read an integer value from the user and store it in a variable you specify. For example:
int input;
scanf("%d", &input);
In this case, "%d" instructs scanf to read an integer from the user and store it in the input variable.

In summary, "%d" is a format specifier in C used to work with integer values when formatting output with printf or
reading input with scanf.

You might also like