answersLogoWhite

0

📱

C Programming

Questions related to the C Computer Programming Language. This ranges all the way from K&R to the most recent ANSI incarnations. C has become one of the most popular languages today, and has been used to write all sorts of things for nearly all of the modern operating systems and applications. It it a good compromise between speed, power, and complexity.

9,649 Questions

How do you write a javascript to swap two numbers without using third one?

By using the algorithm of bitwise EORing (Exclusive ORing) the numbers together:

If the two numbers are X and Y, then to swap them:

X = X EOR Y

Y = Y EOR X

X =X EOR Y

will swap them.

With knowledge of that algorithm, one then uses the syntax of Javascript to implement it.

What are Labeled loops?

Java supports labeled loops which allow you to break out of multiply nested loops by using the label on a break statement.

Here is an example:

FINDBIGGER:

for (i = 0; i < max1; i++)
{
for (j = 0; j < max2; j++)
{
if ( array[i] > array[j] )
break FINDBIGGER;
else if ( array[i] < array[j] )
break;
}
System.out.println("The break will end up here!");
}
System.out.println("The break FINDBIGGER will end up here!");


Note that technically this is not a goto - Java does not support gotos.

How can you read image with a DAT extension in C?

'dat' isn't common for extension for imagyes; but read/fread still usable

What do you mean by compiler?

Which converts high level language into machine understandable codes!

How do you do to shoot a 3 pointer?

