simple C code, assignment help

Anonymous
timer Asked: Oct 20th, 2016
account_balance_wallet $10

Question description

I just need the idea, If you have already done it, please copy paste I will get the idea. only make sure you are right

I have a simple C assignment But am too tired to think. Someone help me as I rest. Here is it A set can be implemented using an enumerated type of elements and an int with bits set to indicate whether an element is present. For example: //Start of code typedef enum {SOCCER=1, FOOTBALL=2, RUGBY=4, CRICKET=8} players; struct set_int { int elements; }; typedef struct set_int *set; //End of code Implement the following functions for a set: 1) void init_set(set *sp) — create an empty set; 2) void add_element(set s, int e) — update s so that it contains only the element e; and 3) void invert(set s) — update s so that it contains all the elements not in it when the function is called and doesn’t contain the elements which were in it when the function is called. Include comments explaining your logic. Just that simple If you have it, you can copy paste. I will modify… Q2 Write a function to ‘deeply clone’ (fully copy), all values of a binary search tree as defined as follows: // Code typedef struct bstnode_int *bstnode; struct bstnode_int { void *data; bstnode left; bstnode right; }; typedef struct binstree_int {bstnode root;} *binstree; You should return the copy — your function should have the following header: binstree clone(binstree t, void *(*copyData)(void *));

Tutor Answer

Prof Newton
School: Carnegie Mellon University

Attached.

C Programs with Solutions

C
Programs with Solutions

By

S. ANANDAMURUGAN
M.E., (Ph.D)., MISTE., MACEEE.,
Senior Lecturer, Department of Computer Science & Engineering,
Kongu Engineering College, Perundurai
Tamil Nadu

UNIVERSITY SCIENCE PRESS
(An Imprint of Laxmi Publications Pvt. Ltd.)
BANGALORE
JALANDHAR




CHENNAI
KOLKATA




COCHIN
LUCKNOW

RANCHI






GUWAHATI
MUMBAI

NEW DELHI




HYDERABAD
PATNA

Published by :

UNIVERSITY SCIENCE PRESS
(An Imprint of Laxmi Publications Pvt. Ltd.)
113, Golden House, Daryaganj,
New Delhi-110002
Phone : 011-43 53 25 00
Fax : 011-43 53 25 28
www.laxmipublications.com
info@laxmipublications.com
Copyright © 2011 by Laxmi Publications Pvt. Ltd. All rights reserved. No part of this
publication may be reproduced, stored in a retrieval system, or transmitted in any form or
by any means, electronic, mechanical, photocopying, recording or otherwise without the
prior written permission of the publisher.

Price: < 180.00 Only.

First Edition: 2011
OFFICES








Bangalore
Cochin
Hyderabad
Kolkata
Mumbai

080-26 75 69 30
0484-237 70 04, 405 13 03
040-24 65 23 33
033-22 27 43 84
022-24 91 54 15, 24 92 78 69

Ranchi

0651-221 47 64

UCP–9612–180–C PROGRAM WITH SOLUTION–ANA
Typeset at : Monu Printographics, Delhi







Chennai
Guwahati
Jalandhar
Lucknow
Patna

044-24 34 47 26
0361-251 36 69, 251 38 81
0181-222 12 72
0522-220 99 16
0612-230 00 97

C—
Printed at : Ajit Printers, Delhi

Dedicated to
My Son
Master A. Shrikarthick

Contents
Chapters
1. C Concepts
2. Introduction—C Programs
3. Fundamentals—C Programs
4. C Debugging
5. Sample Questions
6. Short Questions and Answers
7. Questions

Pages
1–11
12–51
52–112
113–248
249–261
262–279
280–286

Preface
This book gives a rich collection of C programs. These programs that support the theoretical
concepts are given in a large number to help students understand the concepts better. This
book will be useful for students of BE, MCA, BCA, MSc, and BSc, which have C programming language as a part of the course.
The first chapter deals with the fundamental concepts of C language. The second chapter
focuses on introduction C programming. The third chapter provides with detailed program on
next level to the basic C program. Fourth chapter focuses on C debugging. The fifth chapter
deals with the simple C questions and Answers. Sixth chapter deals with the short questions
and answers.
The main aim of this book is to give maximum guidance to the students, faculty and research
scholars. Suggestions for improvement will be appreciated and incorporated.
—Author

Chapter

1

C CONCEPTS

1.0 OVERVIEW OF C PROGRAMMING
C language is one of the most popular computer languages today because it is a structured,
high level, machine independent language. It allows software developers to develop programs without
worrying about the hardware platforms where they will be implemented. C is called a high level,
compiler language. The aim of any high level computer language is to provide an easy and natural
way of giving a programme of instructions to a computer.
C is one of a large number of high level languages which can be used for general purpose
programming, i.e., anything from writing small programs for personal amusement to writing complex
applications. It is unusual in several ways. Before C, high level languages were criticized by machine
code programmers because they shielded the user from the working details of the computer. The C
language has been equipped with features that allow programs to be organized in an easy and
logical way. This is vitally important for writing lengthy programs because complex problems are
only manageable with a clear organization and program structure.
C allows meaningful variable names and meaningful function names to be used in programs
without any loss of efficiency and it gives a complete freedom of style, it has a set of very flexible
loop constructions and neat ways of making decisions. These provide an excellent basis for controlling
the flow of programs. Another feature of C is the way it can express ideas concisely. The richness of
a language shapes what it can talk about. C gives us the apparatus to build neat and compact programs.
C tries to make the best of a computer by linking as closely as possible to the local environment.
The increasing popularity of C is probably due to its many desirable qualities. It is a robust
language whose rich set of built-in functions and operators can be used to write any complex program.
The C compiler combines the capabilities of an assembly language with the features of a high-level
language and therefore it is well suited for writing both system software and business packages.
Programs written in C are efficient and fast. This is due to its variety of data types and powerful
operators. C is highly portable. This means that C programs written for one computer can be run on
another with little or no modification. Another feature of C is its ability to extend itself.
1

2

C PROGRAMS

WITH

SOLUTIONS

1.1 INTRODUCTION
C is a remarkable language. Designed originally by Dennis Ritchie, working at AT&T Bell
Laboratories in New Jersey, it has increased in use until now it may well be one of the most widelywritten computer languages in the world. C is a structured language. It allows variety of programs
in small modules. It is easy for debugging, testing, and maintenance if a language is a structured
one.

1.2 STRUCTURE OF A C PROGRAM
Include header file section
Global declaration section
main()
{
Declaration part
Executable part
}
User-defined functions
{
Statements
}

Include Header File Section
C program depends upon some header files for function definition that are used in program.
Each header file by default is extended with .h. The header file should be included using # include
directive as given here.

Global Declaration
This section declares some variables that are used in more than one function. These variables
are known as global variables. This section must be declared outside of all the functions.

Function Main
Every program written in C language must contain main () function. The function main() is
a starting point of every C program. The execution of the program always begins with the function
main ().

Declaration Part
The declaration part declares the entire variables that are used in executable part. The
initialisations of variables are also done in this section. Initialisation means providing initial value
to the variables.

C CONCEPTS

3

Executable Part
This part contains the statements following the declaration of the variables. This part conatins
a set of statements or a single statement. These statements are enclosed between the braces.

User Defined Function
The functions defined by the user are called user-defined functions. These functions are
generally defined after the main () function.

1.3 STEPS FOR EXECUTING THE PROGRAM
1. Creation of program
Programs should be written in C editor. The file name does not necessarily include exten...

flag Report DMCA
Review

Anonymous
Outstanding Job!!!!

Similar Questions
Hot Questions
Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors