answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

Write an algorithm and draw corresponding flow chart to check whether a given string is a palindrome or not?

Program

# include<stdio.h> void main() { long n,rev,t; int r; clrscr(); printf("Enter number : "); scanf("%ld",&n); t=n; rev=0; while(t>0) { r=t%10; rev=(rev*10)+r; t=t/10; } if(n==rev) printf("Number is palindrom"); else printf("Number is not palindrom"); getch(); }

algorithm

step 1 : input n

step 2 : s = 0, a=n

step 3 : while(n>0)

begin

rem=n%10

s=s*10+rem

n=n/10

end

step 4 : if(s==a)

print 'it is a palindrome'

else

print 'it is not a palindrome'

step 5 : stop

Write a program in c language to reverse elements of a queue?

There are many ways to reverse the order of the elements in a queue. Provided that you have access to the implementation of the queue, it is of course easy to read the elements from the tail end rather than the front end, thus reversing the elements.

However, considering the queue as a black box, and assuming the queue only allows for its characteristic operations (removal of head element, addition to tail), the best method to reverse the elements in a queue to engage a stack.

You'd remove the elements from the queue (always reading the head of the queue), and push each element onto the stack. When the queue is empty, you reverse that process: pop each element from the stack until it is empty, and add each element in this order to the end of the queue.

Your queue will have the exact same elements as in the beginning, but in reverse order.

The exact implementation of this in C, or in any other programming language, is trivial, but the exact source code depends on the implementation of queue and stack containers.

Following is pseudocode:

Queue<Item> reverse (Queue<Item> queue) {

Stack<Item> stack;

Item item;

while (queue.remove(&item)) {

stack.push(item);

}

while(stack.pop(&item)) {

queue.add(item);

}

return queue;

}

How do you display alphanumerics in C program?

#include<iostream.h>

int main()

{

char i,j;

for(i='a';i,<='z';i++)

{

cout<<i<<(char)(i-32);

}

return 0

}

What is the object-oriented version of C programming language that is used to develop software for PCs such as Fractal Design Painter Lotus 123 and games?

There isn't one; C is strictly non object oriented. Although C++ is often considered to be an object-oriented extension for C (it was originally called C with Classes), it would be more accurate to describe them as siblings. The two have evolved separately and while they still retain a high-level of compatibility through their common ancestry, they are not the same language.

How can you tell which text or graphics are links?

the string text to activate link is what will shows as hypertext on your webpage . when a viewer clicks on this hypertext , the web browser links him/her to the internet site indicated by the url .

Why is Java better than C programming?

Java is very popular among high schools and universities for an introductory language. Java syntax is very similar to the "classic" C and C++ languages, but Java is much more developer-friendly when it comes to error feedback and memory management.

When entire generations of programmers are introduced to the field with the same language, that language tends to become the "popular" one.

Describe the 3 levels of government?

depending on what country you live in, here in Canada we have municipal, provincial and then federal.

What is a 5 basic characteristics of computer?

supercomputers, mainframe computers, workstations, microcomputers and microcontrollers

Where does it begin when the microprocessor starts executes instructions?

During the start of execution, the microprocessor executes all instructions from BIOS. This in turn fetches the boot sector.

What are the warehouse key result area?

Key Result areaIn this phrase key means a vital, crucial element.

Key Result Area refers to general areas of outputs or outcomes for which the departments role is responsible.

in simple terms may be defined as primary responsibility of an individual ,the core area which each person is accountable

What is A part of a program in witch a variable may be accessed?

The part of a program in which a particular variable may be accessed is called the 'scope' of the variable.

In most cases, the scope of a variable is limited to the function within which it was created, or any function it is passed to as an argument.

You can also use global variables, which can be accessed from any part of the program and have 'global scope'. However, this is generally considered as poor programming practice, and should be used cautiously and sparingly as it tends to make code difficult to read and maintain.

What function for stack pointer of the register?

A stack pointer is a register pointing to the top of a stack. It supports the fundamental stack manipulations (push and pop) in an efficient manner.

Most micro processor hardware has build-in hardware support for stack pointers, typically both in form of dedicated stack pointer registers and in form of addressing modes which support the creation and maintenance of stacks through general-purpose pointer registers.

In software, many programming languages feature constructs suited for implementation of stack pointers within the high-level language (such as post-increment and pre-decrement operators in C).

What mark is used to separate arguments in a function?

That depends on the syntax rules of the language in which you are programming. However, the "," is the most usual separator).

Program for stop and wait protocol in c language?

/*************************************************************************************/

/* C program to implement stop and wait protocol*/

/* Download more programs at http://sourcecode4u.com/ */

/*************************************************************************************/

#include<stdio.h>

#include<conio.h>

#define MAXSIZE 100

typedef struct

{

unsigned char data[MAXSIZE];

}packet;

typedef enum{data,ack}frame_kind;

