How do you print array variable without using array subscripts?
Well the most prolific answer to this query would be the use of pointers.Use a pointer and allocate it to the array of interest and start printing.
What is the program for palindrome numbers from 500 to 100?
#include<iostream>
// forward declarations...
unsigned reverse (unsigned, const unsigned base = 10);
bool is_palindrome (const unsigned);
// the program...
int main (void) {
const unsigned max {500};
const unsigned min {100};
std::cout << "Palindromes from " << max << " to " << min << std::endl;
for (unsigned num {max}; num>=min; --num) {
if (is_palindrome (num)) {
std::cout << num << std::endl;
}
}
}
// Returns the reverse of a number using the given base (default: base 10)
// Note: trailing zeroes do not become leading zeroes so reverse (100) returns 1 not 001.
// However, the reverse of 0 is obviously 0.
unsigned reverse (unsigned num, const unsigned base /* = 10 */) {
unsigned rev {}; // zero-initialised
while (num) {
rev *= base;
rev += num % base;
num /= base;
}
return rev;
}
// If the reverse of a number is the same number, that number is a palindrome.
// All single-digit numbers are palindromes, including 0.
bool is_palindrome (const unsigned num) {
return num == reverse (num) ;
}
What is the absolute machine code?
The very lowest possible level at which you can program a computer is in its own native machine code, consisting of strings of 1's and 0's and stored as binary numbers. The main problems with using machine code directly are that it is very easy to make a mistake, and very hard to find it once you realize the mistake has been made.
How do i write a program in c langua ge for the implementation of binary search with output?
There are various ways to implement a binary search, but the simplest makes use of a sorted array. It must be sorted because we need to know where values are in relation to one another. That is, if we know that element X has the value Y, then all values less than Y must be in the first half of the array, and all values greater than Y must be in the second half of the array.
We begin by looking at the middle element of the array. If there is no middle element (the array is empty) then the value does not exist. But if the middle value holds the value we are looking for, we are done. Otherwise we compare values to decide which half of the array can be eliminated. We then repeat the process with the remaining half of the array.
What is the difference between copy command and move command?
A move command is simply a copy command which deletes the original once it's finished.
Write a shell script to count the number of times is appears in a given text file?
You don't need a shell script to do this; use the 'grep' command with the '-c' option to count the number of occurrences of some pattern.
Can you give an example of array using character variable in c program?
the example of array over charcter variables is char ["string"]
When we are talking about dereferencing in C we are talking about the pointers and how to get value from them, not address.
Dereferencing operator notation is "*".
Here is a simple example of dereferencing:
int num;
int pNum*;
pNum = # /* make pNum pointer point to numlocation in memory/stack */
*pNum = 7; /* setting pNum value to 7. Note! numvalue becomes 7 too, because pNum points to the same memory location as num */
hi bye i hate yo! Marcian Hoff was one of the inventors for the microprocessor. The microprocessor is like the engine for the computer. When you turn on the computer the microprocessor helps the computer start.
How does a subroutine work in Linux?
With Linux being mostly written in C and normally interfaced via C libraries, I'll give an example from the C point of view, thus I'll refer to functions in place of sub routines.
Using the following C function as an example:
int add(int number1, int number2) { return (number1 + number2); }Before the add function is called, the values of its arguments are pushed onto the stack by the caller in reverse order (number2 then number1).
When the function is called, it reads the values of number1 and number2 from the stack into CPU registers where the addition is done, leaving the answer in register eaxbefore returning from the function.
Different activities in the 6 phases in classical waterfall model?
1) Identify client requirements
2) Identify system requirements
3) Create an overall design
4) Create a detailed design
5) Develop product
6) Test product
An assembly program is a machine-dependent program written in a low-level symbolic code known as assembly language.
Signed binary subtraction 000000111001-111010000101 equals 000110101110 right?
Wrong. You don't say whether you are using ones-complement notation or twos-complement notation, but in either case you'd be wrong. Your answer of 000110101110 is 430 decimal, but the correct answer is 435 or 436 depending on which notation you use.
Ones-complement notation:
000000111001 - 111010000101 = 000110110011
Decimal equivalent:
57 - (-378) = 57 + 378 = 435
Twos-complement notation:
000000111001 - 111010000101 = 000110110100
Decimal equivalent:
57 - (-379) = 57 + 379 = 436
Note that in ones-complement, converting the sign of any value simply inverts all the bits. So if we invert 111010000101 we get 000101111010 which is 378, thus the original signed value was -378. In twos complement we invert all the bits (as per ones-complement) and add 1, so 000101111010 + 1 is 000101111011 is 379, thus the original signed value was -379.
QED.
Program for derived class in cpp?
#include<iostream>
class base
{
int m_data;
public:
base(const int data):m_data(data){}
base(const base& cpy):m_data(cpy.m_data){}
base& operator=(const int rhs){m_data=rhs;return(*this);}
base& operator=(const base& rhs){m_data=rhs.m_data;return(*this);}
virtual ~base(){}
};
class derived
{
public:
derived(const int data):base(data){}
derived(const derived& cpy):base(cpy){}
derived& operator=(const int rhs){return(base::operator=(rhs));}
derived& operator=(const derived& rhs){return(base::operator=(rhs));}
virtual ~derived(){}
};
int main()
{
derived d=42;
}
Which data structure is used for recursion?
this question depends on what the recursion is being used for.....
sumit kumar srivastava
9455587002
What is the difference between deadlock and a race condition?
Race Conditions
A race condition occurs when two threads access a shared variable at the same time. The first thread reads the variable, and the second thread reads the same value from the variable. Then the first thread and second thread perform their operations on the value, and they race to see which thread can write the value last to the shared variable. The value of the thread that writes its value last is preserved, because the thread is writing over the value that the previous thread wrote.
Deadlocks
A deadlock occurs when two threads each lock a different variable at the same time and then try to lock the variable that the other thread already locked. As a result, each thread stops executing and waits for the other thread to release the variable. Because each thread is holding the variable that the other thread wants, nothing occurs, and the threads remain deadlocked.
Who is called as pseudo-intellectual?
The deffinition of pseudp = imposter: a person who makes deceitful pretenses
Preseumably a false intellectual who, while he or she may corroborate inherent truths of intelligence, does not actually have the implied capacity.
Sorting in programming is the process of arranging elements in some prescribed order.
An example might be, given arrays of people's names and birthdates, to sort them by birthdate.
How do you print the elements of singly linked list-program?
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
#define NULL 0
int item,ch;
struct slink
{
int data;
struct slink *next;
}
*start,*new,*l;
main()
{
clrscr();
start=NULL;
printf("\n**MENU**");
printf("\n1.CREATE \n2.PRINT \n3.EXIT ");
while(1)
{
printf("\nENTER YOUR CHOICE: ");
scanf("%d",&ch);
switch(ch)
{
case 1: create();
break;
case 2: print();
break;
default: exit();
break;
}
}
getch();
}
create()
{
start=NULL;
l=start;
printf("\nENTER THE DATA: \n");
scanf("%d",&item);
while(item!=0)
{
new=malloc(sizeof(struct slink));
new->data=item;
new->next=NULL;
if(start==NULL)
{
start=new;
l=new;
}
else
{
l->next=new;
l=l->next;
}
printf("\nENTER 0 TO TERMINATE: \n");
scanf("%d",&item);
}
}
print()
{
l=start;
while(l!=NULL)
{
printf("%d--> ",l->data);
l=l->next;
}
}
What is the number which can be divided by 4 and not with 2?
No such number exists, for if it is divisible by 4 (thus, 4x), then it is divisible by 2 (thus, 2*2x).