Skip to content
Open

d #86

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions armstrong
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>
int main() {
int num, originalNum, remainder, result = 0;
printf("Enter a three-digit integer: ");
scanf("%d", &num);
originalNum = num;

while (originalNum != 0) {
// remainder contains the last digit
remainder = originalNum % 10;

result += remainder * remainder * remainder;

// removing last digit from the orignal number
originalNum /= 10;
}

if (result == num)
printf("%d is an Armstrong number.", num);
else
printf("%d is not an Armstrong number.", num);

return 0;
}
15 changes: 15 additions & 0 deletions stringreverse
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <stdio.h>
#include <string.h>
int main()
{
char s[100];

printf("Enter a string to reverse\n");
gets(s);

strrev(s);

printf("Reverse of the string: %s\n", s);

return 0;
}