-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to be committed: new file: assignment-3/4-if-even-odd modified: others/classes/2023-04-11/2.c modified: others/classes/2023-04-11/3.c new file: others/classes/2023-04-11/4.c Changes not staged for commit: deleted: assignment-3/4-if-even-odd
- Loading branch information
1 parent
2b67eb3
commit 97a78e4
Showing
4 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// WAP to take input of 10 number, display product of all numbers divisible by 5. | ||
#include <stdio.h> | ||
|
||
int main() { | ||
|
||
int arr[10], product = 1, i; | ||
|
||
printf("Enter 10 numbers : "); | ||
|
||
// Taking input of 10 numbers | ||
for (i = 0; i < 10; i++){ | ||
scanf("%d",&arr[i]); | ||
} | ||
|
||
// product of numbers,which is multiple of 5 | ||
for (i = 0; i < 10; i++){ | ||
// checking if divisible by 5 using ternary operator | ||
arr[i]%5 == 0 ? (product *= arr[i]) : (product *= 1); | ||
|
||
// checking if divisible by 5 using if operator | ||
// if (arr[i]%5 == 0){ | ||
// // if divisible by 5 | ||
// product *= arr[i]; | ||
// } | ||
} | ||
|
||
// printing result | ||
printf("Product = %d",product); | ||
return 0; | ||
} |