Showing posts with label source code. Show all posts
Showing posts with label source code. Show all posts

Tuesday, March 31, 2009

Communication & its Process

Communication:
    “Communication is the process in which the message moves from source to the destination”

Process of Communication:
 Process of communication consists of following factors;
1) Source
2) Encoding
3) Message 
4) Channel
        Channel has further following types;
         1) Time consuming (Radio)
         2) Space covering (Printed martial)
         3) Combination of time consuming
              and space covering (TV & Internet)
5) Receiver
6) Decoding
7) Feedback

All these factors are defined as below;
Source:
 A person who speaks or writes is called source. It may be individual or group of people.

Encoding:
 The sender giving physical form to one’s idea is known as encoding.

Message:
 The encoded idea of the sender is called message. It transmits from source to destination.

Channel:
 It’s a medium which carries the message from the source to the receiver. There are three types of channels
                      Time consuming = Radio
                      Space covering = Printed Material
                      Both = TV & Internet

Receiver:
 The recipient of the message is called receiver.

Decoding:
 Decoding is the process of understanding the meaning of the message.

Feedback:
 The response of the receiver is called feedback. It completes the process of communication.

Download doc File HERE



Wednesday, March 18, 2009

100 Sample C Programs!!!

1. Program to print text
2. Program To Read Two Numbers And Print The Sum Of Given Two Numbers.
3. Program To Accept Student Roll No, Marks in 3 Subjects and Calculate Total, Average and Print it.
4.Program To Read Three Numbers And Print The Biggest Of Given Three Numbers
5.Program To Read A Number And Find Whether The Given Number Is Even Or Odd.
6.Program to accept a year and check whether the given year IS leap year or not.
7.Individual Digits
8. Program to accept a three digit number and print the sum of individual digits.
9. Program to accept a number and check the given number is Armstrong or not.
10. Program to print ODD numbers from 1 to 10
11. Program to print natural numbers from 1 to 10 in Reverse
12. Program to print sum of the natural numbers from 1 to 10.
13. Program to accept a number and print mathematical table of the given no.
14. Program to print 1 to 10 mathematical tables .
15. Program to print fibonacci series .
16. Program to print numeric pyramid
17. Program to print numerical pyramid.
18. Program to print numerical diamond.
19. Program to print character pyramid.
20. Program to print character diamond.
21. Program to find biggest of two no by using ternary numbers
22. Program to find biggest of four no by using ternary numbers
23. Program to print smallest of four no by using ternary operators
24. Program to accept a year and check the given year is leap or not by using ternary
25. Program to accept a character in the uppercase and print in lower case.
26. Program to accept a character in any case and print in another case.
27. Program to natural number from 1 to 10 by using while loop.
28. Program to accept a string and print it by using the while loop.
29. Program to accept a string in upper case and print it by lower case.
30. Program to accept a string in any case and print
it by another case .
31. Program to accept a string print each word in new line.
32. Program to accept a string and count no of capital letters, no. of small letters and no. of special characters
33. Program to accept any single digit number and print it in words .
34. Program to print prime numbers between 1 to 100
35. Program to accept two numbers and print sum of two numbers by using functions
36. Program to accept a number and find factorial of given number
37. Program to accept a number and check the given number Armstrong or not
38. Program to accept a number and print the sum of given and Reverse number
39. Program to accept 10 numbers and print first five numbers in original order and print last five numbers in reverse order.
40. Program to accept a string and print the reverse of the given string by using for loop.
41. Program to accept a string and check the given string is palindrome or not .
42.Program to accept values into 3 dimensional array and print .
43. Program to print upper triangle .
44. Program to accept two 3 dimensional array and store addition of those into arrays into the third array .
45. Program to accept a string and find the length of the given string by using functions
46. Program to count the number of words, characters, alphabets, vowels, consonants and digit in a line of text.
47. Program to accept two string and compare the strings are equal or not
48. Program to sort the entered numbers using bubble sort.
49. Program to read date,month, year and print the next day’s date,month,year.
50. Program to interchange two values using pointers.
51. Program to print “PASCAL TRIANGLE”.
52. Program to check whether a given number is perfect or not.
53. Program to check whether a given number is prime number.
54. Program to read ‘n’ number and print them in matrix terms in all orders.
55. Program to search an element using binary search
56. Program to accept two numbers and print the sum of given two numbers by using pointers
57. Programs to multiply two Matrices
58. Program to print prime number between 1-100
59. Program to accept a string and find the length of the string
60. Program to fibanocci of matrix
61. Program a structure which reads ‘n’ students information (name,3 subjects marks) and calculate total marks, result print them in a particular format.
62. Program to find whether a square matrix is a) symmetric b) skew symmetric c) none of two.
63. Program to find area of a triangle when there sides are given.
64. Program to print Armstrong number between 1-500.
65. Program to check whether a given number is Armstrong or not.
66. Program to print the floyd’s triangle.
67. Program to read data in 3 structures and print
68. Program to print a diagonal matrix.
69. Program to copy contents of one file into another.
70. Program to create a file of number and copy odd number into second file and even number into third file.
71. Program a structure which stores information about hotels which stores information about name, grade, room change, no of rooms.
72. Program which does the below process after reading on odd no of integer.
73. Program to sort the entered elements using selection sort technique.
74. Program to find whether a number is divisible by ‘11’ or not without actual division.
75. Program to find maximum and minimum of entered ’n’ number using arrays.
76. Program to print the following series until there sum exceeds 2.6 term value exceeds 1.5x+x2/2!+x3/3!+------------.
77. Program to print a frequency distribution table for a class of 20-students in the following format. The marks range form 1-25.
78. Program to accept values into an array and print array in reverse and original format by using three different functions.
79. Program to accept values into single dimensional array and print the array in reverse by using pointers.
80. Program to read a string and print the number of characters in each word of the string.
81. Program to accept two strings and compare those two strings
82. Program to accept a string using pointers and functions.
83.Program to read a string and print the first two characters of each word in the string.
84.Program to accept two numbers and print the sum of given two numbers by using pointers
85.Program to accept a string and print reverse of the given string by using functions.
86. Program to accept two 3 dimensional array and store subtraction of those two arrays into third array..
87.Program to accept a single dimensional array and print them by using pointers
88.Program to accept two strings and biggest among them
89.Program to print 4 dimentional matrix with
constant number.
90.Prongram to accept a string and print each word in reverse
91. Program to accept elements into single dimensional array and print the array in ascending order by using three different arrays.
92.Program to accept data and store the given data into file print the data.
93. Program to accept data in lower case and store the given data into file into upper case and print the data.
94.Program to copy contents of one file into another.
95. Program to create a file of numbers and copy odd number into second file and even number into third file
96.Program to accept a string in lower case and print first character of each word in upper case.
97.Program to accept two numbers and interchange two values using functions.
98.Program for example of static variable.
99.Program to accept a string and print by trailing spaces.
100. Program to print anti diagonal.