typedef struct

{

frame_kind kind;

int sq_no;

int ack;

packet info;

}frame;

typedef enum{frame_arrival}event_type;

typedef enum{true_false}boolean;

void frame_network_layer(packet *p)

{

printf("\n from network arrival");

}

void to_physical_layer(frame *f)

{

printf("\n to physical layer");

}

void wait_for_event(event_type *e)

{

printf("\n waiting for event n");

}

void sender(void)

{

frame s;

packet buffer;

event_type event;

printf("\n ***SENDER***");

frame_network_layer(&buffer);

s.info=buffer;

to_physical_layer(&s);

wait_for_event(&event);

}

void from_physical_layer(frame *f)

{

printf("from physical layer");

}

void to_network_layer(packet *p)

{

printf("\n to network layer");

}

void receiver(void)

{

frame r,s;

event_type event;

printf("\n ***RECEIVER***");

wait_for_event(&event);

from_physical_layer(&r);

to_network_layer(&r.info);

to_physical_layer(&s);

}

main()

{

sender();

receiver();

getch();

}

How can you calculate the c program running time through c plus plus coding?

This is a big question... but I'll try for a shortish answer. Try to do things in approximately the following order.

1) Use the right algorithms. Look into the Big O efficiency of any algorithms you are using, and make sure there aren't more efficient algorithms available.

2) Think about trading using more memory for a faster algorithm. Perhaps pre-computing tables of intermediate results.

3) Use a profiler to see where the bottle necks are and try improving them.

4) Optimize the inner most loops using assembly language to get the last little bit faster.

5) Run it on a faster computer.

6) Make it run in parallel across many computers or CPUs. This is especially good on the newer Intel chips where you have access to multiple CPUs on one chip. Distributed network computing sometimes is a good idea. Cloud computing is another possibility these days.

7) Make sure that C really is the right answer. It might not be in all cases.

A more specific question might yield a more specific answer.

What do you call a Program that runs Java byte code instruction?

Get the JDK & Bluej from net and the rest will be done by them.

Java byte codes are stored as *.class ; where "*" represents the class name, in your hard disk.

You can download BlueJ as well as JDK from the related link.

What are the different types of computer languages?

There are mainly four types of computer language-

1.High Level Language - the hardware access is abstracted away and managed more or less automatically, do code can focus on what the program needs to do rather than the lowest level details of how.

2.Low Level Language - languages which give full access to the underlying hardware and memory, but which as a result require memory allocation and other details to be handled manually. Generally most appropriate for device drivers and OS drivers which need this level of access.

3.Assembly Language - a language that can sensibly be written by people (at least for small programs) that directly matches the machine level language that the CPU understands. Writing code at this level you know exactly that the CPU will be doing. Generally most appropriate for very limited-power devices (e.g. light controllers, greetings cards).

4.Machine level language - what the computer actually understands

Within the high-level languages there are various further subdivisions - imperative, functional and logic programming. These all share the separation from handling memory allocation, but have a different structure and areas which they are particularly good for. Imperative languages focus on how to do things, and include Java and C#. Functional languages focus on what to do, and include LISP and F#. Logic languages focus on facts and determining the truth (or solutions to) other statements from known facts, and include Prolog.

Algorithm in creating insert method in linked list?

You sort a doubly linked list the same way you sort any other kind of list or array.

You implement a procedure to sort the list or array, and that procedure calls the appropriate insert, delete, or move methods of the list or array.

What is the need of an algorithm?

Not every program, no. An algorithm describes the procedural steps required to solve a particular problem using natural language. A program usually consists of many such algorithms, each of which can be defined as a function or a series of functions encapsulated by a class. The more trivial the function the less likely you need to write an algorithm.

C program to calculate area of circle?

/*to find the area of a circle*/

#include<stdio.h> #include<conio.h> main()

{

int r;

float a;

print f ("Enter r value \n");

scan f ("%d", &r);

a=3.14*r*r;

print f("area=%f",a);

}

2 Write an algorithm to print the factorial of a given number?

include<stdio.h>

main()

{

int n,fact=1;

clrscr();

printf("enter a no");

scanf("%d",&n);

while(n>0)

{

fact=fact*n;

n--;

}

printf("the factorial of given no is %d",fact);

getch();

}

Compare high level language and low level language?

a) The LLL is machine oriented and the HLL is problem oriented. b) The LLL is machine dependent but the HLL isn't. c) The HLL is much more user friendly than the LLL. d) The LLL has faster execution than HLL.

Who is the spirit of delphi?

The Oracle of Delphi in Greece is a place where people would go to talk to the prophetess about solutions to there problems. They would get a riddle as an answer. People traveled for long distances to visit the spirit.

What is unauthorised reproduction of legally protected computer programs?

Making copies for your friends.

Imitating computer programs with the original ones

It is referred to as piracy.