...About The Tutorial C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to develop the UNIX operating system. C is the most widely used computer language. It keeps fluctuating at number one scale of popularity along with Java programming language, which is also equally popular and most widely used among modern software programmers. Audience This tutorial is designed for software programmers with a need to understand the C programming language starting from scratch. This tutorial will give you enough understanding on C programming language from where you can take yourself to higher level of expertise. Prerequisites Before proceeding with this tutorial, you should have a basic understanding of Computer Programming terminologies. A basic understanding of any of the programming languages will help you in understanding the C programming concepts and move fast on the learning track. Copyright & Disclaimer Copyright 2014 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the...
Words: 13419 - Pages: 54
...Exercise Based on basics of c and if else 1. Write a program to print ASCII value of a character entered. 2.Write a program to read a character and if the character entered is a upper case then convert it into lower case and vice versa. 3. Write a program to convert degree Fahrenheit into degree Celsius. 4. Write a program to check whether a number entered is a even number or odd number using switch case statement. 5. Write a program to read month of the year as an integer and print the month name using switch case statement. Exercise based on Loops 1. Write a program to print first 10 natural numbers using while loop, for loop and do while loop. 2. Write a program to calculate the sum of first 10 natural number using while loop, for loop do while loop. 3. Write a program to find the reverse of a number. 4. Write a program to check whether a number is palindrome or not. 5. Write a program to check whether a three digit number is a Armstrong number or not. 6. Write a program to print the numbers from m to n range. 7.write a program to calculate factorial of a number. 8.Write a program to check whether a number is prime or not. 9.Write a program to calculate the sum of digits of a number. 10.Write a program to print the following pattern using loops (a)* (b)1 (c) 1 (d) 0 ** 12 22 12 *** ...
Words: 662 - Pages: 3
...division logic should be in separate function. #include<stdio.h> #include<conio.h> int a,b,x,y; int sumIt(int x , int y ) { return x + y; } int multiplyIt(int x, int y) { return x * y; } int devideIt(int x, int y) { return y / x; } void displayIt(int a, int b) { if (a < 100 && b < 100) { printf("sum is %d",sumIt(a,b)); printf("\nproduct is %d",multiplyIt(a,b)); } else if (a < 100 && b > 100) { printf("Devision is %d",devideIt(a,b)); } else { printf("No condition matches so not performing any calcuclation."); } } void main() { printf("Enter value of a and b:"); scanf("%d %d",&a,&b); displayIt(a,b); getch(); } * Write a program which perform following on string data * Reverse * Small to caps * Caps to small * Find a character from string * Replace a character REVERSE: #include<stdio.h> int main(){ char str[50]; char rev[50]; int i=-1,j=0; printf("Enter any string : "); scanf("%s",str); while(str[++i]!='\0'); while(i>=0) rev[j++] = str[--i]; rev[j]='\0'; printf("\nString Reversal is : %s \n",rev); return 0; } SMALL TO CAPS AND CAPS TO SMALL #include <ctype.h> #include <stdio.h> int main(void) { char str[80]; int i; printf("Enter a string: "); gets(str); for( i = 0; str[ i ]; i++) str[ i ] = toupper( str[ i ] ); ...
Words: 366 - Pages: 2
...Introduction to the C Programming Language Science & Technology Support High Performance Computing Ohio Supercomputer Center 1224 Kinnear Road Columbus, OH 43212-1163 Table of Contents • • • • • • • • • Introduction C Program Structure Variables, Expressions, & Operators Input and Output Program Looping Decision Making Statements Array Variables Strings Math Library Functions • • • • • • • • • User-defined Functions Formatted Input and Output Pointers Structures Unions File Input and Output Dynamic Memory Allocation Command Line Arguments Operator Precedence Table 2 C Programming Introduction • Why Learn C? 3 C Programming Why Learn C? • • • • • • • • • Compact, fast, and powerful “Mid-level” Language Standard for program development (wide acceptance) It is everywhere! (portable) Supports modular programming style Useful for all applications C is the native language of UNIX Easy to interface with system devices/assembly routines C is terse 4 C Programming C Program Structure • • • • • Canonical First Program Header Files Names in C Comments Symbolic Constants 5 C Programming Canonical First Program • The following program is written in the C programming language: #include main() { /* My first program */ printf("Hello World! \n"); } • • C is case sensitive. All commands in C must be lowercase. C has a free-form line structure. End of each...
Words: 4639 - Pages: 19
...Let Us C Fifth Edition Yashavant P. Kanetkar Dedicated to baba Who couldn’t be here to see this day... About the Author Destiny drew Yashavant Kanetkar towards computers when the IT industry was just making a beginning in India. Having completed his education from VJTI Mumbai and IIT Kanpur in Mechanical Engineering he started his training company in Nagpur. Yashavant has a passion for writing and is an author of several books in C, C++, VC++, C#, .NET, DirectX and COM programming. He is a much sought after speaker on various technology subjects and is a regular columnist for Express Computers and Developer 2.0. His current affiliations include being a Director of KICIT, a training company and DCube Software Technologies, a software development company. In recognition to his contribution Microsoft awarded him the prestigious “Best .NET Technical Contributor” award recently. He can be reached at kanetkar@kicit.com. Preface to the Fifth Edition It is mid 2004. World has left behind the DOTCOM bust, 9/11 tragedy, the economic downturn, etc. and moved on. Countless Indians have relentlessly worked for close to two decades to successfully establish “India” as a software brand. At times I take secret pleasure in seeing that a book that I have been part of, has contributed in its own little way in shaping so many budding careers that have made the “India” brand acceptable. Computing and the way people use C for doing it keeps changing as years go by. So overwhelming...
Words: 46379 - Pages: 186
...Yourself C in 24 Hours Previous | Table of Contents | Next Hour 1 - Getting Started A journey of a thousand miles is started by taking the first step. —Chinese proverb High thoughts must have high language. —Aristophanes Welcome to Teach Yourself C in 24 Hours. In this first lesson you'll learn the following: What C is Why you need to learn C The ANSI standard Hardware and software required in order to run the C program What Is C? C is a programming language. The C language was first developed in 1972 by Dennis Ritchie at AT&T Bell Labs. Ritchie called his newly developed language C simply because there was a B programming language already. (As a matter of fact, the B language led to the development of C.) C is a high-level programming language. In fact, C is one of the most popular general-purpose programming languages. In the computer world, the further a programming language is from the computer architecture, the higher the language's level. You can imagine that the lowest-level languages are machine languages that computers understand directly. The high-level programming languages, on the other hand, are closer to our human languages. (See Figure 1.1.) Figure 1.1. The language spectrum. High-level programming languages, including C, have the following advantages: Readability: Programs are easy to read. Maintainability: Programs are easy to maintain. Portability: Programs are easy to port across different computer platforms. The C language's...
Words: 73255 - Pages: 294
...C Functions Intended Learning Outcomes • Distinguish the basic concepts of functions • Differentiate built-in function to user-defined function • Differentiate the functions that do not return a value and functions that return a value. • Apply or create function/s to solve problems Function • known with various names like a method or a sub-routine or a procedure, etc. • is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions. Two types of function • Built-in function – Functions inside the libraries – Stdio.h -> printf() – Math.h -> sqrt() • User-defined function – Functions that are declared and defined by programmers. Functions • You can divide up your code into separate functions. How you divide up your code among different functions is up to you, but logically the division usually is so each function performs a specific task. Advantages of user defined functions 1. Helps to decompose the large program into small segments which makes programmer easy to understand, maintain and debug. 2. If repeated code occurs in a program. Function can be used to include those codes and execute when needed by calling that function. 3. Programmer working on large project can divide the workload by making different functions Advantage Structured Approach Method-oriented Approach Dividing...
Words: 1748 - Pages: 7
...C PROGRAMMING Section 1. Topics: Functions Statements Input Output Variables Introduction The C programming language has been the most popular high level language used for engineering applications for the last 20 years. It shares many common structures with other procedural languages, such as Pascal, and can be used for general purpose programming of a PC. However, it is also particularly good for development of embedded application programs such as those found in phones, video recorders and so forth. The term procedural language refers to the fact that the language uses procedures to do particular tasks such as printing on the screen. In C these procedures are known as functions and are described below. What is so good about a language like C? The basic reason such languages were developed was to make it easier for humans to program computers. The alternative is the language of the computer, i.e., binary codes. Clearly such ‘low-level’ languages are not very appealing for humans, although sometimes necessary for detailed engineering work. (In fact C is often ‘mixed’ with such languages for engineering applications.) C uses words and symbols that are part of, or similar to, normal language. This makes it easier for programmers to develop code. The C code is converted to the machine code by a special program called a compiler. See note 1. But perhaps the most useful thing about such a language is that it provides the developer with a library of ‘mini-programs’...
Words: 3795 - Pages: 16
...Latham Comparison of C, C++, and C# IADT Seattle The C family of languages has been a cornerstone in the programming field for years. So exactly what is the C family? It includes the C, C++ and C# (pronounced sharp) languages. Now that we know what they are, what are the differences between the three? Well, that is what will be discussed here. C is a minimalistic programming language because it could be compiled in a straightforward manner by a relatively simple compiler. C offers low-level access to memory via pointers and the ability to access specific hardware addresses. C generates only a few instructions of machine languages for each of its core language elements and does not require extensive run-time support. It can be concluded that C language is suitable for many systems-programming applications that had traditionally been implemented in assembly languages (Gabb, 2012). With its inherent low-level memory access and small run-time support, using C for embedded hardware systems is ideal. Many devices such as robots, machinery, and electronic tools are programmed utilizing its ability to access specific hardware addresses. However, as C is structured oriented programming language and focuses on the procedural programming paradigm, it is relatively hard to control the large-scale program. As C language has high level and machine level mixed programming capacity, it is used in most hardware related applications. It is very suitable for writing programs in embedded device...
Words: 1038 - Pages: 5
...Release Team[oR] 2001 [x] java Java 2: The Complete Reference by Patrick Naughton and Herbert Schildt Osborne/McGraw-Hill © 1999, 1108 pages ISBN: 0072119764 This thorough reference reads like a helpful friend. Includes servlets, Swing, and more. Table of Contents Back Cover Synopsis by Rebecca Rohan Java 2: The Complete Reference blends the expertise found in Java 1: The Complete Reference with Java 2 topics such as "servlets" and "Swing." As before, there's help with Java Beans and migrating from C++ to Java. A special chapter gives networking basics and breaks out networking-related classes. This book helps you master techniques by doing as well as reading. Projects include a multi-player word game with attention paid to network security. The book is updated where appropriate throughout, and the rhythm of text, code, tables, and illustrations is superb. It's a valuable resource for the developer who is elbow-deep in demanding projects. Table of Contents Java 2 Preface - 7 Part l The Java Language - The Complete Reference - 4 Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 hapter 10 - The Genesis of Java - 9 - An Overview of Java - 20 - Data Types, Variables, and Arrays - 36 - Operators - 57 - Control Statements - 75 - Introducing Classes - 94 - A Closer Look at Methods and Classes - 111 - Inheritance - 134 - Packages and Interfaces - 156 - Exception Handling - 174 Chapter 11 - Multithreaded Programming...
Words: 78285 - Pages: 314
...hardcopy) Weighting: Part of 10% of overall assessment. Environment: You are required to do this assignment in C++ environment. Assessment Your assignment will be assessed for the following: Correctness of the programs Sample test data/results/output or discussion of results No plagiarism Submission You are required to submit documentation in the form of printed copy of your codes and sample test data. Your submission should bind together with the assignment cover given at the end of this assignment question. Use GREEN colour paper as your Assignment 1 cover. Warning 1. To be done in individually. 2. Marks will be deducted for plagiarism and late submission. ASSIGNMENT QUESTION: Question 1 (50 marks) In linked list, an ordered collection of data in which each element contains the location of the next element or elements using pointers. You are required to build a singly linked list program in C++ programming: 1) Create a singly linked list that contains data of 2,15,8,24,63,77 and print out the output. (10 marks) 2) With the creation of the linked list data, delete the no 8, 24 and 77 and print out the output. (5 marks) 3) Add the no 10 ,25 and 30 in your list and print out the output. (5 marks) Question 2 5. You are required to write a C++ program that indicates Linked List : a) Create a structure “model”. This structure basically has members of model...
Words: 503 - Pages: 3
...Generic; using System.Linq; using System.Text; namespace Csharp_exercises { class Program { static void Main(string[] args) { int x,y,z; Console.Write("Enter value 1:"); x = int.Parse(Console.ReadLine()); Console.Write("Enter value 2:"); y = int.Parse(Console.ReadLine()); Console.Write("Enter value 3:"); z = int.Parse(Console.ReadLine()); if (x > y) if (x > z) Console.Write("The greatest value is:{0}.",x); else Console.Write("The greatest value is:{0}.", z); else if (y > z) Console.Write("The greatest value is:{0}.",y); else Console.Write("The greatest value is:{0}.",z); Console.ReadLine(); } } } 2. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Csharp_exercises { class Program { static void Main(string[] args) { float quiz_score; float mid_score; float final_score; float avg; Console.Write("Enter quiz score:"); quiz_score=float.Parse(Console.ReadLine()); Console.Write("Enter mid-term score:"); mid_score = float.Parse(Console.ReadLine()); Console.Write("Enter final score:"); final_score = float.Parse(Console.ReadLine()); avg = (quiz_score +mid_score+final_score) / 3; if (avg >= 90) Console.WriteLine("Grade A"); else if ((avg >= 70) && (avg < 90)) Console.WriteLine("Grade B"); else if ((avg >= 50) && (avg < 70)) Console.WriteLine("Grade C"); else if (avg < 50) Console.WriteLine("Grade F"); else Console.WriteLine("Invalid...
Words: 457 - Pages: 2
..."functions", are created and used in junction with each other to perform a function. These objects are organized within the program through use of things called structures or classes. A class is something we use to create a blueprint of sorts for a assortment of variables and components. Similarly, a structure serves the same purpose. The only difference between a structure and a class is that a structure's members are public by default and a classes members are private by default. Another form of "blueprint" used by programmers is the data union. While a union is very primitive in comparison to a structure or class, it is a good tool to use to conserve memory in larger applications. A union uses the same memory block for multiple variables at different points. While two variables in a union cannot be accessed at the same time, a union is a good way to re-use blocks of memory that would normally be left void after a variable is finished with. Now that I have covered the basic points of classes, structures and unions, I will go into more detail of just how powerful a class or structure can be. In basic reference, a class is simply a blueprint to something we create instances of later in the program. This is a very vague statement however, because in object-oriented programming the class is the backbone of the program. It is what makes the program do what it is intended to do. Members of a class are private by default, though they can be made selectively public...
Words: 813 - Pages: 4
...packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with these names could be kept in that shelf as in this example: bottom of shelf ---> [AAAJKRDFDEWAAYFYYKK]-----Top of shelf. All these packets are to be loaded on cars. The cars are lined in order, so that the packet could be loaded on them. The cars are also named [A, B, C, D, E,………….]. Each Car will load the packet with the same alphabet. So, for example, car ‘A’ will load all the packets with name ‘A’. Each particular car will come at the loading point only once. The cars will come at the loading point in alphabetical order. So, car ‘B’ will come and take all the packets with name ‘B’ from the shelf, then car ‘C’ will come. No matter how deep in the shelf any packet ‘B’ is, all of the ‘B’ packets will be displaced before the ‘C’ car arrives. For that purpose, some additional shelves are provided. The packets which are after the packet B, are kept in those shelves. Any one of these shelves contains only packets, having the same name. For example, if any particular shelf is used and if a packet with name X is in it, then only the packets having names X will be kept in it. That shelf will look like [XXXXXXX]. If any shelf is used once, then it could be used again only if it is vacant. Packets from the initial shelf could be unloaded from top only. Write a program that finds the minimum total number of shelves, including...
Words: 6793 - Pages: 28
...assumes a different numeric (number) and/or alphanumeric (combination of numbers and letters) value. * Start with a letter * 1 to 32 character * 1 word * NO SPECIAL SYMBOL ASIDE FROM UNDERSCORE (_) * Not a KEYWORD TYPES OF VARIABLE 1. Constructive – It doesn’t change 2. Destructive – It change to another value DATA In the C programming language, data types refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted. The types in C can be classified as follows: S.N. | Types and Description | 1 | Basic Types:They are arithmetic types and consists of the two types: (a) integer types and (b) floating-point types. | 2 | Enumerated types:They are again arithmetic types and they are used to define variables that can only be assigned certain discrete integer values throughout the program. | 3 | The type void:The type specifier void indicates that no value is available. | 4 | Derived types:They include (a) Pointer types, (b) Array types, (c) Structure types, (d) Union types and (e) Function types. | The array types and structure types are referred to collectively as the aggregate types. The type of a function specifies the type of the function's return value. We will see basic types in the following section, whereas, other types will be covered in the upcoming chapters. Integer Types Following...
Words: 797 - Pages: 4