Posts

Showing posts from September, 2018

TOP CRICKETER HOUSE PRICE

Image
TOP CRICKETERS HOUSE IN THE WORLD RICKY POINTING 69.8 CRORE SHANE WATSON  62.8 CRORE YUVRAJ SINGH 60 CRORE MICHEAL CLARKE 59.3 CRORE DAVID WARNER 45.3 CRORE SHANE WARNE 38.4 CRORE SACHIN TENDULKAR 38 CRORE VIRAT KOHLI HOUSE 34 CRORE ROHIT SHARMA 30CR BRETT LEE HOUSE  27.9 CRORE
C Program to Check Whether a Number is Prime or Not Example to check whether an integer (entered by the user) is a prime number or not using for loop and if...else statement. To understand this example, you should have the knowledge of following  C programming topics: C if...else Statement C Programming for Loop C Programming break and continue Statement A prime number is a positive integer which is divisible only by 1 and itself. For example: 2, 3, 5, 7, 11, 13 Example: Program to Check Prime Number #include <stdio.h> int main () { int n , i , flag = 0 ; printf ( "Enter a positive integer: " ); scanf ( "%d" , & n ); for ( i = 2 ; i <= n / 2 ; ++ i ) { // condition for nonprime number if ( n % i == 0 ) { flag = 1 ; break ; } } if ( n == 1 ) { printf ( "1 is neither a prime nor a compos...

NEW TOPIC

You have seen the basic structure of a C program, so it will be easy to understand other basic building blocks of the C programming language. Tokens in C A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol. For example, the following C statement consists of five tokens − printf ( "Hello, World! \n" ); The individual tokens are − printf ( "Hello, World! \n" ) ; Semicolons In a C program, the semicolon is a statement terminator. That is, each individual statement must be ended with a semicolon. It indicates the end of one logical entity. Given below are two different statements − printf ( "Hello, World! \n" ); return 0 ; Comments Comments are like helping text in your C program and they are ignored by the compiler. They start with /* and terminate with the characters */ as shown below − /* my first program in C */ You cannot have comments within comments...
Image
Accepting command line arguments in C using argc and argv BY ALEX ALLAIN In C it is possible to accept command line arguments. Command-line arguments are given after the name of a program in command-line operating systems like DOS or Linux, and are passed in to the program from the operating system. To use command line arguments in your program, you must first understand the full declaration of the main function, which previously has accepted no arguments. In fact, main can actually accept two arguments: one argument is number of command line arguments, and the other argument is a full list of all of the command line arguments. THERE PROGRAM IS NEXT LEVEL TECHNICALCLA.BLOGSPOT.COM

TYPECASTING

Image
Typecasting BY ALEX ALLAIN

FIRST PROGRAM IN C LANGUAGE

#include <stdio.h> int main() {     printf("Hello, World!");     return 0; } technicalcla.blogspot.com

C FILE I/O

Image
C File I/O and Binary File I/O BY ALEX ALLAIN In this tutorial, you'll learn how to do file IO, text and binary, in C, using  fopen ,  fwrite , and  fread ,  fprintf ,  fscanf ,  fgetc  and  fputc . FILE * For C File I/O you need to use a FILE pointer, which will let the program keep track of the file being accessed. (You can think of it as the memory address of the file or the location of the file). For example: FILE *fp; fopen To open a file you need to use the fopen function, which returns a FILE pointer. Once you've opened a file, you can use the FILE pointer to let the compiler perform input and output functions on the file. FILE *fopen(const char *filename, const char *mode); In the filename, if you use a string literal as the argument, you need to remember to use double backslashes rather than a single backslash as you otherwise risk an escape character such as \t. Using double backslashes \\ escapes the \ key, so t...

RECURSION IN C

