Saturday, May 18, 2013
Saturday, May 4, 2013
Crypt-arithmetic e litmus questions abc*def
What is a cryptarithmetic problem? It is a mathematical puzzle in which each letter represents
a digit (for example, if X=3, then XX=33). The object is to find the value of each letter. No two
letters represent the same digit (If X=3, Y cannot be 3). And the first letter cannot be 0 (Given
the value ZW, Z cannot be 0). They can be quite challenging, often involving many steps.
Here's an example, illustrating how to solve them:
. SEND
+MORE
MONEY
M must be 1. If you'll notice, this is an addition problem; the sum of two four digit numbers can't
be more than 10,000, and M can't be 0 according to the rules since it's the first letter. So now
you have:
. SEND
+1ORE
1ONEY
Now in the column S1O, S+1≥10. S must be 8 (if there is a 1 carried over from the column
E0N) or 9. O must be 0 (if S=8 and there is a 1 carried or S=9 and there is no 1 carried) or 1 (if
S=9 and there is a 1 carried). But 1 is already taken, so O must be 0.
. SEND
+10RE
10NEY
There can't be a carry from the column E0N, because any digit plus 0 < 10, unless there is a
carry from the column NRE and E=9; but this cannot be the case, because then N would be 0,
and 0 is already taken. So E<9 and there is no carry from this column. Therefore, S=9,
because 9+1=10.
. 9END
+10RE
10NEY
In the column E0N, E cannot be equal to N, so there must be a carry from the column NRE;
E+1=N. We now look at the column NRE; we know that E+1=N. Since we know that there is a
carry from this column, N+R=1E (if there is no carry from the column DEY) or N+R+1=1E (if
there is a carry from the column DEY). Let's try out both cases.
No carry: N+R=10+(N-1)=N+9
R=9
9 is already taken, so this won't work.
Carry: N+R+1=N+9
R=8
This must be the solution for R.
. 9END
+108E
10NEY
The digits we have left are 7, 6, 5, 4, 3, and 2. We know there must be a carry from the column
DEY, so D+E>10. N=E+1, so E can't be 7 because then N would be 8 which is already taken.
D is at most 7, so E cannot be 2 because then D+E<10, and E cannot be 3 because then
D+E=10 and Y=0, but 0 is taken already. Likewise, E cannot be 4 because if D>6, D+E<10,
and if D=6 or D=7, then Y=0 or Y=1, which are both taken. So E is 5 or 6.
If E=6, then D=7 and Y=3, so this part works. But look at the column N8E. Remember, there is
a carry from the column D5Y. N+8+1=16 (because we know there is a carry for this column).
But then N=7, and 7 is taken by D. Therefore, E=5.
. 95ND
+1085
10N5Y
Now that we've gotten this important digit, it gets much simpler from here. N+8+1=15, N=6.
. 956D
+1085
1065Y
The digits left are 7, 4, 3, and 2. We know there is a carry from the column D5Y, so the only
pair that fits is D=7 and Y=2
. 9567
+1085
10652
And Voila! The problem is solved! These are quite tricky and require some thinking, but are
lots of fun. Now we'll take turns posting problems. When a problem is solved, you may post
another problem. Be sure to show your work; you don't have to write detailed instructions
like I did, but show your steps at least, since figuring out how to solve the problem is the most
important part. I'll start things off here:
EAT
+THAT
APPLE
. . EAT
+THAT
APPLE
I started off knowing that T is not 0, as T+T is not equal to T. Same case with A.
From know on, I'm gonna show the steps to my answer. Don't ask HOW I got them, it's too
much work that I did on a piece of paper. And I can't type all that.
. . EA9
+9HA9
APPLE
. . 8A9
+9HA9
APPL8
. . 819
+9H19
APPL8
. . 819
+9H19
APP38
. . 819
+9219
A0038
. . 819
+9219
10038
FINAL ANSWER:
. . EAT
. . 819
+THAT
+9219
APPLE
10038
Thursday, May 2, 2013
c programs using structures
Theory Questions:
1.
What is a structure?
2.
What is an ADT?
3.
What is the syntax for creating a structure?
4.
What is the size of a structure?
5.
What is the use of typedef?
6.
Does structure definition need a semicolon?
7.
Does structure definition exist inside main?
8.
How many structure can have in a program?
9.
Does structure can contain another structure?
10.
Built in structures?
a.
time
b.
FILE
11.
What is Structure initialization?
12.
What is Structure variable Assignment?
Programs (Task):
1.
Create a Employee structure with the following
a.
Members
i.
Empno
ii.
Ename
iii.
Job
iv.
Salary
b.
Use typedef and provide a alias Emp
c.
Declare a two variables for the structure
d.
Read data into the variables ( structure objects
)
e.
Display the data exist in structure object
f.
Display sum of two employee salaries.
2.
Declare two objects for employee stricture and
initialize the objects and display.
3.
Initialize two employee objects (a,b), copy the data into c,d objects and display.
4.
Declare an Address strcture with the following
a.
Members
i.
DNo
ii.
Street
iii.
City
iv.
Pin
b.
Declare 2 objects
c.
Read data
d.
Display data
5.
Declare structure Array Object for Employee
e[12];
a.
Assign data into array object
b.
Display all the employee data
c.
Display male employee
d.
Display female employee
e.
Sort data based on ename
6.
Declare strcture Array object for employee e[10]
a.
Read the data into array object
b.
Display in given order
c.
Display in reverse order
7.
Write a program for the following Menu
a.
Read Employee
b.
Dsiplay Employee
c.
Delete Employee
d.
Search Employee
e.
Edit Employee
f.
Exist
g.
Enter the choice :
8.
Declare a stricture object and initialize the
data
a.
Display using function with structure parameter
9.
Create A Time structure
a.
Declare three objects
b.
Assign in time in 1 structure variable
c.
Assign out time in another structure
d.
Display in and out times
e.
Fill the third structure with substation of in
and out
f.
Display the session duration.
10.
Create a Date structure
a.
Declare object
b.
Read the data by validating input.
c.
Display the data
programs on arrays in c-language
Character Arrays: (using built in functions from string.lib)
1.
Read your name into character array and display.
2.
Read a sentence into character array and
display.
3.
Read a string and display its length using
strlen().
4.
Read a string and display in uppercase using
strupr()
5.
Read a string and display in lowercase using
strlwr()
6.
Read a string and display in reverse using
strrev()
7.
Copy your name into character array name[] and
display using strcpy()
8.
Read 2 names into character array name1[] and
name2[] and interchange using strcpy()
9.
Read your first name into character array
name1[] and concat your last name into name2[] and display using strcat()
10.
Read a string and check the given string in
palindrome or not using strrev() and strdup()
String manipulations (without using loops)
11.
Read a string and display letters in it.
12.
Read a string and display the count of letters.
13.
Read a string and display the count of small
letters.
14.
Read a string and display the count of vowels.
15.
Read a string and display letters in uppercase.
16.
Read a string and display letters in lower case.
17.
Read a string and display the letters in
opposite case.
18.
Read a string display the count of words in it.
19.
Read a string and display the string in initcap.
20.
Read a string and display in reverse order.
21.
Read a string and arrange the letters in
ascending order.
22.
Read a string and arrange the letters in
descending order.
23.
Read a string and eliminate the duplicates in
it.
24.
Read a string and search for a letter in it.
25.
Read a string and search for a word in it.
26.
Read a string and copy the string into another
character array.
27.
Read a string and add welcome message to it.
28.
Display the following output
K
K I
K I R
K I R A
K I R A N
Display the output
K I R A N
K I R A
K I R
K I
K
c programs on Functions and theory questions on c language
a)
What is the use of following functions?
a.
gotoxy
b.
kbhit()
c.
delay()
d.
sleep()
b)
Program to display ascii values.
c)
What is enum? How to declare multiple constants
using enum.
d)
What is the use const object?
1.
Write a program to develop writechar() function
to display character in a specified position. Writechar(‘a’,45,16);
2.
Write a program to develop writestring()
function to display string in a specified position. Writestring(“kiran”,10,10);
3.
Write a program to develop hline() to draw a
horizontal line. Hline(5, 10, 80 );
4.
Write a program to develop vline() to draw a
vertical line. Vline (5, 5, 25 );
5.
Write a program to develop drawbox() to draw a
box, drawbox(5,5,70,24);
6.
Write a program to display drawborders() to
display borders. Drawborders(5,5,70,24)
List of Exercise c programs on Functions (Returning values)
1.
Write a program to develop functions for the
following
a.
return square of the given number in the
parameter.
b.
which takes two integer partakers and return sum
of the values.
c.
which takes two integer partakers and return
biggest of two numbers.
d.
which takes two integer partakers and return
smallest of two numbers.
e.
which takes an integer parameter and returns its
factorial values.
f.
which takes an integer parameter and return sum
of 1 to n.
g.
which takes an integer parameter and return sum
of digits
h.
which takes an integer parameter and return the
reverse
i.
which takes an integer parameter and return nearby
prime.
j.
which takes an integer parameter and return number
of zero digits in a given number.
2.
Write a function which takes integer parameter
and return true or false for the following
a.
IsZero(9)
b.
IsEven(9);
c.
IsOdd(9);
d.
IsPositive(9)
e.
IsCapital(‘A’)
f.
IsSmall(‘A’)
g.
IsNemeric(‘d)
h.
IsVowel(‘a’)
i.
IsAlphabet(‘%’)
j.
IsAlnum(‘=’)
3.
Write a function which takes integer parameter
and return true or false for the following
a.
IsPrime()
b.
IsPalindrome()
c.
IsPerfect()
d.
IsArmstrong()
e.
IsLeapYear()
List of Exercise c programs on functions
1.
What is a Function? What is the Syntax for developing
a function?
2.
What is the use of void keyword?
3.
What is a header file and library file?
4.
What is a storage class?
5.
What is the use of #include
6.
What is the use of static storage class?
7.
Explain the following terms
a.
Function prototype
b.
Function Definition
c.
Function Developing
d.
Function Invoking/Calling
i.
Call by value
ii.
Call by reference
e.
Function returning value
f.
Recursive functions
8.
What are the important functions exist in following
libraries
a.
Conio.lib
b.
Stdio.lib
c.
Math.lib
d.
Ctype.lib
e.
String.lib
f.
Alloc.lib
g.
Dos.lib
c programs on loops(n dimensional)
1. Program to display multiplication tables from 1 and 10
2. Program to display factorial values from 1 and 10
3. Program to display palindrome numbers between 150 250
4. Program to display prime numbers between 1 and 1000
5. Program to display perfect numbers between 1 and 10000
6. Program to display Armstrong number between 1 and 10000
7. Program to display twin primes between 1 and 1000
8. Program to display nearest prime number for the given
number
11. Write a program to display the following output.
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
12. Write a program to display the following output.
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
13.. Write a program to display the following output.
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
14. Write a program to display the following output.
5 5 5 5 5
4 4 4 4 4
3 3 3 3 3
2 2 2 2 2
1 1 1 1 1
15. Write a program to display the following output.
a b c d e
f g h i j
k l m n o
p q r s t
u v w x y
16. Write a program to display the following output.
1 1 1 1 1
0 0 0 0 0
1 1 1 1 1
0 0 0 0 0
1 1 1 1 1
17. Write a program to display the following output.
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1
18. Write a program to display the following output.
1 1 1 1 1
1 1
1 1
1 1
1 1 1 1 1
19. Write a program to display the following output.
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
20. Write a program to display the following output.
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
21. Write a program to display the following output.
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
22. Write a program to display the following output.
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
23. Write a program to display the following output.
1
1 2
1 2 3
1 2
1
24. Write a program to display the following output.
0 0 0 0 1
0 0 0 1 2
0 0 1 2 3
0 1 2 3 4
1 2 3 4 5
25. Write a program to display the following output.
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
26. Write a program to display the following output.
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
28. Write a program to display the following output.
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
29. Write a program to display the following output.
1 2 3 4 5 4 3 2 1
1 2 3 4 4 3 2 1
1 2 3 3 2 1
1 2 2 1
1 1
30. Write a program to display the following output.
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1
List of Exercise c programs on arrays
1.
Read 5 elements into an array vector and
display.
2.
Read 5 elements into an array vector and display
in reverse order.
3.
Read 5 elements into an array vector and display
sum of elements
4.
Read 5 elements into an array vector and display
biggest element.
5.
Read 5 elements into an array vector and display
smallest element.
6.
Read 5 elements into an array vector and display
average of elements.
7.
Read 5 elements into an two array’s and merge
into 3rd array and display
8.
Read 5 elements into an array vector and search
for a given element (LINEAR SEARCH).
9.
Read 5 elements into an array vector and search
for a given element (BINARY SEARCH).
10.
Read 5 elements into an array vector and add
element at last position.
11.
Read 5 elements into an array vector and add
element at first position.
12.
Read 5 elements into an array vector and add
element at specified n position.
13.
Read 5 elements into an array vector and delete
element at specified position.
14.
Read 5 elements into an array vector and
implement SELCTION SORT ascending order.
15.
Read 5 elements into an array vector and
implement BUBBLE SORT ascending order.
c programs on loops(single dimension)
1.
Display 1 to 10 numbers
2.
Display 10 to 1 numbers
3.
Display 2, 4, 6, 8, 10
4.
Display 1,3,5,7,9
5.
Display capital letter alphabets
6.
Display small letter alphabets.
7.
Display all letters using their ASCII values
8.
Display sum of 1 to 10 numbers
9.
Display sum of 5 to 1 numbers
10.
Write a program to read a number and display its
multiplication table
11.
Write a program to read a number and display its
factorial value
12.
Write a program to read a number and generate Fibonacci
series
13.
Write a program to read a number and display
factors of give number
14.
Write a program to read a number and display
count of factors
15.
Write a program to read a number and display
count of even factors
16.
Write a program to read a number and display sum
of factors
17.
Write a program to read a number and display the
count digits in a given number.
18.
Write a program to read a number and display
count of zero digits in a given number.
19.
Write a program to read a number and display
count of odd digits in a given number.
20.
Write a program to read a number and display sum
of digits.
21.
Write a program to read a number and reverse the
given integer.
22.
Write a program to read a number and check the
given number is PRIME or not.
23.
Write a program to read a number and check the
given number if ARMSTRONG or not.
24.
Write a program to read a number and check given
number is PALINDROME or not.
25.
Write a program to read a number and check the
given number is PERFECT number or not
Subscribe to:
Posts (Atom)