well its easy for me but not for some people who arent as cool as me, all you do is act like you're shooting a free throw or a shot like that, but you throw it harder if you're weak then you should start working out you'll be able to shoot one soon' good luck being as good as me (it's hard to do so dont waste your time) see ya!

Is null node equal to leaf node?

No. A leaf node is a node that has no child nodes. A null node is a node pointer that points to the null address (address zero). Since a leaf node has no children, its child nodes are null nodes.

Write a c plus plus programs to find the sum of first n natural number and to display the number of terms edit?

Your question is not clear but i can write a program to find the sum of n natural numbers.

#include<iostream.h>

#include<conio.h>

int main()

{

long int res=0;

int last;

cout<<"enter the last number.";

cin>>last;

for(int i=0;i<=last;i++)

res=res+i;

cout<<"Result is "<<res<<endl;

return 0;

}

How can you write a Algorithm using switch case in C language with examples?

A switch is a selection statement. We don't use switch statements to create algorithms, although they can form part of an algorithm. The controlling expression must evaluate to a value of integral type or an enum. We can then define case labels for some or all possible evaluations of the control expression. If required, we can define a default label to catch any and all values not explicitly labelled. Upon evaluating the expression, if there is no corresponding case label, control passes to the next statement after the switch statement. Otherwise, control immediately passes to the corresponding case label and execution continues from there until a break, return or goto statement is encountered. If there is no break, return or goto statement before the next case label is encountered, execution "falls through" to the next case. When using fall through, the order of labels is important. Notably, the default label (if any) need not be the final label.

Write Client and server program in C language using UDP?

Write and run a client and a server program in C-language using UDP

Programm to calculate and display no of each differebt character present in a string suppose String is Mumbai output should be M2u1b1a1i1?

In Java

// the string we want to process

final String str = "Mumbai";

// convenience conversion to characters

final char[] str_chars = str.toCharArray();

// letters used to keep track of which characters we've counted

final Set letters = new HashSet();

// iterate through each character in str

for (int i = 0; i < str_chars.length; ++i) {

// store lower case version of ch so we only need to convert once

final char ch_l = Character.toLowerCase(str_chars[i]);

// only process this letter if we haven't done so yet

if (!letters.contains(ch_l)) {

// store letter

letters.add(ch_l);

// count number of times this letter is in str

int count = 1;

for (int j = i + 1; j < str_chars.length; ++j) {

if (ch_l == Character.toLowerCase(str_chars[j])) {

++count;

}

}

// output

System.out.format("%c%d", str_chars[i], count);

}

}

How do you draw a stock chart?

To view a stock's price chart, you need to use a service that offers them, like stockcharts.com. However, what you do with that information is entirely up to you, and takes experience and knowledge to make any use of it. This is a site that can help you learn how to use stock charts, spot chart patterns, formulate trading plans, etc.

http://onlycharts.com/

What does it mean for a city's function to be integrated?

To achieve a satisfactory level of co-ordination. City functions can be considered as nodes in a directed graph, or as inter-dependent variables of a system (the city that is). It follows that co-ordination is a must, for the system (city) to function as a whole.

How do you write the sum of a number and 100?

The algebraic expression is n + 100, where n is the unknown number.

Are instence variable are global or local variable?

Instance variables are not global nor local variables.

Variables in OOP are different from the counter parts in COBOL, FORTRAN, or C.

To define any variable in OOP, it must be defined within a class/struct, at instance or class level (static in C# or shared in VB.NET).

local variables usually referred to those defined within a method (of a class, instance-level or class-level) in OOP (object oriented programming).

global variables, to define one in OOP is difficult and violate the object oriented design principle. However, the singleton design pattern does address this issue.

Singleton pattern guarantees that the same instance (of that class) being the only one lives within your application (and globally accessible to that same instance), and hence the variables defined within this singleton may be treated as "global" variables

What is the C program for DFS and BFS?

Breadth First Search is the technique to find the shortest distance between some starting node and the remaining nodes of the graph. This shortest distance is the minimum number of edges traversed in order to travel from the start node to the specific node being examined. It is called BFS because the distances are given breadth wise. It is the faster search technique as the representation of the nodes and the edges are in the form of adjacency list representation. We can also use this technique for searching.

Depth-first search (DFS) is an algorithm for traversing or searching a tree, tree structure, or graph. One starts at the root (selecting some node as the root in the graph case) and explores as far as possible along each branch before backtracking.

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

-> This Program is to implement Depth First search.

-> Data Structers:

Graph:Adjacency List

Stack:Array

-> This program works in Microsoft vc++ 6.0 environment.

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

#include

int visit[100];

class graph

{

private:

int n;

graph*next;

public:

graph* read_graph(graph*);

void dfs(int); //dfs for a single node

void dfs(); //dfs of the entire graph

void ftraverse(graph*);

}*g[100];

int dfs_span_tree[100][100];

graph* graph::read_graph(graph*head)

{

int x;

graph*last;

head=last=NULL;

cout<<"Enter adjecent node ,-1 to stop:\n";

cin>>x;

while(x!=-1)

{

graph*NEW;

NEW=new graph;

NEW->n=x;

NEW->next=NULL;

if(head==NULL)

head=NEW;

else

last->next=NEW;

last=NEW;

cout<<"Enter adjecent node ,-1 to stop:\n";

cin>>x;

}

return head;

}

void graph::ftraverse(graph*h)

{

while(h!=NULL)

{

cout<n<<"->";

h=h->next;

}

cout<<"NULL"<

}

void graph::dfs(int x)

{

cout<<"node "<

visit[x]=1;

graph *p;

p=g[x];

while(p!=NULL)

{

int x1=p->n;

if(visit[x1]==0)

{

cout<<"from node "<

//Add the edge to the dfs spanning tree

dfs_span_tree[x][x1]=1;

dfs(x1);

}

p=p->next;

}

}

void graph::dfs()

{

int i;

cout<<"**********************************************************\n";

cout<<"This program is to implement dfs for an unweighted graph \n";

cout<<"**********************************************************\n";

cout<<"Enter the no of nodes ::";

cin>>n;

for(i=1;i<=n;i++)

g[i]=NULL;

for(i=1;i<=n;i++)

{

cout<<"Enter the adjacent nodes to node no. "<

cout<<"***************************************\n";

g[i]=read_graph(g[i]);

}

//display the graph

cout<<"\n\nThe entered graph is ::\n";

for(i=1;i<=n;i++)

{

cout<<" < "< ::";

ftraverse(g[i]);

}

for(i=1;i<=n;i++)

visit[i]=0; //mark all nodes as unvisited

cout<<"\nEnter the start vertex ::";

int start;

cin>>start;

for(i=1;i<=n;i++)

for(int j=1;j<=n;j++)

dfs_span_tree[i][j]=0;

cout<<"\nThe dfs for the above graph is ::\n";

dfs(start);

cout<<"\n\nThe required dfs spanning tree is ::\n";

for(i=1;i<=n;i++)

{

for(int j=1;j<=n;j++)

cout<

cout<

}

}

int main()

{

graph obj;

obj.dfs();

return 0;

}

How do you remove blarul c if nothing works and if you cannot open the file where avg found it?

You can try a program called The Cleaner Professional 4.1 found here: http://www.moosoft.com/products/cleaner/download/

Run the "evaluation" of it and it should sniff out all trojans/viruses and quarantine them. After that you need to go into the quarantine and delete them.