List two types of errors that can lead to an infinite loop?
Quite simply: a circular function in the programming, not going anywhere.
Why don't you directly specify the number of bytes to reserve to store data in memory?
You don't directly specify the number of bytes to reserve in memory to store data because you don't necessarily know how many bytes that data requires.
Instead, you specify the type of data and the number of elements, and the compiler and run-time library figures out how many bytes to allocate.
Its a portability issue. You don't want to tie your code to a specific word size because the code would then break when the underlying platform changes. One very famous example of this is the int data type in MS Windows 3.x. That was a 16-bit integer. When Windows "grew up" and the int became a 32-bit integer, the int changed to 32-bit, and everyone's code broke, except those that planned ahead and wrote the code correctly.
How do you convert decimal number to binary number using while loop?
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
long int a[20],i,n,count=0,b[20],c[20],sum=0;
printf("ENter the number in binary form=\t");
scanf("%ld",&n); // Get a binary number from the user
for (i=0;n>=1;i++)
{
a[i]=n%10;
n=n/10; // Loop To reverse the number And put all reversed numbers in arry a[i]
count=count + 1; // count to count the number of times this loop runs
}
for (i=0;i<=count-1;i++) // count -1 condition is used to run the loop till the previous loop run
{
b[i]=pow(2,i); // This is to raise the power of 2 to no of times previous loop runned.
}
for (i=0;i<=count-1;i++)
{
c[i]=a[i] * b[i]; // Multiply a[i] or reveresed binary no with b[i] or increasing pow of 2 to count-1
sum=sum +c[i]; // it is to add the c[i] elements with each other n put into sum variable.
}
printf("Decimal form =%ld",sum); // printing the sum to get the decimal form
getch();
}
// Hope it solves your problem, ANy more assistance honey.gupta13@yahoo.com ffffff
Why do you need signed and unsigned integer?
We need signed integers in order to represent both negative and positive values. However, some numbers can never be negative. For instance, the size of a file must always be greater than or equal to zero so we use unsigned integers to represent file sizes. Also, natural numbers must be greater than 0 so there's no point in using a signed value to represent a natural number. Signed integers also use one bit to denote the sign, but unsigned integers do not thus unsigned integers can effectively represent twice the range of positive values than an unsigned integer can. For instance, an 8-bit signed value can represent values in the range -128 to +127 using twos complement notation, but an 8-bit signed value can represent values in the range 0 to 255.
Write a C program to print numbers from 1 to 999 in words?
write a c program which reads an integer value from the keyboard then it displays the number in words?
#include<stdio.h>
#include<conio.h>
void main(void)
{
int rev,n,
clrscr();
printf("\n enter any number");
scanf("%d",&n);
temp=n;
while(n>0)
{
rem=temp%10;
rev+=rem*10;
temp=temp/10;
choice=rev%10;
switch(choice)
{
case 1:
printf("one");
break;
case 2:
printf("two");
break;
case 3:
printf("three");
break;
case 4:
printf("four");
break;
case 5:
print("five");
break;
case 6:
printf("six");
break;
case 7:
printf("seven");
break:
case 8:
printf("eight");
break:
case 9:
printf("nine");
}
getch();
}
What are the unique advantages of object oriented programming paradigm?
a. OOP provides a clear modular structure for programs which makes it good for defining abstract datatypes where implementation details are hidden and the unit has a clearly defined interface.
b. OOP makes it easy to maintain and modify existing code as new objects can be created with small differences to existing ones.
c. OOP provides a good framework for code libraries where supplied software components can be easily adapted and modified by the programmer. This is particularly useful for developing graphical user interfaces.
What is difference between c and pro c?
C is the computer language bases on K&R's language that has evolved over the years. It includes C++, as extended by Stroustroup..
Pro*C is an Oracle precompiler that will read a C or C++ program, detect Oracle extensions to it, and convert it to native code for subsequent processing by the C or C++ compiler. This involves building the data structures and function calls needed to use Oracle while passing the non-Oracle C or C++ code through intact. The amalgamated code is then processed by the C or C++ compiler and it now works with Oracle.
What is an example of a pretest loop?
Well, from my knowledge of pseudocode, a pre-test loop contains the DO WHILE and LOOP functions.
So say you want to pour some milk into your cereal for breakfast:
DO WHILE cereal_bowl.Full = False
Pour_Milk
LOOP
Basically this is you saying, I am going to pour milk WHILE the bowl is not full. Once the bowl is full you will stop because you checked before your poured (a pre-test).
Hope this helps.
- The Doctor
What is Objectives Oriented Evaluation Approach to program evaluation?
Objectives Oriented Evaluation Approach is the means by which the worth or merit of a program is assessed based on the extent to which the objectives or purposes of the program are being achieved.
Assume the question was for C#, not C.
":" is syntax to extend a type. If the type extended from is another class, they form a class hierarchy and the "inheritance" is established:
For example:
class Base {}
class Derived : Base {}
Derived extends Base, and thus inherits from Base.
How do you empty a file using C programming?
That depends on the type of file and what you mean by "empty". Generally, fopen() called on an existing file, with the "w" option instead of the "a" option will truncate the file to zero length. To delete a file completely is a different process. Function truncate is your friend.
Can a structure be assigned to another using assignment operator?
Yes, provided both structures are of the same type:
struct S {/*...*/};
S a, b;
// ...
a = b;
The built-in structure assignment operator is typically implemented as a memory copy (memcpy) operation as this is the most efficient means of performing member-wise copy, as opposed to performing individual assignment operations upon each member.
Be aware that pointer members are shallow-copied not deep-copied:
struct S {
void* ptr;
size_t size;
};
S a;
a.size = 100 * sizeof(int); // allow for storage of 100 integers
a.ptr = malloc (a.size); // allocate memory
At this point, object 'a' owns the memory allocated to a.ptr.
S b;
b = a;
At this point, ownership of the memory is ambiguous because both a.ptr and b.ptr are referring to the same memory address. Shared memory is best avoided because releasing that memory will invalidate all objects that share the same memory:
free (a.ptr);
free (b.ptr); // Undefined behaviour: releasing the same memory twice!
To avoid this, we must manually perform a deep-copy:
S b;
b.size = a.size; // copy the size member
b.ptr = malloc (b.size); // allocate new memory
memcpy (b.ptr, a.ptr, a.size); // deep-copy
Note that the onus is entirely upon the programmer to ensure resource ownership is unambiguous. The compiler cannot help you.
In object oriented languages like C++, we use "smart" pointers (resource handles) rather than "naked" pointers. In this way, the onus of resource ownership shifts to the language itself.
What are the three most common data types used in c?
Pick any three:
int, char, long, void, char *, void *
Basically in c++ passing an array as an argument only provides a pointer to the first value and that function won't know how many values it has.
If you read beyond the size you will just get garbage from memory.
What is the Advantages of selection sort?
+ reasonable fast in worst and average cases, n lg n + O(n)
+ in place
- best case still n lg n
How can the value of an expression be converted to a different data type in c?
There are different ways, there is one straight forward though. For instance you have a variable of type char: var1. And you want to convert it to another variable of type int: var2. You can use casting for it:
var2 = (int) var1;
You have to be very careful using casting because it cause buffer overflow. Newer versions of C have many different function to assure correctness of parsing, for instance, TryToParse...
Can a function be called from more than one place in a program in c plus plus?
In C and C++, as well as in many (all?) languages, a function can be called from more than one place in a program. That's the purpose of functions - to encapsulate pieces of code that are needed in more than one place in the program.
What is complete binary tree in c?
The basic idea (you write functions CountChildren, GetChild, NewBinTree):
struct GenTree;
struct BinTree;
typedef struct GenTree GenTree;
typedef struct BinTree BinTree;
int CountChildren (const GenTree *from);
int GetChild (const GenTree *from, int which);
BinTree *NewBinTree (DATATYPE data, BinTree *left, BinTree *right);
BinTree *Convert (const GenTree *from)
{
BinTree *bt, *tmp;
int i, n;
if (from==NULL) return NULL;
n = CountChildren (from);
bt = NewBinTree (from->data, NULL, NULL);
if (n 1) return bt;
tmp = Convert (GetChild (from, n));
for (i=n-1; i<=2; --i) {
tmp= NewBinTree (<NODATA>, Convert (GetChild (from, i)), tmp);
}
bt->right = tmp;
return bt;
}
Explain the scope and visibility of variables in c plus plus function?
If you define a variable inside of your function, the variable can be referred and used only inside of that function. It means that you will not able to use the variable in another function (including main). Area of code where your variable can be used after declaration is usually called visibility of the variable.
What is the difference between data record and data base?
A data record is a collection of various fields of data (like name, organisation, sex, age etc), whereas a database is a collection of records tables. (And views, indexes, stored procedures, and other stuff;)
Describe the four basic data types in c?
Describe the basic data types in C
Describe the basic data types in C
Your program is portable if you can compile and execute it on different platforms.
Which tools can be used to create prototypes?
Prototypes are normally built in a similar way to the final product however parts may differ slightly as they aren't always produced on a production line they are one off's made by hand or 'compatible' parts may be used instead to lower the cost of prototyping as it is a very expensive process.
Rapid prototyping uses 3D printing technologies to make prototype parts, this process also allows for no assembly of parts as they can be printed in place thus further speeding up the prototyping process. In some cases the material used isn't final but the process takes only hours compared to traditional weeks-months and can be used to test the fitting, visual appeal and dimensional properties of the product wanting to be prototypes.
In some cases computer modelling is used to make a prototype as you can test a design without ever having to build it physically. This has its draw backs of requiring large amounts of computing power and the models may require refinement to accurately reflect real scenarios.
What kinds of programming languages may be developed and used in the future?
It is always very hard to predict the future, especially in an area which has seen very rapid development over the past two decades.
In software engineering of applications interfacing with human users, powerful new declarative approaches are the modern choice, such as Microsoft's Windows Presentation Framework (WPF) and its XAML language, or Adobe's Flex (with MXML), and others.
It is probably fair to assume that the declarative part of application design will grow in the near and mid-term future, taking even more responsibility for the mundane tasks related to graphical user interface development off the programmer. This allows to focus more implementing the application's core algorithm and logic.
It's probably also fair to assume that the dividing line between desktop applications, web applications and mobile applications continue to diminish both in term of design as well as in terms of usability: applications will increasingly work within a web browser, and it will be common to have a (possibly feature reduced) mobile app on a smart phone or tablet computer, or a desktop app all resulting from the same development effort.
It is fair to assume that programming languages will continue supporting this goal in even more comprehensive hardware abstractions and increased automation of the housekeeping work.