Download HERE in PDF Format              More Program codes coming Soon!

Monday, March 9, 2009

int main() And void main() - Differeance!

We’ve been brought up with many different variations of this popular function. Some books/teachers like to write it as “int main”, some write it as “void main” and then there are some who make do with just “main”, forgoing the return type altogether. So, which one out of them is correct? Or does it even make a difference?

The answer to the 2nd question is “YES”. It makes a whole world of difference as in it could:
» do nothing
» or give you a compile time warning
» or crash the program
» or cause problems in your invocation environment

Now, we go back to the first question. Which is the correct form and why?
The answer is “int main” is the correct type for C++.
But for C, it is a bit tricky and I’d say “int main” is the recommended way.
The simple reasoning is “because the C and C++ standards say so”. (See this however, which is what is leads to a bit of confusion though and makes it implementation dependent in c)

But lets take a brief look at the practical reasons for this because you might wonder “My compiler doesn’t give me a warning for void main, so why should I care?” (If your compiler does that, then its time to switch to something else. Did I hear you are using a Microsoft compiler? ).

There is something called “startup code” (more on this soon) which is what runs first when you start your program, sets things up (e.g. initializes stack, heap, .bss etc) and then calls “main”. Now, generally this start up code expects main to return an integer value and place it onto stack. Now, if we don’t return anything (in void main’s case), it will still take something in its place, which you don’t have any control of. e.g. If this startup code expects the value to be in a certain range, it will crash if it sees something out of it. Or imagine if the caller function pops off an int from the stack but our main never put anything into it, it would screw up the stack for good. (Ever saw segfaults on a program that runs fine but crashes while exiting)

Moreover, if you are running a script that makes its basis upon such a program, a garbage value will be returned to it leading to unknown consequences.

End Note: Some would say that leaving out the type altogether and just writing “main” should be the way to go because the return type of such functions is automatically assumed to be int by the compiler. However, this is not correct because the standard does not define an intended behaviour for this and this is totally compiler dependent and hence it is not reliable.

Please post your comments about this article or if there is something that I missed out on. Also let us know if there is something in particular that you’d want us to talk about.

© Safer Code

Blog Widget by LinkWithin