Introduction of Computer In this chapter you will learn about: • Computer • Data processing • Characteristic features of computers • Computers' evolution to their present form Computer • The word computer comes from the word "compute", which means, "to calculate" • Thereby, a computer is an electronic device that can perform arithmetic operations at high speed • A computer is also called a data processor because it can store, process, and retrieve data whenever desired Data Processing The activity of processing data using a computer is called data processing Data is raw material used as input to data processing and information is processed data obtained as output Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Characteristics of Computers 1. Automatic : it carries out a job normally without any human intervention. 2. Speed : it can perform several billion (10 ^9) simple arithmetic operations per second . 3. Accuracy : it performs every cal...
// Bubble Sort #include <stdio.h> int main() { int array[50], n. i, j, swap; printf("Enter number of elements\n"); scanf("%d", &n); printf("Enter %d integers\n", n); for (i=0; i < n; i++) scanf("%d", &array[i]); for (i=0; i< (n - 1); i++) { for (1 = 0: jn1-1; j++) { if (array[j]> array[j+1]) /* For decreasing order use < */ swap = array[j]; array[j] = array(j + 1]; array[j+1]= swap; } printf("Sorted list in ascending order: \n"); for (i=0; i < n; i++) printf("%d\n", array[i]); return 0; } Output: Enter number of elements 5 Enter 5 integers 20 90 0 -23 78 Sorted list in ascending order: -23 0 20 78 90
C Constants and Literals T he constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are also enumeration constants as well. The constants are treated just like regular variables except that their values cannot be modified after their definition. Integer literals An integer literal can be a decimal, octal, or hexadecimal constant. A prefix specifies the base or radix: 0x or OX for hexadecimal, 0 for octal, and nothing for decimal. An integer literal can also have a suffix that is a combination of U and L, for unsigned and long, respectively. The suffix can be uppercase or lowercase and can be in any order. Here are some examples of integer literals : Floating-point literals A floating-point literal has an integer part, a decimal point, a fraction...
Comments
Post a Comment