Computer Science, asked by SƬᏗᏒᏇᏗƦƦᎥᎧƦ, 1 month ago

•Explain if else statement and give a example.
•Explain block of statements.
bye!​

Answers

Answered by itztalentedprincess
51

Question:

Explain if else statement and give a example.

Answer:

If Statement:

It is a conditional statement where one condition is true and other is false.

Example of: If Statement

// Program to display a number if it is negative #include <stdio.h> int main() { int number; printf("Enter an integer: "); scanf("%d", &number); // true if number is less than 0 if (number < 0) { printf("You entered %d.\n", number); } printf("The if statement is easy."); return 0; }

Block of statements:

Block of statements is a function, where it can be zero or more statements enclosed in braces. But in some situations you have to use only one statement.

____________________________________________________________

Hope it helps #Be honest can we be frnd?

Attachments:
Answered by IISLEEPINGBEAUTYII
5

Answer:

  • // Program to display a number if it is negative #include <stdio.h> int main() { int number; printf("Enter an integer: "); scanf("%d", &number); // true if number is less than 0 if (number < 0) { printf("You entered %d.\n", number); } printf("The if statement is easy."); return 0; }

  • A block statement, or compound statement, lets you group any number of data definitions, declarations, and statements into one statement. All definitions, declarations, and statements enclosed within a single set of braces are treated as a single statement. You can use a block wherever a single statement is allowed.
Similar questions