Skip to content

Commit

Permalink
Updated 5-d-18.c and others
Browse files Browse the repository at this point in the history
  • Loading branch information
Surajkumarsaw1 committed Mar 28, 2023
1 parent 2181ba2 commit f0e5d5f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 32 deletions.
4 changes: 2 additions & 2 deletions assignment-2/3-swap-bitwise.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ void main() {
}


// 1101
// 1011
// 1101 = 13
// 1011 = 11
// ----
// 0110 => not matching

Expand Down
22 changes: 0 additions & 22 deletions assignment-5/d/13.c

This file was deleted.

4 changes: 2 additions & 2 deletions assignment-5/d/17.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ int main() {
else {
printf("Not a perfect number.\n");
}

break;
default:

printf("Enter a valid option.\n");
break;
}
return 0;
Expand Down
15 changes: 9 additions & 6 deletions assignment-5/d/18-prime_and_Automorphic.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
Write a menu driven C program to accept a number from the user and check whether it is a Palindrome or a Perfect number.
(a) Palindrome number: (A number is a Palindrome which when read in reverse order is same as in the right order)
Example: 11, 101, 151 etc.
(b) Perfect number: (A number is called Perfect if it is equal to the sum of its factors other than the number itself.)
Example: 6 = 1 + 2 + 3
Write a menu driven C program to accept a number from the user and check whether it is a Prime number or an Automorphic number.
(a) Prime number: (A number is said to be prime, if it is only divisible by 1 and itself)
Example: 3,5,7,11
(b) Automorphic number: (Automorphic number is the number which is contained in the last digit(s) of its square.)
Example: 25 is an Automorphic number as its square is 625 and 25 is present as the last two digits.
*/

#include <stdio.h>
Expand Down Expand Up @@ -47,11 +47,14 @@ int main() {
sq = num*num;

while( sq/tens != 0){
// printf("sq = %d, tens = %d\t",sq,tens);
// printf("sq/tens = %d\t",sq/tens );
// printf("sq%%tens = %d\n",sq%tens);
if (sq%tens == num){
automorphic = 1;
break;
}
tens += 10;
tens *= 10;
}

if (automorphic){
Expand Down
Binary file removed assignment-5/d/a.out
Binary file not shown.

0 comments on commit f0e5d5f

Please sign in to comment.