Image
Recursion in C by alex allain Recursion is a programming technique that allows the programmer to express operations in terms of themselves. In C, this takes the form of a function that calls itself. A useful way to think of recursive functions is to imagine them as a process being performed where one of the instructions is to "repeat the process". This makes it sound very similar to a loop because it repeats the same code, and in some ways it  is  similar to looping. On the other hand, recursion makes it easier to express ideas in which the result of the recursive call is necessary to complete the task. Of course, it must be possible for the "process" to sometimes be completed without the recursive call. One simple example is the idea of building a wall that is ten feet high; if I want to build a ten foot high wall, then I will first build a 9 foot high wall, and then add an extra foot of bricks. Conceptually, this is like saying the "buil...
Image
Binary Trees in C The binary tree is a fundamental data structure used in computer science. The binary tree is a useful data structure for rapidly storing sorted data and rapidly retrieving stored data. A binary tree is composed of parent nodes, or leaves, each of which stores data and also links to up to two other child nodes (leaves) which can be visualized spatially as below the first node with one placed to the left and with one placed to the right. It is the relationship between the leaves linked to and the linking leaf, also known as the parent node, which makes the binary tree such an efficient data structure. It is the leaf on the left which has a lesser key value (i.e., the value used to search for a leaf in the tree), and it is the leaf on the right which has an equal or greater key value. As a result, the leaves on the farthest left of the tree have the lowest values, whereas the leaves on the right of the tree have the greatest values. More importantly, as each lea...
C BITS MANIPULATION Bitwise Operators: Bitwise operator works on bits and perform bit by bit operation. Assume if B = 60; and B = 13; Now in binary format they will be as follows: A = 0011 1100 B = 0000 1101 ----------------- A&B = 0000 1000 A|B = 0011 1101 A^B = 0011 0001 ~A  = 1100 0011 Show Examples There are following Bitwise operators supported by C language Operator Description Example & Binary AND Operator copies a bit to the result if it exists in both operands. (A & B) will give 12 which is 0000 1100 | Binary OR Operator copies a bit if it exists in eather operand. (A | B) will give 61 which is 0011 1101 ^ Binary XOR Operator copies the bit if it is set in one operand but not both. (A ^ B) will give 49 which is 0011 0001 ~ Binary Ones Complement Operator is unary and has the efect of 'flipping' bits. (~A ) will give -60 which is 1100 0011 << Binary Left Shift Operator. The left operands value is moved left by the number of bit...
WORKING OF THE FILE To open a file you need to use the  fopen  function, which returns a FILE pointer. Once you've opened a file, you can use the FILE pointer to let the compiler perform input and output functions on the file. FILE *fopen(const char *filename, const char *mode); Here filename is string literal which you will use to name your file and mode can have one of the following values w - open for writing (file need not exist) a - open for appending (file need not exist) r+ - open for reading and writing, start at beginning w+ - open for reading and writing (overwrite file) a+ - open for reading and writing (append if file exists) Note that it's possible for fopen to fail even if your program is perfectly correct: you might try to open a file specified by the user, and that file might not exist (or it might be write-protected). In those cases, fopen will create a file if you specify file mode as "w", "w+", "a", or "a...
C STRUCTURED DATA TYPE Structure Example: Try out following example to understand the concept: #include <stdio.h> struct student { char firstName[20]; char lastName[20]; char SSN[10]; float gpa; }; main() { struct student student_a; strcpy(student_a.firstName, "Deo"); strcpy(student_a.lastName, "Dum"); strcpy(student_a.SSN, "2333234" ); student_a.gpa = 2009.20; printf( "First Name: %s\n", student_a.firstName ); printf( "Last Name: %s\n", student_a.lastName ); printf( "SNN : %s\n", student_a.SSN ); printf( "GPA : %f\n", student_a.gpa ); } This will produce following results: First Name: Deo Last Name: Dum SSN : 2333234 GPA : 2009.20 Pointers to Structs: Sometimes it is useful to assign pointers to structures (this will be evident in the next section with self-referential structures). Declaring pointers to structures is basically the same as declaring a norma...
C OPERATOR TYPE What is Operator?  Simple answer can be given using expression  4 + 5 is equal to 9 . Here 4 and 5 are called operands and + is called operator. C language supports following type of operators. Arithmetic Operators Logical (or Relational) Operators Bitwise Operators Assignment Operators Misc Operators Lets have a look on all operators one by one. Arithmetic Operators: There are following arithmetic operators supported by C language: Assume variable A holds 10 and variable B holds 20 then: Show Examples Operator Description Example + Adds two operands A + B will give 30 - Subtracts second operand from the first A - B will give -10 * Multiply both operands A * B will give 200 / Divide numerator by denumerator B / A will give 2 % Modulus Operator and remainder of after an integer division B % A will give 0 ++ Increment operator, increases integer value by one A++ will give 11 -- Decrement operator, decreases integer value by one A-- w...
C~ STORAGE KEYWORDS A storage class defines the scope (visibility) and life time of variables and/or functions within a C Program. There are following storage classes which can be used in a C Program auto register static extern auto - Storage Class auto  is the default storage class for all local variables. { int Count; auto int Month; } The example above defines two variables with the same storage class. auto can only be used within functions, i.e. local variables. register - Storage Class register  is used to define local variables that should be stored in a register instead of RAM. This means that the variable has a maximum size equal to the register size (usually one word) and cant have the unary '&' operator applied to it (as it does not have a memory location). { register int Miles; } Register should only be used for variables that require quick access - such as counters. It should also be noted that...
C RESERVED KEYWORDS The following names are reserved by the C language. Their meaning is already defined, and they cannot be re-defined to mean anything else. auto else long switch break enum register typedef case extern return union char float short unsigned const for signed void continue goto sizeof volatile default if static while do int struct _Packed double       While naming your functions and variables, other than these names, you can choose any names of reasonable length for variables, functions etc.
The computer as we know it today had its beginning with a 19th century English mathematics professor name Charles Babbage. He designed the Analytical Engine and it was this design that the basic framework of the computers of today are based on. Generally speaking, computers can be classified into three generations. Each generation lasted for a certain period of time,and each gave us either a new and improved computer or an improvement to the existing computer. First generation: 1937 – 1946 -  In 1937 the first electronic digital computer was built by Dr. John V. Atanasoff and Clifford Berry. It was called the Atanasoff-Berry Computer (ABC). In 1943 an electronic computer name the Colossus was built for the military. Other developments continued until in 1946 the first general– purpose digital computer, the Electronic Numerical Integrator and Computer (ENIAC) was built. It is said that this computer weighed 30 tons, and had 18,000 vacuum tubes which was used for processing. When ...

History of c

Image

Popular posts from this blog

TECHNICAL INTERVIEW QUESTION

MS DHONI