tag:blogger.com,1999:blog-54471684809503960392024-03-06T03:44:53.820+05:30Mysterious World!If you wanna get in touch with this amazing World, you are at right place.!Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.comBlogger33125tag:blogger.com,1999:blog-5447168480950396039.post-33799695852719362352015-04-29T14:16:00.001+05:302015-04-29T14:17:54.058+05:30Squaring of Number<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
Now Squaring of Number will be very easy by the Multiplications method we have learn in previous Posts.</h2>
<div>
<br /></div>
<div>
Let me give you few Examples of it.</div>
<div>
<br /></div>
<div>
9 -1</div>
<div>
<u>9 -1</u></div>
<div>
<b>8 / 1</b></div>
<div>
<br /></div>
<div>
12 +2 97 -3 108 +8 997 -3 1021 +21</div>
<div>
<u>12 +2</u> <u> 97 -3</u> <u>108 +8</u> <u>997 -3</u> <u>1021 +21</u></div>
<div>
<b>14 /4 94 / 09 116 / 64 994/009 1042/441</b></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
28 +8 72 +2 72 -8</div>
<div>
<u>28 +8</u> <u>72 +2</u> <u> 72 -8</u></div>
<div>
36 / 64 74 /4 64 /64</div>
<div>
<u>x2 </u> <u>x7 </u> <u> x8 </u></div>
<div>
72 /64 <b>518 /4 </b> 512/64</div>
<div>
=784 <b> =518/4</b></div>
<div>
<br /></div>
<h2 style="text-align: left;">
Now Lets see what if Number ends at 5!</h2>
<h3 style="text-align: left;">
The magic comes here!</h3>
<div>
45*45 = (4*5) /25 = <b>20 / 25</b></div>
<div>
<br /></div>
<div>
85*85 = (8*9)/25 = <b>72 / 25</b></div>
<div>
<br /></div>
<div>
115*115 = (11*12)/25 = <b>132 / 25 </b></div>
<div>
<br /></div>
<div>
325*325 = (32*33)/25 = <b>1056 / 25</b> ---> <b>i calculate 32*33 directly using Vedic method!</b></div>
<div>
<br /></div>
<div>
1235*1235 = (123*124)/25 = <b>15252 / 25</b> ---> <b>i calculate 123*124 directly using Vedic method!</b></div>
<div>
<br /></div>
<div>
105*105 = (10*11)/25 = <b>110 / 25</b></div>
<div>
<br /></div>
<div>
95*95 = (9*10)/25 = <b>90 / 25</b></div>
<div>
<br /></div>
<h2 style="text-align: left;">
Now you have learn lots of tricks to multiply and square number very Quick with very easy Methods!<br />Congratulations!</h2>
<h2 style="text-align: left;">
<span style="color: red;">Don't Forget to share it with your Friends.</span></h2>
<div>
<br /></div>
</div>
Jiten Aminhttp://www.blogger.com/profile/06500318083115629514noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-24995220659111046792015-04-29T00:01:00.001+05:302015-04-29T00:01:40.542+05:30Two digit multiplication Easy methods<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizsL7aHQP1mtDR-E6RmLKYeJSu8qzy2y5MpSzwQZszk9xaAM72ueUvUw9Keq6LAL9ML5FmsAZ_GQYPzsBnAxNqYtT989ibjxX5DujgiNO17_W7z836J7Z1hG7v8jPLEDsNeyGvtCwgjYM/s1600/IMG_20150428_123208.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizsL7aHQP1mtDR-E6RmLKYeJSu8qzy2y5MpSzwQZszk9xaAM72ueUvUw9Keq6LAL9ML5FmsAZ_GQYPzsBnAxNqYtT989ibjxX5DujgiNO17_W7z836J7Z1hG7v8jPLEDsNeyGvtCwgjYM/s1600/IMG_20150428_123208.jpg" height="200" width="122" /></a><br />
<b>Do you tired of teaching your child multiplication tables?</b><br />
<br />
Here i have something for you that you will feel that you do not need to remember Multiplication table more then number 5. <span style="color: blue;">Isn't it sounds cool ?</span><br />
<span style="color: blue;"><br /></span>
Let me Explain how to multiply 9 x 6 using 10 as base.<br />
<br />
1) do 9-10 and write it to the right side of 9<br />
<br />
2) do 6-10 and write it to the right side of 6<br />
<br />
3) Now left side digit will calculate using Multiplication of right most digits that has been calculated using (1) and (2)<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTONUY7Y5V4w6yGpdtJq0Djf9MubRZluzugT9op_7f69rozBR4wMTWECsE96Hs6nGkW9rWKw_Opy5Qfzzu0SGPIO0L_QYmIl_O-u3RvFXzxgWjwt-GB8IduMNpwoKzOcaQqkiZu2CTKAU/s1600/IMG_20150428_123557.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTONUY7Y5V4w6yGpdtJq0Djf9MubRZluzugT9op_7f69rozBR4wMTWECsE96Hs6nGkW9rWKw_Opy5Qfzzu0SGPIO0L_QYmIl_O-u3RvFXzxgWjwt-GB8IduMNpwoKzOcaQqkiZu2CTKAU/s1600/IMG_20150428_123557.jpg" height="200" width="104" /></a>4) And Left Side Digit will calculate using add numbers in cross sides. i.e add 9 to -4 or add 6 to -1 both will give the same result.<br />
Here i have another Example of the same Methods that display another case of getting result in 2 digit right side. and how to handle it.<br />
<br />
In such case we simply add right side's first digit to left side.<br />
<br />
Now we are Moving towards number having more then 1 digit.<br />
<br />
Now i will Show you how to multiply number near 100.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizJC-AWdkd0cAUYwBLUyefC1T8_-CwNHT4IZ2Hh_qFpWX-YNFDVECzMHWqnyyzyhgt6X5IunZkGSmYDUO8qcCvJ-t6DCwm58UjqmPGDq2wWqG-Cu5BQvczNd1Sw6kP6B5wcaFb6OBKj_0/s1600/IMG_20150428_131136.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizJC-AWdkd0cAUYwBLUyefC1T8_-CwNHT4IZ2Hh_qFpWX-YNFDVECzMHWqnyyzyhgt6X5IunZkGSmYDUO8qcCvJ-t6DCwm58UjqmPGDq2wWqG-Cu5BQvczNd1Sw6kP6B5wcaFb6OBKj_0/s1600/IMG_20150428_131136.jpg" height="200" width="113" /></a></div>
Method will Remain same as above but just the difference is on right side in answer we will have 2 digit as it is multiplication by number near 100.<br />
<br />
<span style="color: red;">How Simple it is! Then Why not use it by making daily Practice using it?</span><br />
<span style="color: red;"><br /></span>
Now Lets see number Near 100 but above 100.<br />
<br />
113 +13<br />
<u>102 +2</u><br />
115 / 26<br />
<br />
<h3 style="text-align: left;">
<span style="color: purple;">how easy????</span></h3>
<h2>
Can you Imagine Multiplication can be much faster and easier like this?</h2>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
Let take another Example of numbers in 1000.<br />
<br />
988 -12 1113 +113<br />
<u>998 -2 </u> <u>1002 +2 </u><br />
986 / 024 1115 / 226<br />
<br />
What if one number is above our consider Base and another is above it???<br />Let Understand it by Example.<br />
<br />
13 +3<br />
<u>7 -3</u><br />
10 / -9<br />
=91<br />
<br />
because -9 will be subtracted from 10<br />
<br />
Let see another Example.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3glPFS69fYYRTOtl_dIoSm44jRpQwl8PFXuucINdag14VDmFSZtDRNJRQQeHg50BGl5k1TkaSVcah0oC7a-WXzRpCntRzWR1onekwNlG6uV_-EDcMFJG770W-UNlrLHmRBc4ZCQK5ZCA/s1600/11.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3glPFS69fYYRTOtl_dIoSm44jRpQwl8PFXuucINdag14VDmFSZtDRNJRQQeHg50BGl5k1TkaSVcah0oC7a-WXzRpCntRzWR1onekwNlG6uV_-EDcMFJG770W-UNlrLHmRBc4ZCQK5ZCA/s1600/11.png" height="200" width="150" /></a><br />
114 +14<br />
<u>97 - 3 </u><br />
111 / -42<br />
=11058<br />
Because 42 will be subtracted from last 100.<br />
<br />
<h3 style="text-align: left;">
Let Take another Example to clear it!</h3>
<br />
<br />
<h3 style="text-align: left;">
<br />Now What if Number is not near by 10 or not 100 or not 1000????</h3>
<br />
Don't Worry We have Method for it too!<br />
<br />
i.e Example of base 20<br />
<br />
24 +4<br />
<u>18 -2</u><br />
22 / -8<br />
<u>x2 </u> -----> here We Do multiplication by 2 because base is 10x2<br />
44/-8<br />
=432<br />
<br />
This Method is Similar for all Number that is come near by some number. Practice of it will make you aware which method we can use for which numbers.<br />
<br />
Let Take another Example to Finalize this Method with Practice.<br />
<br />
76 +6<br />
<u>68 -2</u><br />
74 / -12<br />
<u>x7 </u><br />
518/-12<br />
=5168<br />
<br />
We have many more methods that we will see in next blog. Till Practice this one!<br />Have a Good Day.</div>
Jiten Aminhttp://www.blogger.com/profile/06500318083115629514noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-75967761183418632622015-04-27T10:50:00.000+05:302015-04-27T20:51:21.802+05:30Multiplication of 3 digit numbers<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
</div>
If you want to multiply 123 and 456 then consider 1 in 123 as a ,2 in 123 as b and 3 in 123 as c.<br />
<br />
so the number 123 will be written as <b>ax2 + bx +c</b><br />
<b><br /></b>
here x is 10 so<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; text-align: right;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoiOyuccf7oxjdxiK5EIXGZS3p5U4q_tSRdgSCr9qlo4nv10hO3uNoTymmXc5Uctjb__p81E3RprIXqLxtXOfBqC48vyCEehid4z3DTXVZdUbPaIDnxybUOc_9A_8_3sewljd__2DlnQU/s1600/multiplication1.jpg" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoiOyuccf7oxjdxiK5EIXGZS3p5U4q_tSRdgSCr9qlo4nv10hO3uNoTymmXc5Uctjb__p81E3RprIXqLxtXOfBqC48vyCEehid4z3DTXVZdUbPaIDnxybUOc_9A_8_3sewljd__2DlnQU/s1600/multiplication1.jpg" height="228" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Here i have illustrate how to multiply 3 digit numbers using<br />
Vedic method with Explanation</td></tr>
</tbody></table>
<br />
ax2+bx+c<br />
=1*10*10 + 2*10 + 3<br />
=100 + 20 + 3<br />
=123<br />
<br />
in same manner we take 456 as dx2 + ex + f<br />
<br />
so now multiplication is between <b>ax2 + bx +c and dx2 + ex + f </b><br />
<b><br /></b>
so the answer is (ad)x4 + (ae + bd)x3 + (af + be + cd)x2 + (ce+bf)x + cf<br />
<br />
If you make this practice then multiplication be very easy for you.<br />
<br />
so using vedic trick multiplication is as shown below.<br />
<br />
<h2 style="text-align: left;">
1 2 3</h2>
<h2 style="text-align: left;">
<u>4 5 6</u></h2>
<div style="text-align: left;">
4 3 8 7 8</div>
<div>
<u> 1 2 2 1 </u></div>
<div>
5 6 0 8 8</div>
<div>
<br /></div>
<div>
You can do same method for any digit number for faster Multiplication.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
</div>
</div>
Jiten Aminhttp://www.blogger.com/profile/06500318083115629514noreply@blogger.com5tag:blogger.com,1999:blog-5447168480950396039.post-33014298900896766052015-04-26T10:18:00.001+05:302015-04-27T20:51:39.148+05:30Vedic Maths: Multiplication of two digit numbers<div dir="ltr" style="text-align: left;" trbidi="on">
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; text-align: right;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4vxfz0laLNOBVkJ6heW847vZzhTnUPMeUdC1hQ-8g5vLx0rVglNLVgIdwlC4QUe6s9lLPi6TIcczlNVsvX5Xh7cufmqnstzJZ-m1XlMptsBhvIGwNIBfW2p2T9diU_iElrAZHVmTGis0/s1600/DSC04567.JPG" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4vxfz0laLNOBVkJ6heW847vZzhTnUPMeUdC1hQ-8g5vLx0rVglNLVgIdwlC4QUe6s9lLPi6TIcczlNVsvX5Xh7cufmqnstzJZ-m1XlMptsBhvIGwNIBfW2p2T9diU_iElrAZHVmTGis0/s1600/DSC04567.JPG" height="218" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Learn vedic method of Multiplication of two digit number<br />
and win prize by giving answer till 27/04/2015 9:00 AM</td></tr>
</tbody></table>
Here i have explained you very easily how we can get multiplication of two digit numbers.<br />
<br />
Here i'm also having one skim for you.<br />
<br />
<b><u><i>All participant can comment your answer with vedic method and have chance to win prize.</i></u></b><br />
<br />
<b>You have time till 27/04/2015 9:00 AM. to answer this question</b>.<br />
<br />
One among all correct one will be chosen to have prize.</div>
Jiten Aminhttp://www.blogger.com/profile/06500318083115629514noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-80463803410568561842015-04-26T09:04:00.000+05:302015-04-27T20:51:51.278+05:30Power of Vedic Mathematics And Why to learn it.<div dir="ltr" style="text-align: left;" trbidi="on">
Vedic Maths is not different kind of maths then we have studied in schools. Then how it make difference and why people learn it?<br />
<br />
<b>The difference is vedic math include conclusions based on various sutras(Formula) from our vedas and Upnishdas.</b> That help us to detecting type of problem. And we do calculation based on the problem type. So we do not follow conventional boring method all time and do calculation based on the situation <b><i><u>that make our mind very instant to answer.</u></i></b><br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; text-align: right;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9W4sF1fcXtSWeYlDEzmeQobhBNeXK2950cCBqd51Q8Q3Y5gXCM__DzMjES6_8caf6q4GeRMM-5HoMR-zdC8dNXn5rf6jMxezbVNNtpZ8gOI3nNPr_-ljLi1YJ3ng3pLxdovQLMG3f3UE/s1600/vedic.jpg" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9W4sF1fcXtSWeYlDEzmeQobhBNeXK2950cCBqd51Q8Q3Y5gXCM__DzMjES6_8caf6q4GeRMM-5HoMR-zdC8dNXn5rf6jMxezbVNNtpZ8gOI3nNPr_-ljLi1YJ3ng3pLxdovQLMG3f3UE/s1600/vedic.jpg" height="235" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Sample of how use of Vedic Maths reduces Time and make <br />
maths Easy to learn for students</td></tr>
</tbody></table>
So the learner of Vedic Maths learn how to apply their knowledge in Maths as well as in other fields too.<br />
<br />
My sincere<b><u> thanks to Jagadguru Sankaracharya Sri Bhakti Krishna Tirthaji Maharaja of Govardhana Matha, Puri</u></b> for Writing 16 simple Mathematical formula based on Vedas.<br />
<br />
Vedic Maths is also popular as <b><i><u>High Speed maths or Mental maths</u></i></b> Because once you will practice it you can calculate various things by mentally.<br />
<br />
Here in this post i'm going to show you how easy Maths become for students using the various methods given in Vedic maths.<br />
<br />
At fist extent you might find it difficult but once you will practice it , it will become easy for you.Because it is totally different to use from conventional maths we are using.<br />
<br />
I'm lover of Math so i'm starting this online blogging for vedic maths free for all. So all can ask any doubt about maths , vedic maths.</div>
Jiten Aminhttp://www.blogger.com/profile/06500318083115629514noreply@blogger.com1tag:blogger.com,1999:blog-5447168480950396039.post-17527007039946053822015-04-25T00:14:00.002+05:302015-04-27T20:52:33.189+05:30Vedic Maths: Square a Number<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="font-size: x-large;">Square a number by the Deficiency Sutra Method</span></b><br />
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;">Sometimes we find it difficult to get square of a number by our routine methods. Here's how vedic mathematics can help us!</span></b><br />
<br />
Here are few easy steps to get through!<br />
<br />
1 : Find the base of given number. That is maybe, 10, 100, 1000, 10000, ...<br />
2 : Find the difference between base and a given number. That is a deficiency value.<br />
3 : Subtract the given number by deficiency and then multiply by base.<br />
4 : Square the deficiency value.<br />
5 : Add rule 3 result with the rule 4 result. And that's it!<br />
<br />
Example: 93 X 93 (Yaavadunam Sutra Method)<br />
<br />
1 : 93 base is 100<br />
2 : 100 - 93 = 7<br />
3 : (93 - 7) X 100 = 86 X 100 = 8600<br />
4 : 7 X 7 = 49<br />
5 : = 8600 + 49 = 8649<br />
<br />
93 X 93 = 8649</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-2717889863436800082015-04-23T01:06:00.003+05:302015-04-23T01:07:23.189+05:30Most common Passwords people use!<div dir="ltr" style="text-align: left;" trbidi="on">
Here is the list of most common passwords people use!<br />
Make sure you don't have anything from this to avoid being hacked by someone!<br />
<br />
<b>123456</b><br />
<b>password</b><br />
<b>12345678</b><br />
<b>qwerty</b><br />
<b>abc123</b><br />
<b>123456789</b><br />
<b>111111</b><br />
<b>1234567</b><br />
<b>iloveyou</b><br />
<b>adobe123</b><br />
<b><br /></b>
Password is the most important thing you should take care of if you have important data in your account. If not then enjoy using simple passwords :D</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-42741561239242094122015-02-13T15:49:00.001+05:302015-02-13T15:49:11.276+05:30Jayesh and Sweety Wedding Dance<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/ak4zchKtk68" width="480"></iframe>Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-20254856615330032392011-10-14T20:30:00.002+05:302015-04-27T20:52:57.736+05:30Shortest Path Algorithm: Dijkstra<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
<div class="MsoNoSpacing">
<b><u><span style="font-size: 14pt;">Aim :- To find
shortest path<o:p></o:p></span></u></b></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
#include <iostream.h></div>
<div class="MsoNoSpacing">
#include <conio.h></div>
<div class="MsoNoSpacing">
class graph</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
public:</div>
<div class="MsoNoSpacing">
char a;</div>
<div class="MsoNoSpacing">
char b;</div>
<div class="MsoNoSpacing">
int e;</div>
<div class="MsoNoSpacing">
};</div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
class dijkstra</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
public:</div>
<div class="MsoNoSpacing">
int n,p,t,f;</div>
<div class="MsoNoSpacing">
char c[10];</div>
<div class="MsoNoSpacing">
void get_data();</div>
<div class="MsoNoSpacing">
void
get_connection(graph g[]);</div>
<div class="MsoNoSpacing">
void shortest(graph
g[]);</div>
<div class="MsoNoSpacing">
void
display(graph g[]);</div>
<div class="MsoNoSpacing">
int minm(int
[],int,char []);</div>
<div class="MsoNoSpacing">
int findu(graph
g[],int,int,char []);</div>
<div class="MsoNoSpacing">
};</div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
void
dijkstra::get_data()</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
cout<<"Enter number of nodes in your network:";</div>
<div class="MsoNoSpacing">
cin>>n;</div>
<div class="MsoNoSpacing">
cout<<endl<<"Write the name of each node"<<endl;</div>
<div class="MsoNoSpacing">
for(int
i=0;i<n;i++)</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
cout<<"Name of node "<<i+1<<":";</div>
<div class="MsoNoSpacing">
cin>>c[i];</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
void
dijkstra::get_connection(graph g[])</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
clrscr();</div>
<div class="MsoNoSpacing">
cout<<endl<<endl<<"NOW ITS TIME TO CONNECT THE
NODES...!";</div>
<div class="MsoNoSpacing">
cout<<endl<<"Enter 1 if there is connection between
consicutive nodes otherwise enter 0"<<endl;</div>
<div class="MsoNoSpacing">
p=0;</div>
<div class="MsoNoSpacing">
for(int
i=0;i<n;i++)</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
for(int
j=i+1;j<n;j++)</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
cout<<c[i]<<"
& "<<c[j]<<" :";</div>
<div class="MsoNoSpacing">
int
t;</div>
<div class="MsoNoSpacing">
cin>>t;</div>
<div class="MsoNoSpacing">
if(t==1)</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
g[p].a=c[i];</div>
<div class="MsoNoSpacing">
g[p].b=c[j];</div>
<div class="MsoNoSpacing">
cout<<"Enter distance:";</div>
<div class="MsoNoSpacing">
cin>>g[p].e;</div>
<div class="MsoNoSpacing">
p++;</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
void
dijkstra::display(graph g[])</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
clrscr();</div>
<div class="MsoNoSpacing">
cout<<"YOUR NETWORK IS LIKE THIS:"<<endl;</div>
<div class="MsoNoSpacing">
for(int
i=0;i<p;i++)</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
cout<<g[i].a<<" &
"<<g[i].b<<" :"<<g[i].e<<endl;</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
void
dijkstra::shortest(graph g[])</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
char s,C[10];</div>
<div class="MsoNoSpacing">
int q,D[10];</div>
<div class="MsoNoSpacing">
cout<<endl<<endl<<"NOW ENTER NODE from which you
want to find shortest distance:";</div>
<div class="MsoNoSpacing">
cin>>s;</div>
<div class="MsoNoSpacing">
t=0;</div>
<div class="MsoNoSpacing">
f=0;</div>
<div class="MsoNoSpacing">
//function
to get distance & node array (Initialization)</div>
<div class="MsoNoSpacing">
for(int
r=0;r<n;r++)</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
if(s!=c[r])</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
C[f]=c[r];</div>
<div class="MsoNoSpacing">
for(int
i=0;i<p;i++)</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
if((g[i].a==s && g[i].b==C[f]) ||
(g[i].a==C[f] && g[i].b==s))</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
D[f]=g[i].e;</div>
<div class="MsoNoSpacing">
q=0;</div>
<div class="MsoNoSpacing">
break;</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
if(q!=0)</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
D[f]=32767;</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
f++;</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
} int w,u,v;</div>
<div class="MsoNoSpacing">
//greedy loop</div>
<div class="MsoNoSpacing">
for(q=0;q<n-2;q++)</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
v=minm(D,f,C);</div>
<div class="MsoNoSpacing">
for(w=0;w<f;w++)</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
if(C[w]!=NULL
&& C[w]!=C[v])</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
u=findu(g,w,v,C);</div>
<div class="MsoNoSpacing">
D[w]=(D[w]<(u+D[v])?D[w]:(u+D[v]));</div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
C[v]=NULL;</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
cout<<"The sortest distance from node
"<<s<<":";</div>
<div class="MsoNoSpacing">
for(int
z=0;z<f-1;z++)</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
cout<<D[z]<<",";</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
cout<<D[f-1];</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
int dijkstra::findu(graph
g[],int w,int v,char C[])</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
for(int
z=0;z<p;z++)</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
if((g[z].a==C[w]
&& g[z].b==C[v]) ||(g[z].a==C[v] && g[z].b==C[w]))</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
return
g[z].e;</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
return 32676;</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
int
dijkstra::minm(int j[],int t,char c[])</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
int o=32766,q;</div>
<div class="MsoNoSpacing">
for(int
i=0;i<t;i++)</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
if(o>j[i]
&& c[i]!=NULL)</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
o=j[i];</div>
<div class="MsoNoSpacing">
q=i;</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
return q;</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
void main ()</div>
<div class="MsoNoSpacing">
{</div>
<div class="MsoNoSpacing">
clrscr();</div>
<div class="MsoNoSpacing">
graph g[15];</div>
<div class="MsoNoSpacing">
dijkstra d;</div>
<div class="MsoNoSpacing">
d.get_data();</div>
<div class="MsoNoSpacing">
d.get_connection(g);</div>
<div class="MsoNoSpacing">
d.display(g);</div>
<div class="MsoNoSpacing">
d.shortest(g);</div>
<div class="MsoNoSpacing">
getch();</div>
<div class="MsoNoSpacing">
}</div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
Output:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-3mcC60iBg9Y/TphOVyUeEzI/AAAAAAAAAdI/IC-vZSLxmKQ/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-3mcC60iBg9Y/TphOVyUeEzI/AAAAAAAAAdI/IC-vZSLxmKQ/s400/1.png" height="81" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-oPt4zj7uOgA/TphOWT8QcjI/AAAAAAAAAdQ/tZf_5dO4wyg/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-oPt4zj7uOgA/TphOWT8QcjI/AAAAAAAAAdQ/tZf_5dO4wyg/s400/2.png" height="186" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-B-oo5zVhdnE/TphOWyvKbbI/AAAAAAAAAdY/iNJBPArwN4g/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-B-oo5zVhdnE/TphOWyvKbbI/AAAAAAAAAdY/iNJBPArwN4g/s400/3.png" height="158" width="400" /></a></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
</div>
<div class="MsoNoSpacing">
<o:p></o:p></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
</div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-83361144472599781762010-08-23T08:56:00.000+05:302015-04-27T20:53:09.354+05:30Decimal To Binary Converter<div dir="ltr" style="text-align: left;" trbidi="on">
//This Is The Program To Convert Decimal To Binary But Its Different From Other Ones!<br />
#include<stdio.h><br />
void printBinary(int n);<br />
void main()<br />
{<br />
int num;<br />
printf("Enter Decimal Number\n");<br />
scanf("%d",&num);<br />
printBinary(num);<br />
}<br />
void printBinary(int n)<br />
{<br />
if (n>0)<br />
{<br />
printBinary(n/2);<br />
printf("%c","01"[n%2]);<br />
}<br />
}</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com2tag:blogger.com,1999:blog-5447168480950396039.post-38501523663760921262010-03-18T22:05:00.005+05:302015-04-25T00:32:36.688+05:30Monoalphabatic cipher encryption and decryption<div dir="ltr" style="text-align: left;" trbidi="on">
//MONOALPHABETIC ENCRYPTION AND DECRYPTION<br />
//copyright jayeshaminnew@gmail.com<br />
<br />
//ENCRYPTION OF MONOALPHABAIC CIPHER<br />
#include<stdio.h><br />
#include<conio.h><br />
#include<string.h><br />
#include<iostream.h><br />
#include<ctype.h><br />
void main()<br />
{<br />
FILE *f1,*f2,*f3;<br />
int i,j=0,k,asc[50],l,temp,temp1,flag=0;<br />
char plain[50],cipher[50],key[50],m;<br />
clrscr();<br />
f1=fopen("plain.txt","r");<br />
while((l=getc(f1))!=EOF)<br />
{<br />
plain[j++]=l;<br />
}<br />
plain[j]=NULL;<br />
fclose(f1);<br />
j=0;<br />
f2=fopen("key.txt","r");<br />
while((l=getc(f1))!=EOF)<br />
{<br />
key[j++]=l;<br />
}<br />
key[j]=NULL;<br />
fclose(f2);<br />
cout<<"plain text is\n"<<plain;<br />
cout<<"key is \n"<<key;<br />
//logic<br />
k=0;<br />
for(i=0;i<strlen(plain);i++)<br />
{<br />
asc[k++]=plain[i]-97;<br />
}<br />
k=0;<br />
for(i=0;i<strlen(plain);i++)<br />
{<br />
if(asc[i]>=0 && asc[i]<=25)<br />
cipher[k++]=key[asc[i]];<br />
else<br />
cipher[k++]=plain[asc[i]+97];<br />
}<br />
cout<<"\n"<<"cipher text is\n";<br />
cipher[k]=NULL;<br />
cout<<cipher;<br />
<br />
f3=fopen("cipher.txt","w");<br />
for(i=0;i<strlen(cipher);i++)<br />
putc(cipher[i],f2);<br />
getch();<br />
}<br />
<br />
<br />
//DECRYPTION OF MONOALPHABATIC CIPHER<br />
<br />
#include<stdio.h><br />
#include<conio.h><br />
#include<string.h><br />
#include<iostream.h><br />
#include<ctype.h><br />
void main()<br />
{<br />
FILE *f1,*f2,*f3;<br />
int i,j=0,k,asc[50],l,temp,temp1,flag=0;<br />
char plain[50],cipher[50],key[50],m;<br />
clrscr();<br />
f1=fopen("cipher.txt","r");<br />
while((l=getc(f1))!=EOF)<br />
{<br />
cipher[j++]=l;<br />
}<br />
cipher[j]=NULL;<br />
fclose(f1);<br />
j=0;<br />
f2=fopen("key.txt","r");<br />
while((l=getc(f1))!=EOF)<br />
{<br />
key[j++]=l;<br />
}<br />
key[j]=NULL;<br />
fclose(f2);<br />
cout<<"cipher text is\n"<<cipher;<br />
cout<<"\nkey is \n"<<key;<br />
//logic<br />
k=0;<br />
for(i=0;i<strlen(cipher);i++)<br />
{<br />
for(j=0;j<strlen(key);j++)<br />
{<br />
if(cipher[i]==key[j])<br />
break;<br />
}<br />
plain[k++]=j+97;<br />
}<br />
cout<<"\n"<<"plain text is\n";<br />
plain[k]=NULL;<br />
cout<<plain;<br />
<br />
f3=fopen("plain.txt","w");<br />
for(i=0;i<strlen(plain);i++)<br />
putc(plain[i],f2);<br />
getch();<br />
}</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-664948520605519462010-03-18T22:04:00.002+05:302015-04-25T00:32:49.970+05:30Caesar cipher encryption and decryption<div dir="ltr" style="text-align: left;" trbidi="on">
//CAESAR CIPHER ENCRYPTION<br />
//copyright jayeshaminnew@gmail.com<br />
#include<stdio.h><br />
#include<conio.h><br />
#include<string.h><br />
#include<ctype.h><br />
void main()<br />
{<br />
//declaring variables<br />
FILE *f1,*f2;<br />
int i,j=0,k,l,key,temp,temp1,flag=0;<br />
char plain[50],cipher[50],m;<br />
clrscr();<br />
//reading plain text<br />
f1=fopen("plain.txt","r");<br />
while((l=getc(f1))!=EOF)<br />
plain[j++]=l;<br />
plain[j]=NULL;<br />
fclose(f1);<br />
printf("your plain text is:%s\n",plain);<br />
scanf("%d",&key,printf("enter key:"));<br />
for(i=0;i<j;i++)<br />
{<br />
temp=plain[i];<br />
temp1=temp;<br />
temp1+=key;<br />
if(temp1>122 && islower(temp))<br />
temp1-=26;<br />
else if(temp1>90 && isupper(temp))<br />
temp1-=26;<br />
else if(!((temp>=97 && temp<=122) || (temp>=65 && temp<=90)))<br />
{<br />
flag=1;<br />
}<br />
if(flag==0)<br />
cipher[i]=temp1;<br />
else<br />
cipher[i]=temp;<br />
flag=0;<br />
}<br />
cipher[i]=NULL;<br />
//writing cipher text into file<br />
f2=fopen("cipher.txt","w");<br />
for(i=0;i<strlen(cipher);i++)<br />
putc(cipher[i],f2);<br />
fclose(f2);<br />
printf("your cipher text is:%s",cipher);<br />
getch();<br />
}<br />
<br />
//CAESAR CIPHER DECRYPTION<br />
<br />
#include<stdio.h><br />
#include<conio.h><br />
#include<string.h><br />
#include<ctype.h><br />
#include<process.h><br />
void main()<br />
{<br />
FILE *f1,*f2;<br />
int i,j=0,k,l,key,temp,temp1,flag=0;<br />
char plain[50],cipher[50],meaning;<br />
clrscr();<br />
f1=fopen("cipher.txt","r");<br />
while((l=getc(f1))!=EOF)<br />
cipher[j++]=l;<br />
cipher[j]=NULL;<br />
fclose(f1);<br />
j=0;<br />
for(i=0;i<26;i++)<br />
{<br />
for(j=0;j<strlen(cipher);j++)<br />
{<br />
temp=cipher[j];<br />
temp1=temp;<br />
temp1-=i;<br />
if(temp1<97 && islower(temp))<br />
temp1+=26;<br />
else if(temp1<65 && isupper(temp))<br />
temp1+=26;<br />
else if(!((temp>=97 && temp<=122) || (temp>=65 && temp<=90)))<br />
{<br />
flag=1;<br />
}<br />
else<br />
{}<br />
if(flag==0)<br />
plain[j]=temp1;<br />
else<br />
plain[j]=temp;<br />
flag=0;<br />
}<br />
plain[j]=NULL;<br />
printf("Message:%s",plain);<br />
printf("\nis it meaning ful msg?? Y/N?\n");<br />
scanf("%s",&meaning);<br />
if(meaning=='y' || meaning=='Y')<br />
{<br />
printf("your plain text is: %s",plain);<br />
getch();<br />
exit(0);<br />
}<br />
}<br />
getch();<br />
}</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-48425413956237366252010-03-18T22:01:00.005+05:302015-04-25T00:33:00.685+05:30Polyalphabatic cipher encryption and decryption<div dir="ltr" style="text-align: left;" trbidi="on">
//POLYALPHABATIC CIPHER ENCRYPTION<br />
#include<stdio.h><br />
#include<conio.h><br />
#include<string.h><br />
void main()<br />
{<br />
int start=98,i,temp=97,j,k,m,n,l;<br />
char plain[100],key[100],cipher[100],arr[27][27],ch1,ch2;<br />
FILE *f1,*f2;<br />
clrscr();<br />
//code for matrix generation<br />
for(i=0;i<27;i++)<br />
{<br />
for(j=0;j<27;j++)<br />
{<br />
if(temp>122 )<br />
temp=32;<br />
arr[i][j]=temp++;<br />
if(temp==33)<br />
temp=97;<br />
}<br />
temp=start++;<br />
}<br />
//printing matrix<br />
for(i=0;i<27;i++)<br />
{<br />
for(j=0;j<27;j++)<br />
printf("%c",arr[i][j]);<br />
printf("\n");<br />
}<br />
i=0;<br />
f1=fopen("plain.txt","r");<br />
while((l=getc(f1))!=EOF)<br />
plain[i++]=l;<br />
plain[i]=NULL;<br />
fclose(f1);<br />
i=0;<br />
f1=fopen("key.txt","r");<br />
while((l=getc(f1))!=EOF)<br />
key[i++]=l;<br />
key[i]=NULL;<br />
fclose(f1);<br />
temp=0;<br />
printf("\nplain text: %s\n",plain);<br />
for(i=strlen(key);i<strlen(plain);i++)<br />
{<br />
if(temp>strlen(key))<br />
temp=0;<br />
key[i]=key[temp++];<br />
}<br />
key[i]=NULL;<br />
printf("key: %s\n",key);<br />
for(i=0;i<strlen(plain);i++)<br />
{<br />
if(plain[i]!=32)<br />
m=plain[i]-97;<br />
else<br />
m=26;<br />
n=key[i]-97;<br />
cipher[i]=arr[m][n];<br />
}<br />
cipher[i]=NULL;<br />
f1=fopen("cipher.txt","w");<br />
for(i=0;i<strlen(cipher);i++)<br />
putc(cipher[i],f1);<br />
fclose(f1);<br />
printf("cipher text:%s",cipher);<br />
getch();<br />
<br />
<div>
</div>
<br />
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
}</div>
<br />
//POLYALPHABATIC CIPHER DECRYPTION<br />
#include<stdio.h><br />
#include<conio.h><br />
#include<string.h><br />
void main()<br />
{<br />
int start=98,i,temp=97,j,k,m,n,l;<br />
char plain[100],key[100],cipher[100],arr[27][27],ch1,ch2;<br />
FILE *f1,*f2;<br />
clrscr();<br />
//code for matrix generation<br />
for(i=0;i<27;i++)<br />
{<br />
for(j=0;j<27;j++)<br />
{<br />
if(temp>122 )<br />
temp=32;<br />
arr[i][j]=temp++;<br />
if(temp==33)<br />
temp=97;<br />
}<br />
temp=start++;<br />
}<br />
//printing matrix<br />
for(i=0;i<27;i++)<br />
{<br />
for(j=0;j<27;j++)<br />
printf("%c",arr[i][j]);<br />
printf("\n");<br />
}<br />
i=0;<br />
f1=fopen("cipher.txt","r");<br />
while((l=getc(f1))!=EOF)<br />
cipher[i++]=l;<br />
cipher[i]=NULL;<br />
fclose(f1);<br />
i=0;<br />
f1=fopen("key.txt","r");<br />
while((l=getc(f1))!=EOF)<br />
key[i++]=l;<br />
key[i]=NULL;<br />
fclose(f1);<br />
temp=0;<br />
printf("\ncipher text:%s\n",cipher);<br />
for(i=strlen(key);i<strlen(cipher);i++)<br />
{<br />
if(temp>strlen(key))<br />
temp=0;<br />
key[i]=key[temp++];<br />
}<br />
key[i]=NULL;<br />
k=0;<br />
printf("key: %s\n",key);<br />
for(i=0;i<strlen(cipher);i++)<br />
{<br />
for(j=0;j<27;j++)<br />
{<br />
if(cipher[k]==arr[key[i]-97][j])<br />
break;<br />
}<br />
plain[k++]=arr[0][j];<br />
}<br />
plain[k]=NULL;<br />
f1=fopen("plain.txt","w");<br />
for(i=0;i<strlen(plain);i++)<br />
putc(plain[i],f1);<br />
fclose(f1);<br />
printf("plain text: %s\n",plain);<br />
getch();<br />
}<br />
<div>
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-55189373937265648672010-03-18T22:00:00.002+05:302015-04-25T00:42:39.102+05:30Bresenham's line drawing algorithm<div dir="ltr" style="text-align: left;" trbidi="on">
//This is Bresenham's line drawing algorithm developed in C language<br />
#include <graphics.h><br />
#include <stdlib.h><br />
#include <stdio.h><br />
#include <conio.h><br />
void jayubre(int,int,int,int);<br />
void main(void)<br />
{<br />
int gdriver = DETECT, gmode,x1,y1,x2,y2;<br />
initgraph(&gdriver, &gmode, "..\\bgi");<br />
printf("Enter starting points(x1,y1):\n"),scanf("%d%d",&x1,&y1);<br />
printf("Enter ending points(x2,y2):\n"),scanf("%d%d",&x2,&y2);<br />
jayubre(x1,y1,x2,y2);<br />
getch();<br />
}<br />
void jayubre(int x1,int y1,int x2,int y2)<br />
{<br />
int p0,dy,dx,sx=1,sy=1,xmax, ymax,x,y;<br />
float m;<br />
putpixel(x1,y1,8);<br />
putpixel(x2,y2,8);<br />
if(x1>x2)<br />
sx=-1;<br />
if(y1>y2)<br />
sy=-1;<br />
dx=abs(x2-x1);<br />
dy=abs(y2-y1);<br />
m=dy/dx;<br />
if(m<1)<br />
{<br />
p0=2*dy-dx;<br />
while(x1!=x2)<br />
{<br />
if(p0<0)<br />
{<br />
p0=p0+2*dy;<br />
x1=x1+sx;<br />
y1=y1;<br />
putpixel(x1,y1,4);<br />
}<br />
else if(p0>=0)<br />
{<br />
p0=p0+2*dy-2*dx;<br />
x1=x1+sx;<br />
y1=y1+sy;<br />
putpixel(x1,y1,4);<br />
<br />
}<br />
}<br />
}<br />
else<br />
{<br />
p0=2*dx-dy;<br />
while(y1!=y2)<br />
{<br />
if(p0<0)<br />
{<br />
p0=p0+2*dx;<br />
y1=y1+sy;<br />
x1=x1;<br />
putpixel(x1,y1,4);<br />
}<br />
else if(p0>=0)<br />
{<br />
p0=p0+2*dx-2*dy;<br />
y1=y1+sy;<br />
x1=x1+sx;<br />
putpixel(x1,y1,4);<br />
}<br />
}<br />
}<br />
}<br />
<div>
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-82495535262063245802010-03-18T21:57:00.003+05:302015-04-25T00:47:24.784+05:30Midpoint circle algorithm<div dir="ltr" style="text-align: left;" trbidi="on">
// This is Midpoint circle algorithm developed in C language<br />
<br />
#include <graphics.h><br />
#include <stdlib.h><br />
#include <stdio.h><br />
#include <conio.h><br />
void jayucircle(int xc,int yc,int r);<br />
void jayuprint(int x,int y,int xc,int yc);<br />
void main()<br />
{<br />
int xc,yc,p,r,x,y,gdriver = DETECT, gmode, errorcode;<br />
initgraph(&gdriver, &gmode, "..\\bgi");<br />
printf("enter value of (x,y,r)"),scanf("%d%d%d",&xc,&yc,&r);<br />
jayucircle(xc,yc,r);<br />
getch();<br />
}<br />
void jayucircle(int xc,int yc,int r)<br />
{<br />
int x=0,y=r,p=1-r;<br />
jayuprint(0,r,xc,yc);<br />
while(x<=y)<br />
{<br />
if(p<0)<br />
{<br />
x++;<br />
p+=(2*x)+1;<br />
jayuprint(x,y,xc,yc);<br />
}<br />
else<br />
{<br />
x++;<br />
y--;<br />
p+=(2*x)+1-(2*y);<br />
jayuprint(x,y,xc,yc);<br />
}<br />
}<br />
}<br />
void jayuprint(int x,int y,int xc,int yc)<br />
{<br />
putpixel(xc+x,yc+y,7);<br />
putpixel(xc-x,yc+y,7);<br />
putpixel(xc+x,yc-y,7);<br />
putpixel(xc-x,yc-y,7);<br />
putpixel(yc+y,xc+x,7);<br />
putpixel(yc-y,xc+x,7);<br />
putpixel(yc+y,xc-x,7);<br />
putpixel(yc-y,xc-x,7);<br />
}</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-18959039924094320832010-03-18T21:55:00.005+05:302015-04-25T00:49:13.900+05:302D Modeling: 2D Rotation<div dir="ltr" style="text-align: left;" trbidi="on">
// This is 2D Rotation program using C language<br />
<br />
#include<stdio.h><br />
#include<conio.h><br />
#include<graphics.h><br />
#include<math.h><br />
float ans[3][10];<br />
void multi(float tmat[3][3],float coormat[3][10],int size);<br />
void main()<br />
{<br />
float coormat[3][10],x[10],y[10],temp;<br />
int gd=DETECT,gm,no,sx,sy,sum=0,i,j,k,theta;<br />
float tmat[3][3]={{1,0,0},{0,1,0},{0,0,1}};<br />
clrscr();<br />
initgraph(&gd,&gm,"..\\bgi");<br />
printf("enter theta:"),scanf("%d",&theta);<br />
temp=(float)theta*3.14/180;<br />
tmat[0][0]=cos(temp);<br />
tmat[1][1]=cos(temp);<br />
tmat[0][1]=-1*sin(temp);<br />
tmat[1][0]=-1*sin(temp);<br />
printf("Translation matrix is:\n");<br />
for(i=0;i<3;i++)<br />
{<br />
for(j=0;j<3;j++)<br />
printf("%4.1f\t",tmat[i][j]);<br />
printf("\n");<br />
}<br />
printf("enter no. of vertices:\n"),scanf("%d",&no);<br />
for(i=0;i<no;i++)<br />
printf("enter (x%d,y%d):\n",i+1,i+1),scanf("%f%f",&x[i],&y[i]);<br />
for(i=0;i<no;i++)<br />
coormat[0][i]=x[i];<br />
for(i=0;i<no;i++)<br />
coormat[1][i]=y[i];<br />
for(i=0;i<no;i++)<br />
coormat[2][i]=1;<br />
printf("co ordinate matrix is:\n");<br />
for(i=0;i<3;i++)<br />
{<br />
for(j=0;j<no;j++)<br />
printf("%4.2f\t",coormat[i][j]);<br />
printf("\n");<br />
}<br />
//printing starting line<br />
for(j=0;j<no-1;j++)<br />
line(coormat[0][j],coormat[1][j],coormat[0][j+1],coormat[1][j+1]);<br />
line(coormat[0][0],coormat[1][0],coormat[0][j],coormat[1][j]);<br />
multi(tmat,coormat,no);<br />
printf("answer matrix is:\n");<br />
for(i=0;i<3;i++)<br />
{<br />
for(j=0;j<no;j++)<br />
printf("%4.2f\t",ans[i][j]);<br />
printf("\n");<br />
}<br />
<br />
for(j=0;j<no-1;j++)<br />
line(ans[0][j],ans[1][j],ans[0][j+1],ans[1][j+1]);<br />
line(ans[0][0],ans[1][0],ans[0][j],ans[1][j]);<br />
<br />
getch();<br />
}<br />
void multi(float tmat[3][3],float coormat[3][10],int no)<br />
{<br />
int i,j,k,sum=0;<br />
for(i=0;i<3;i++)<br />
{<br />
for(j=0;j<no;j++)<br />
{<br />
sum=0;<br />
for(k=0;k<3;k++)<br />
{<br />
sum+=tmat[i][k]*coormat[k][j];<br />
}<br />
ans[i][j]=sum;<br />
}<br />
}<br />
}</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-69473567502438249872010-03-18T21:55:00.002+05:302015-04-25T00:49:53.892+05:302D Modeling: 2D scaling<div dir="ltr" style="text-align: left;" trbidi="on">
#include<stdio.h><br />
#include<conio.h><br />
#include<graphics.h><br />
#include<math.h><br />
float ans[3][10];<br />
void multi(float tmat[3][3],float coormat[3][10],int size);<br />
void main()<br />
{<br />
float coormat[3][10],x[10],y[10];<br />
int gd=DETECT,gm,no,sx,sy,sum=0,i,j,k;<br />
float tmat[3][3]={{1,0,0},{0,1,0},{0,0,1}};<br />
clrscr();<br />
initgraph(&gd,&gm,"..\\bgi");<br />
printf("enter (sx,sy):"),scanf("%d%d",&sx,&sy);<br />
tmat[0][0]=sx;<br />
tmat[1][1]=sy;<br />
printf("Translation matrix is:\n");<br />
for(i=0;i<3;i++)<br />
{<br />
for(j=0;j<3;j++)<br />
printf("%4.1f\t",tmat[i][j]);<br />
printf("\n");<br />
}<br />
printf("enter no. of vertices:\n"),scanf("%d",&no);<br />
for(i=0;i<no;i++)<br />
printf("enter (x%d,y%d):\n",i+1,i+1),scanf("%f%f",&x[i],&y[i]);<br />
for(i=0;i<no;i++)<br />
coormat[0][i]=x[i];<br />
for(i=0;i<no;i++)<br />
coormat[1][i]=y[i];<br />
for(i=0;i<no;i++)<br />
coormat[2][i]=1;<br />
printf("co ordinate matrix is:\n");<br />
for(i=0;i<3;i++)<br />
{<br />
for(j=0;j<no;j++)<br />
printf("%4.2f\t",coormat[i][j]);<br />
printf("\n");<br />
}<br />
//printing starting line<br />
for(j=0;j<no-1;j++)<br />
line(coormat[0][j],coormat[1][j],coormat[0][j+1],coormat[1][j+1]);<br />
line(coormat[0][0],coormat[1][0],coormat[0][j],coormat[1][j]);<br />
multi(tmat,coormat,no);<br />
printf("answer matrix is:\n");<br />
for(i=0;i<3;i++)<br />
{<br />
for(j=0;j<no;j++)<br />
printf("%4.2f\t",ans[i][j]);<br />
printf("\n");<br />
}<br />
<br />
for(j=0;j<no-1;j++)<br />
line(ans[0][j],ans[1][j],ans[0][j+1],ans[1][j+1]);<br />
line(ans[0][0],ans[1][0],ans[0][j],ans[1][j]);<br />
<br />
getch();<br />
}<br />
void multi(float tmat[3][3],float coormat[3][10],int no)<br />
{<br />
int i,j,k,sum=0;<br />
for(i=0;i<3;i++)<br />
{<br />
for(j=0;j<no;j++)<br />
{<br />
sum=0;<br />
for(k=0;k<3;k++)<br />
{<br />
sum+=tmat[i][k]*coormat[k][j];<br />
}<br />
ans[i][j]=sum;<br />
}<br />
}<br />
}</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-4421638304215874102010-03-18T21:54:00.002+05:302015-04-25T00:50:15.341+05:302D Modeling: 2D transformation<div dir="ltr" style="text-align: left;" trbidi="on">
#include<stdio.h><br />
#include<conio.h><br />
#include<graphics.h><br />
#include<math.h><br />
float ans[3][10];<br />
void multi(float tmat[3][3],float coormat[3][10],int size);<br />
void main()<br />
{<br />
float coormat[3][10],x[10],y[10];<br />
int gd=DETECT,gm,no,tx,ty,sum=0,i,j,k;<br />
float tmat[3][3]={{1,0,0},{0,1,0},{0,0,1}};<br />
clrscr();<br />
initgraph(&gd,&gm,"..\\bgi");<br />
printf("enter (tx,ty):"),scanf("%d%d",&tx,&ty);<br />
tmat[0][2]=tx;<br />
tmat[1][2]=ty;<br />
printf("Translation matrix is:\n");<br />
for(i=0;i<3;i++)<br />
{<br />
for(j=0;j<3;j++)<br />
printf("%4.1f\t",tmat[i][j]);<br />
printf("\n");<br />
}<br />
printf("enter no. of vertices:\n"),scanf("%d",&no);<br />
for(i=0;i<no;i++)<br />
printf("enter (x%d,y%d):\n",i+1,i+1),scanf("%f%f",&x[i],&y[i]);<br />
for(i=0;i<no;i++)<br />
coormat[0][i]=x[i];<br />
for(i=0;i<no;i++)<br />
coormat[1][i]=y[i];<br />
for(i=0;i<no;i++)<br />
coormat[2][i]=1;<br />
printf("co ordinate matrix is:\n");<br />
for(i=0;i<3;i++)<br />
{<br />
for(j=0;j<no;j++)<br />
printf("%4.2f\t",coormat[i][j]);<br />
printf("\n");<br />
}<br />
//printing starting line<br />
for(j=0;j<no-1;j++)<br />
line(coormat[0][j],coormat[1][j],coormat[0][j+1],coormat[1][j+1]);<br />
line(coormat[0][0],coormat[1][0],coormat[0][j],coormat[1][j]);<br />
multi(tmat,coormat,no);<br />
printf("answer matrix is:\n");<br />
for(i=0;i<3;i++)<br />
{<br />
for(j=0;j<no;j++)<br />
printf("%4.2f\t",ans[i][j]);<br />
printf("\n");<br />
}<br />
<br />
for(j=0;j<no-1;j++)<br />
line(ans[0][j],ans[1][j],ans[0][j+1],ans[1][j+1]);<br />
line(ans[0][0],ans[1][0],ans[0][j],ans[1][j]);<br />
<br />
getch();<br />
}<br />
void multi(float tmat[3][3],float coormat[3][10],int no)<br />
{<br />
int i,j,k,sum=0;<br />
for(i=0;i<3;i++)<br />
{<br />
for(j=0;j<no;j++)<br />
{<br />
sum=0;<br />
for(k=0;k<3;k++)<br />
{<br />
sum+=tmat[i][k]*coormat[k][j];<br />
}<br />
ans[i][j]=sum;<br />
}<br />
}<br />
}</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-2218189481389359252010-03-18T21:37:00.002+05:302015-04-25T00:51:22.531+05:30Midpoint ellipse algorithm<div dir="ltr" style="text-align: left;" trbidi="on">
//This is Midpoint ellipse algorithm developed using C language<br />
<br />
#include <graphics.h><br />
#include <stdlib.h><br />
#include <stdio.h><br />
#include <conio.h><br />
#include<math.h><br />
void jayuellipse(int x,int y,int rx,int ry);<br />
void print(int,int,int,int);<br />
void main()<br />
{<br />
int xc,yc,p,r,rx,ry,gdriver = DETECT, gmode;<br />
initgraph(&gdriver, &gmode, "..\\bgi");<br />
printf("enter values of (x,y,xrad,yrad)"),scanf("%d%d%d%d",&xc,&yc,&rx,&ry);<br />
jayuellipse(xc,yc,rx,ry);<br />
getch();<br />
}<br />
void jayuellipse(int xc,int yc,int rx,int ry)<br />
{<br />
long int p,p2,x,y,dx,dy,ry2,rx2,rx2ry,hfrx2,_2ry2x,_2rx2y;<br />
float x5;<br />
//initialization of values<br />
x=0;<br />
y=ry;<br />
ry2=ry*ry;<br />
rx2=rx*rx;<br />
rx2ry=rx*rx*ry;<br />
hfrx2=.25*rx*rx;<br />
p=ry2-rx2ry+hfrx2;<br />
_2ry2x=2*ry*ry*x;<br />
_2rx2y=2*rx*rx*y;<br />
dx=_2ry2x;<br />
dy=_2rx2y;<br />
//calculation for region 1<br />
while(dx<dy)<br />
{<br />
print(x,y,xc,yc);<br />
if(p<0)<br />
{<br />
x++;<br />
dx+=2*ry2;<br />
p+=dx+ry2;<br />
}<br />
else if(p>=0)<br />
{<br />
x++;<br />
y--;<br />
dx+=2*ry2;<br />
dy-=2*rx2;<br />
p+=dx+ry2-dy;<br />
}<br />
}<br />
//end of region 1<br />
x5=x+.5;<br />
p2=(ry2*x5*x5)+(rx2*(y-1)*(y-1))-(rx2*ry2);<br />
//calculation for region 2<br />
while(y>=0)<br />
{<br />
print(x,y,xc,yc);<br />
if(p2>0)<br />
{<br />
y--;<br />
dx+=-(2*rx2);<br />
p2+=rx2-(dx);<br />
}<br />
else<br />
{<br />
x++;y--;<br />
dx+=-(2*rx2);<br />
dy+=2*ry2;<br />
p2+=rx2-(dx)+(dy);<br />
}<br />
}<br />
}<br />
void print(int x,int y,int xc,int yc)<br />
{<br />
putpixel(x+xc,y+yc,7);<br />
putpixel(x+xc,-y+yc,7);<br />
putpixel(-x+xc,y+yc,7);<br />
putpixel(-x+xc,-y+yc,7);<br />
}</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-41743344490539527292010-03-10T22:09:00.002+05:302015-04-25T00:38:12.733+05:30Playfair cipher encyption and decryption<div dir="ltr" style="text-align: left;" trbidi="on">
//PLAYFAIR CIPHER ENCRYPTION<br />
<br />
#include<stdio.h><br />
#include<conio.h><br />
#include<string.h><br />
void main()<br />
{<br />
FILE *fp;<br />
int i,m=0,flag=0,j,n,row1,row2,col1,col2;<br />
char ch,d,mat[5][5],key[10],k[10],c[30],a[10],ct[10],pt[10];<br />
clrscr();<br />
fp=fopen("key.txt","r");<br />
fscanf(fp,"%s",key);<br />
fclose(fp);<br />
printf("The key is: %s",key);<br />
//finding new key removing duplicates...<br />
for(i=0;i<strlen(key);)<br />
{<br />
if(key[i]=='j')<br />
key[i]=105;<br />
flag=0;<br />
for(j=0;j<i;j++)<br />
{<br />
if(key[i]==key[j])<br />
flag=1;<br />
}<br />
if(flag==1)<br />
i++;<br />
else<br />
k[m++]=key[i++]; //new array for key<br />
}<br />
k[m]=NULL;<br />
printf("\nThe new key is :\n%s",k);//printing new key<br />
//store key in matrix<br />
m=0;<br />
for(ch=97;ch<=122;)<br />
{<br />
flag=0;<br />
for(i=0;i<strlen(k);i++)<br />
{<br />
if(k[i]==ch)<br />
flag=1;<br />
}<br />
if(flag==1)<br />
ch++;<br />
else if(ch=='j')<br />
ch++;<br />
else<br />
{<br />
c[m++]=ch;<br />
ch++;<br />
}<br />
}<br />
c[m]=NULL;<br />
//construction of 2-D 5*5 matrix<br />
m=0;<br />
n=0;<br />
for(i=0;i<5;i++)<br />
{<br />
for(j=0;j<5;j++)<br />
{<br />
mat[i][j]=k[m++];<br />
if(m>strlen(k))<br />
mat[i][j]=c[n++];<br />
}<br />
}<br />
printf("\n");<br />
for(i=0;i<5;i++)<br />
{<br />
for(j=0;j<5;j++)<br />
printf("\t %c",mat[i][j]);<br />
printf("\n");<br />
}<br />
//retrieve plain-text from file<br />
i=0;<br />
fp=fopen("plain.txt","r");<br />
fscanf(fp,"%s",pt);<br />
fclose(fp);<br />
printf("\nThe plain-text is: %s",pt);<br />
//seperation of digram<br />
j=0;<br />
printf("\nAfter Processing Digrams: ");<br />
for(i=0;i<strlen(pt);)<br />
{ if(pt[i]==pt[i+1])<br />
{<br />
a[j++]=pt[i];<br />
a[j++]='x';<br />
i+=1;<br />
}<br />
else<br />
{<br />
a[j++]=pt[i];<br />
a[j++]=pt[i+1];<br />
i+=2;<br />
}<br />
}<br />
a[j]='\0';<br />
printf("%s",a);<br />
printf("\n");<br />
for(i=0;i<strlen(a);i+=2)//Loop for conversion to cipher text<br />
{<br />
for(j=0;j<5;j++)// matrix row<br />
{<br />
for(m=0;m<5;m++)//matrix column<br />
{<br />
//Find position of 1st element of Digram in matrix<br />
if(a[i]==mat[j][m])<br />
{<br />
row1=j;<br />
col1=m;<br />
}<br />
//Find position of 2nd element of Digram in matrix<br />
if(a[i+1]==mat[j][m])<br />
{<br />
row2=j;<br />
col2=m;<br />
}<br />
//Condition For both elements in same row of matrix<br />
if(row1==row2)<br />
{<br />
ct[i]=mat[row1][(col1+1)%5];<br />
ct[i+1]=mat[row1][(col2+1)%5];<br />
}<br />
//Condition For both elements in same column of matrix<br />
else if(col1==col2)<br />
{<br />
ct[i]=mat[(row1+1)%5][col1];<br />
ct[i+1]=mat[(row2+1)%5][col2];<br />
}<br />
else<br />
{<br />
ct[i]=mat[row1][col2];<br />
ct[i+1]=mat[row2][col1];<br />
}<br />
}<br />
}<br />
}<br />
ct[i]='\0';<br />
fp=fopen("cipher.txt","w");<br />
printf("\nCipher Text: ");<br />
//store cipher text in a file<br />
for(i=0;i<strlen(ct);i++)<br />
putc(ct[i],fp);<br />
fclose(fp);<br />
printf("%s",ct); //print cipher text<br />
getch();<br />
}<br />
<br />
<br />
//PLAYFAIR CIPHER DECRYPTION<br />
<br />
#include<stdio.h><br />
#include<conio.h><br />
#include<string.h><br />
void main()<br />
{<br />
FILE *fp;<br />
int i,m=0,flag=0,j,n,row1,row2,col1,col2;<br />
char ch,d,mat[5][5],key[10],k[10],c[30],a[10],ct[10],pt[10];<br />
clrscr();<br />
fp=fopen("key.txt","r");<br />
fscanf(fp,"%s",key);<br />
fclose(fp);<br />
printf("The key is: %s",key);<br />
for(i=0;i<strlen(key);)<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(key[i]=='j')<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>key[i]='i';<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>flag=0;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for(j=0;j<i;j++)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(key[i]==key[j])<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>flag=1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(flag==1)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>i++;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>k[m++]=key[i++]; //new array for key<br />
}<br />
k[m]=NULL;<br />
// printing new key after elimination of duplicates<br />
printf("\nThe new key is :\n%s",k);<br />
//seperation of key letters from a-z & later stored in an array<br />
m=0;<br />
for(ch=97;ch<=122;)<br />
{<br />
flag=0;<br />
for(i=0;i<strlen(k);i++)<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(k[i]==ch)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>flag=1;<br />
}<br />
if(flag==1)<br />
ch++;<br />
else if(ch=='j')<br />
ch++;<br />
else<br />
{<br />
c[m++]=ch;<br />
ch++;<br />
}<br />
}<br />
c[m]=NULL;<br />
//construction of 2-D 5*5 matrix<br />
m=0;<br />
n=0;<br />
for(i=0;i<5;i++)<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for(j=0;j<5;j++)<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>mat[i][j]=k[m++];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(m>strlen(k))<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>mat[i][j]=c[n++];<br />
}<br />
}<br />
printf("\n");<br />
for(i=0;i<5;i++)<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for(j=0;j<5;j++)<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("\t %c",mat[i][j]);<br />
}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("\n");<br />
}<br />
<br />
//retrieve cipher-text from file<br />
<br />
i=0;<br />
fp=fopen("cipher.txt","r");<br />
fscanf(fp,"%s",ct);<br />
fclose(fp);<br />
printf("\nThe Cipher-text is: %s",ct);<br />
<br />
<br />
<br />
printf("\n");<br />
for(i=0;i<strlen(ct);i+=2)//conversion to plain text<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for(j=0;j<5;j++) //matrix row<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for(m=0;m<5;m++)//matrix column<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>//Find position of 1st element of Digram in matrix<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(ct[i]==mat[j][m])<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>row1=j;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>col1=m;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>//Find position of 2nd element of Digram in matrix<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(ct[i+1]==mat[j][m])<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>row2=j;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>col2=m;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>//Condition For both elements in same row of matrix<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(row1==row2)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>pt[i]=mat[row1][(col1-1+5)%5];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>pt[i+1]=mat[row1][(col2-1+5)%5];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>//Condition For both elements in same column of matrix<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else if(col1==col2)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>pt[i]=mat[(row1-1+5)%5][col1];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>pt[i+1]=mat[(row2-1+5)%5][col2];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>pt[i]=mat[row1][col2];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>pt[i+1]=mat[row2][col1];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
}<br />
pt[i]='\0';<br />
fp=fopen("plain.txt","w");<br />
printf("\nPlain Text: ");<br />
//store plain text in a file<br />
for(i=0;i<strlen(pt);i++)<br />
putc(pt[i],fp);<br />
fclose(fp);<br />
printf("%s",pt); //print plain text<br />
fclose(fp);<br />
getch();<br />
}</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-19742457482779315962010-03-10T21:30:00.004+05:302015-04-25T00:53:25.148+05:30Synchronous TDM and Asynchronous TDM<div dir="ltr" style="text-align: left;" trbidi="on">
// This is Synchronous TDM developed using C<br />
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">#include<stdio.h></span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">#include<string.h></span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">int main()</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">{</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">int i,j,k=0,l,maxlength=0,length[3],flag1=0,flag2=0,flag3=0;</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">char usr1[10],usr2[10],usr3[10],newusr1[10],newusr2[10],newusr3[10],b[100];</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">printf("enter data for user 1\n");</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">gets(usr1);</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">printf("enter data for user 2\n");</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">gets(usr2);</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">printf("enter data for user 3\n");</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">gets(usr3);</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">length[0]=strlen(usr1);</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">length[1]=strlen(usr2);</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">length[2]=strlen(usr3);</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">for(j=0;j<3;j++)</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">{</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">if(maxlength<length[j])</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">maxlength=length[j];</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">}</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">for(i=0;i<maxlength;i++)</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">{</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">if(usr1[i]!=NULL && flag1==0)</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">b[k++]=usr1[i];</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">else</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">{</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">b[k++]='$';</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">flag1=1;</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">}</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">if(usr2[i]!=NULL && flag2==0)</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">b[k++]=usr2[i];</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">else</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">{</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">b[k++]='$';</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">flag2=1;</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">}</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">if(usr3[i]!=NULL && flag3==0)</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">b[k++]=usr3[i];</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">else</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">{</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">b[k++]='$';</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">flag3=1;</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">}</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">}</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">b[k]=NULL;</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">k=0;</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">for(i=1;i<=maxlength;i++)</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">{</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">printf("\nframe %d is ",i);</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">for(j=0;j<3;j++)</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">printf("%c",b[k++]);</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">}</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">strcpy(newusr1,usr3);</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">strcpy(newusr2,usr1);</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">strcpy(newusr3,usr2);</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">printf("\nTransferring Data To Respective Users...\n\n");</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">printf("user1 gets %s \n",newusr1);</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">printf("user2 gets %s \n",newusr2);</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">printf("user3 gets %s \n",newusr3);</span></span></div>
<div>
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">return 0;</span></span></div>
<br />
<div>
</div>
<br />
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
<div style="margin: 0px;">
<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;">}</span></span></div>
</div>
<br />
<br />
//This is Asynchronous TDM developed using C<br />
<br />
#include<stdio.h><br />
#include<ctype.h><br />
#include<string.h><br />
int main()<br />
{<br />
int i,j,k=0,l,frame,maxlength=0,length_t=0,length[3],flag1=0,flag2=0,flag3=0;<br />
char usr1[10],usr2[10],usr3[10],newusr1[10],newusr2[10],newusr3[10],b[100];<br />
printf("enter data for user 1\n");<br />
gets(usr1);<br />
printf("enter data for user 2\n");<br />
gets(usr2);<br />
printf("enter data for user 3\n");<br />
gets(usr3);<br />
length[0]=strlen(usr1);<br />
length[1]=strlen(usr2);<br />
length[2]=strlen(usr3);<br />
for(j=0;j<3;j++)<br />
{<br />
length_t+=length[j];<br />
if(maxlength<length[j])<br />
maxlength=length[j];<br />
}<br />
<br />
if(length_t%2==0)<br />
frame=length_t/2;<br />
else<br />
frame=(length_t/2)+1;<br />
printf("\ntotal frames are %d\n",frame);<br />
<br />
for(i=0;i<maxlength;i++)<br />
{<br />
if(isalpha(usr1[i]))<br />
b[k++]=usr1[i];<br />
if(isalpha(usr2[i]))<br />
b[k++]=usr2[i];<br />
if(isalpha(usr3[i]))<br />
b[k++]=usr3[i];<br />
}<br />
b[k]=NULL;<br />
k=0;<br />
for(i=1;i<=frame;i++)<br />
{<br />
printf("\nframe %d is ",i);<br />
for(j=0;j<2;j++)<br />
printf("%c",b[k++]);<br />
}<br />
k=0;<br />
for(i=0;i<frame;i++)<br />
{<br />
if(i<strlen(usr1))<br />
newusr2[i]=b[k++];<br />
if(i<strlen(usr2))<br />
newusr3[i]=b[k++];<br />
if(i<strlen(usr3))<br />
newusr1[i]=b[k++];<br />
}<br />
newusr1[strlen(usr3)]=NULL;<br />
newusr2[strlen(usr1)]=NULL;<br />
newusr3[strlen(usr2)]=NULL;<br />
printf("\nTransferring Data To Respective Users...\n\n");<br />
printf("user1 gets %s \n",newusr1);<br />
printf("user2 gets %s \n",newusr2);<br />
printf("user3 gets %s \n",newusr3);<br />
return 0;<br />
}<br />
<div>
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-29045157460230928352010-02-20T21:44:00.001+05:302015-04-25T01:26:02.873+05:30Polygon Drawing<div dir="ltr" style="text-align: left;" trbidi="on">
//This program is to draw polygon using C<br />
<br />
#include <graphics.h><br />
#include <stdlib.h><br />
#include <stdio.h><br />
#include <conio.h><br />
#include<iostream.h><br />
#include<math.h><br />
void line(float x1,float y1,float x2,float y2);<br />
void main()<br />
{<br />
int gdriver = DETECT, gmode,i,no;<br />
float x[100],y[100];<br />
initgraph(&gdriver, &gmode, "..\\bgi");<br />
cout<<"how many sides you want";<br />
cin>>no;<br />
for(i=0;i<no;i++)<br />
{<br />
cout<<"enter x"<<i+1;<br />
cin>>x[i];<br />
cout<<"enter y"<<i+1;<br />
cin>>y[i];<br />
}<br />
x[no]=x[0];<br />
y[no]=y[0];<br />
for(i=0;i<no;i++)<br />
{<br />
line(x[i],y[i],x[i+1],y[i+1]);<br />
}<br />
getch();<br />
}<br />
void line(float x1,float y1,float x2,float y2)<br />
{<br />
int i;<br />
float sign,dx,dy;<br />
if(abs(x2-x1)>abs(y2-y1))<br />
sign=abs(x2-x1);<br />
else<br />
sign=abs(y2-y1);<br />
dx=x2-x1;<br />
dy=y2-y1;<br />
for(i=0;i<=sign;i++)<br />
{<br />
putpixel(x1,y1,15);<br />
x1+=dx/sign;<br />
y1+=dy/sign;<br />
}<br />
}<br />
<div>
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-45779178548272559182010-02-20T21:29:00.001+05:302015-04-25T01:30:01.757+05:30DDA Line drawing algorithm <div dir="ltr" style="text-align: left;" trbidi="on">
// This is Digital differential analyzer(DDA) line drawing algorithm using C<br />
<br />
#include <graphics.h><br />
#include <stdlib.h><br />
#include <stdio.h><br />
#include <conio.h><br />
#include<math.h><br />
void jayudda(float,float,float,float);<br />
void main()<br />
{<br />
int gdriver = DETECT, gmode;<br />
float x1,y1,x2,y2;<br />
initgraph(&gdriver, &gmode, "..\\bgi");<br />
printf("enter starting points(x1,y1):"),scanf("%f%f",&x1,&y1);<br />
printf("enter ending points(x2,y2):"),scanf("%f%f",&x2,&y2);<br />
jayudda(x1,y1,x2,y2);<br />
getch();<br />
}<br />
void jayudda(float x1,float y1,float x2,float y2)<br />
{<br />
int i;<br />
float sign;<br />
if(abs(x2-x1)>abs(y2-y1))<br />
sign=abs(x2-x1);<br />
else<br />
sign=abs(y2-y1);<br />
for(i=0;i<=sign;i++)<br />
{<br />
putpixel(x1,y1,7);<br />
x1+=(x2-x1)/sign;<br />
y1+=(y2-y1)/sign;<br />
}<br />
}</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-41936958450337407422009-10-09T22:08:00.000+05:302015-04-25T01:31:31.143+05:30Operator precedence parsing algorithm<div dir="ltr" style="text-align: left;" trbidi="on">
<link href="file:///C:%5CDOCUME%7E1%5Cjayu%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml" rel="File-List"></link><link href="file:///C:%5CDOCUME%7E1%5Cjayu%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx" rel="themeData"></link><link href="file:///C:%5CDOCUME%7E1%5Cjayu%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml" rel="colorSchemeMapping"></link>
<m:smallfrac m:val="off">
<m:dispdef>
<m:lmargin m:val="0">
<m:rmargin m:val="0">
<m:defjc m:val="centerGroup">
<m:wrapindent m:val="1440">
<m:intlim m:val="subSup">
<m:narylim m:val="undOvr">
</m:narylim></m:intlim>
</m:wrapindent><style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1107304683 0 0 159 0;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1073750139 0 0 159 0;}
@font-face
{font-family:"Comic Sans MS";
panose-1:3 15 7 2 3 3 2 2 2 4;
mso-font-charset:0;
mso-generic-font-family:script;
mso-font-pitch:variable;
mso-font-signature:647 0 0 0 159 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-parent:"";
margin-top:0in;
margin-right:0in;
margin-bottom:10.0pt;
margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-font-family:Calibri;
mso-bidi-font-family:"Times New Roman";}
.MsoChpDefault
{mso-style-type:export-only;
mso-default-props:yes;
font-size:10.0pt;
mso-ansi-font-size:10.0pt;
mso-bidi-font-size:10.0pt;
mso-ascii-font-family:Calibri;
mso-fareast-font-family:Calibri;
mso-hansi-font-family:Calibri;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
</m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac><br />
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">//This is </span><span style="font-family: Comic Sans MS;"><span style="font-size: 13.3333330154419px; line-height: 15.3333320617676px;">operator precedence parsing algorithm using C</span></span><br />
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">char
pre[10][10],ss[30],rs[30],stk[10][2];<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">int i,j,k,n,p,sp=0,br=0;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">void push();<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">void pop();<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">char chk_pre();<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">void reduce_ss();<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">void main()<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">clrscr();<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">strcpy(pre[0],"
+*()]");<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">strcpy(pre[1],"+><<>>");<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">strcpy(pre[2],"*>><>>");<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">strcpy(pre[3],"(<<<=e");<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">strcpy(pre[4],")>>e>>");<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">strcpy(pre[5],"[<<<e=");<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">n=6;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">scanf ("%s",ss,
printf("Enter the source string : "));<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">strcpy(rs,"[");<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">strcat(rs,ss);<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">strcat(rs,"]");<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">strcpy(ss,rs);<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">printf("\n");<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">for(i=0;i<n;i++)<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">for(j=0;j<strlen(pre[i]);j++)<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">printf("%c\t",pre[i][j]);<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">printf("\n");}<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">while(ss[2]!=']' &&
br==0)<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">sp=0;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">for(i=0;i<strlen(ss);i++)<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">if( (ss[i]>='a' &&
ss[i]<='z') || (ss[i]>='A' && ss[i]<='Z') )<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">continue;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">push();<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">if(stk[sp-1][1]=='e' ||
ss[1]==']' || ss[0]==']')<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">{ printf("\n\nInvalid
string.");<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">br=1;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">break; }<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">if((stk[sp-1][1]=='>'
&& stk[sp-2][1]=='<') || stk[sp-1][1]=='=')<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">{ reduce_ss();<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">pop(); } } }<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">if(ss[2]==']')<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">printf("\nValid
String.");<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">getch();<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">void push()<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">{ stk[sp][0]=ss[i];<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">stk[sp][1]=chk_pre();<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">sp++; }<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">void pop()<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">{ char tmp,tmp1;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">sp--;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">tmp=stk[sp][0];<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">tmp1=stk[sp][1];<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">sp--;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">stk[sp][0]=tmp;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">stk[sp][1]=tmp1;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">sp++; }<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">char chk_pre()<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">{ char tmp;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">if(i==0)<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">tmp=' ';<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">else<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">{ for(j=0;j<n;j++)<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">for(k=0;k<strlen(pre[j]);k++)<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">if(stk[sp-1][0]==pre[j][0]
&& stk[sp][0]==pre[0][k])<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">tmp=(pre[j][k]); }<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">return tmp; }<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">void reduce_ss()<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">{
char t1[30],t3[30];<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">int tmp;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">if(stk[sp-1][0]==')' &&
stk[sp-2][0]=='(')<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">tmp=i-2;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">else<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">tmp=i-3;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">for(j=0;j<tmp;j++)<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">{
t1[j]=ss[j]; }<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">t1[j]='\0';<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">tmp=tmp+3;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">k=0;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">for(j=tmp;j<strlen(ss);j++)<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">{
t3[k]=ss[j];<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">k++; }<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">t3[k]='\0';<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">strcpy(ss,"");<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">strcpy(ss,t1);<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">strcat(ss,"i");<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">strcat(ss,t3);<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: "Comic Sans MS"; font-size: 10pt; line-height: 115%;">}<o:p></o:p></span></div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com0tag:blogger.com,1999:blog-5447168480950396039.post-71418019907693990062009-09-17T18:46:00.000+05:302015-04-25T01:33:46.332+05:30Database connection in classic ASP<div dir="ltr" style="text-align: left;" trbidi="on">
Dim con<br />
Dim rs<br />
Dim ConnectString<br />
dim accessdb<br />
set con=server.CreateObject("ADODB.Connection")<br />
set rs=server.CreateObject("ADODB.RecordSet")<br />
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\database.mdb"<br />
con.open ConnectString<br />
accessdb="database.mdb"<br />
mysql="select * from table"<br />
<span style="font-size: small;"></span><br />
rs.open mysql, con, 3, 3</div>
Anonymoushttp://www.blogger.com/profile/09318593936474353428noreply@blogger.com2