answersLogoWhite

0

C Sharp

C Sharp is a programming language developed by Microsoft Corporation. It is designed to be a simple, general-purpose, modern, object-oriented programming language. The latest version is C# 4.0. It is designed for developing applications for both embedded and hosted systems.

343 Questions

Algorithm for converting prefix to postfix using stack?

/*Infix to Prefix And Postfix*/

/*Assignment:5*/

/*Roll No:2102*/

#include<stdio.h>

#include<conio.h>

#include<string.h>

#define MAX 15

#define true 1

#define false 0

/*Structure Decvlaration*/

typedef struct

{

char data[MAX];

char top;

}STK;

/*Function Declarations*/

void input(char str[]);

void intopre(char str1[],char pre[]);

void intopost(char str1[],char post[]);

int isoperand(char sym);

int prcd(char sym);

void push(STK *s1,char elem);

int pop(STK *s1);

int empty(STK *s2);

int full(STK *s2);

void dis(char str[]);

void main()

{

STK s;

int cs,ans;

char str[MAX],pre[MAX],post[MAX];

clrscr();

do /*Using Do-while Loop*/

{

clrscr();

printf(" -----Program for Expressions-----");

printf(" Input The String:");

printf(" MENU: ");

printf("1.Infix to Prefix ");

printf("2.Infix to Postfix");

printf(" 3.Exit");

cs=getche();

switch(cs) /*Using Switch Case*/

{

case 1:

intopre(str,pre);

break;

case 2:

intopost(str,post);

break;

case 3:

break;

default:

printf(" Enter a Valid Choise!"); /*Default Case*/

break;

}

printf(" Do you wish to Continue?(y/n)");

ans=getche();

}while(ans=='y'ans=='Y'); /*Condition for Do-while loop*/

getch();

}

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

/*To Input String*/

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

void input(char str)

{

printf("Enter the Infix String:");

scanf("%s",str);

}

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

/*To Covert Infix To Prefix*/

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

void intopre(STK s1,char str1[],char pre[])

{

int len,flag;

len=strlen(str1);

int check=0,cnt=len-1,pos=0;

char elem;

while(cnt>=0) /*while condition*/

{

flag=0;

if(isoperand(str1[cnt])) /*Checking for Operand*/

{

printf("%c",str1[cnt]);

cnt--;

pos++;

}

else

{

check=prcd(str1[cnt]);

while(check==false)

{

pre[pos]=str1[cnt];

flag=1;

pos++;

cnt--;

}

if(flag==0)

{

elem=pop(&s1);

printf("%c",elem);

}

}

}

}

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

/*To Convert Infix To Postfix*/

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

void intopost(STK s1,char str1[],char post[])

{

int len;

len=strlen(str1);

int check=0,cnt=len-1,pos=0;

}

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

/*To Check For Operand*/

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

int isoperand(char sym)

{

if('A'<sym<'Z''a'<sym<'z')

return(true);

return(false);

}

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

/*To Check The Precedence*/

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

int prcd(char sym)

{

}

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

/*To Display String*/

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

void dis(char str[])

{

}

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

/*Push Function Definition*/

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

void push(STK *s1,char elem)

{

if(!full(s1))

{

s1->top++; /*Incrementing top*/

s1->data[s1->top]=elem; /*Storing element*/

}

else

printf("

Stack is Full!");

}

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

/*Full Function Definition*/

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

int full(STK *s2)

{

if(s2->top==MAX) /*Condition for Full*/

return(true);

return(false);

}

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

/*Pop Function Definition*/

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

int pop(STK *s1)

{

char elem;

if(!empty(s1))

{

elem=s1->data[s1->top]; /*Storing top stack element in elem*/

s1->top--; /*Decrementing top*/

return(elem);

}

return(false);

}

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

/*Empty Function Definition*/

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

int empty(STK *s2)

{

if(s2->top==-1) /*Condition For Empty*/

return(true);

return(false);

}

When was the programming language C Sharp initially developed or released?

It was developed by Microsoft during 2000-01. A beta version was released in October 2001 and a full version was out in April 2002.

During the development of the .NET Framework, the class libraries were originally written using a managed code compiler system called Simple Managed C (SMC). In January 1999, Anders Hejlsberg formed a team to build a new language at the time called Cool, which stood for "C-like Object Oriented Language". Microsoft had considered keeping the name "Cool" as the final name of the language, but chose not to do so for trademark reasons. By the time the .NET project was publicly announced at the July 2000 Professional Developers Conference, the language had been renamed C#, and the class libraries and ASP.NET runtime had been ported to C#.

C# First Language specification was given on December 2001

and its First Version was released on January 2002

Disadvantages of multiple inheritance?

If a single class inherits from two other classes, each of which has the same function implemented, how can we tell which one to call? This ambiguity often leads to non-deterministic behavior of classes in multiple inheritance languages.

What is significance attached to the main function in C programming?

The main function in C++ is no different to any other function, other than it is the only required function; it defines the entry point of the application. The minimal main function (and therefore the minimal C++ program) is:

#include <stdio.h>

int main()

{

return(0);

}

The main function must always return an integer to the caller (even if not required by the caller). A return value of zero is usually used to indicate the program terminated successfully, however it is up to the programmer to decide what the return value actually means to the caller. It is common to return (-1) upon an unrecoverable error.

Shell script to add two numbers?

echo "enter the value of a"

read a

echo "enter the value of b"

read b

c=`expr $a + $b`

echo "the sum of a and b is $c"

Or, alternatively, one could also...

#!/bin/sh

A=5

B=10

C=`echo "$A + $B"|bc -l`

echo "$A + $B = $C"

The above examples illustrate the use of back ticks to fork a child process in shell, however the first example uses the 'expr' command to perform the arithmetic while the second example uses the 'bc' command to perform the calculation. As is nearly always the case in Unix or Linux, there are multiple methods of arriving at the same correct solution.

While the wonderful and all powerful Perl language is perhaps, technically, not a shell, it is theoretically possible to accomplish this goal in Perl as well. Let me see now, to make this example as educational as possible, I'll use a couple of subscripts of the array @array to store our values and an off-the-shelf printf function to display the results of our calculations...

perl -e '@array = (5, 10); printf("%s + %s = %s\n", $array[1], $array[0], ($array[0]+$array[1]));'

As the purpose of this site is to teach, I briefly entertained and then discarded a notion to shoot for maximum obfuscation. Larry, Randy and Nathan will be proud of me I hope. :)

Naturally, there are numerous other ways to accomplish this goal in Linux.

Difference between static and non static constructor?

A static constructor is used to do anything you need done before any static methods are called such as static variable initialization. In Java (as in C#) when a static constructor is called is non-deterministic but will always be called before a static method on the same class.

In what ways do you think you can make a contribution to our company?

When you are asked in what ways you can make a contribution to a company, you should discuss your special skills, and talents. As you list these skills, make sure to relate them to how they will be beneficial to the company.

Write a program in C programming language that will add two integer numbers using linked list?

#include<stdio.h>

int add(int pk,int pm);

main()

{

int k ,i,m;

m=2;

k=3;

i=add(k,m);

printf("The value of addition is %d\n",i);

getch();

}

int add(int pk,int pm)

{

if(pm==0) return(pk);

else return(1+add(pk,pm-1));

}

</stdio.h>

How exception handling mechanism can be used for debugging a program in java?

Trapping and handling of runtime errors is one of the most crucial taska ahead of any programmer. AS A DEVELOPER, YOU SOMETIMES SEEM TO SPEND MORE TIME CHECKING FOR ERRORS AND HANDLING THEM THEN YOU DO ON THE CORE LOGIC OF THE ACTUAL PROGRAM.

What is an actual parameter?

A formal perimeter refers to an identifier that is used in a method to stand for the value that is passed into the method by a caller. An actual perimeter on the other hand refers to the actual value that is passed into the method by a caller.

What are the main tasks of the colon?

i know of 3 don't know the fourth one absorption, secretion, and elimination.

What is the full form of ASAX?

The answer depends on the context. It could mean:

Alto saxophone (on musical scores)

Active Server Page (.NET framework)

Active Server Application Extended

How do you explain characteristics of algorithm?

Characteristics of algorithms are:

Finiteness: terminates after a finite number of steps

Definiteness: rigorously and unambiguously specified

Input: valid inputs are clearly specified

Output: can be proved to produce the correct output given a valid input

Effectiveness: steps are sufficiently simple and basic.

What should we do if we have to find explanation of beep codes?

Beep codes are typically issued by the BIOS to denote a severe problem that prevents the system from booting properly. You can decode these beeps by visiting the motherboard or system manufacturer's website.

What is mean by selection sort?

Selection sort works by looking for the largest value in a set and swapping it with the last value. The last value can now be ignored since it is now in place. The process repeats with the remainder of the set. After repeated passes, the remainder of the set will have only one item, the smallest value, at which point all the values will be in sorted order.

The algorithm is similar to that of bubblesort, but is generally more efficient because there can only be one swap at most for each iteration of the algorithm. With bubble sort, there may be multiple swaps per iteration. However, while the number of comparisons is the same for both algorithms, bubblesort can be optimised to minimise the number of iterations required and thus minimise the number of comparisons. Nevertheless, swapping is a more expensive operation than comparing, thus selection sort is generally faster.

Neither algorithm is suitable for sorting large sets of data.

What is formal parameter in c?

A variable declared in the header of a method whose initial value is obtained during method invocation (using the actual parameter). So: int method(/*Formal Parameters*/){ //Method Actions return 0; }

A program of reverse a number using recursion in C?

(in C#)

string Reverse (string input) {

There are two cases; the recursive case and the trivial case.

The trivial case is when the string has zero or one character. In this case, the reversal of the string is the same.

if (input.Length <=1 ) return input;

For any other string, you can reverse it by reversing the "tail" of the string, and then putting the "head" on the end.

else return Reverse (input.Substring(1)) + input[0];

}

What is the difference between abstract class and static class?

Abstract ClassAn abstract class is an abstract data type (ADT) or abstract base class (ABC). It is a conceptual class. Unlike concrete classes which can serve as generic base classes for more specialised classes, ADTs can only be instantiated through derivation. For instance, circles, triangles and rectangles are all types of shape and all can therefore be derived from a shape base class. However you wouldn't want consumers instantiating a generic shape since it would be impossible to work with a shape without knowing what type of shape it actually was. Thus the shape class is an ideal candidate for an ADT.


An ADT is simply a base class that has one or more pure-virtual methods. A pure-virtual method is similar to a virtual method except that the ADT need not provide any implementation for that method. Even if it does provide a generic implementation, all derivatives must override that method, even if only to call the generic base class method. This ensures that all derivatives provide their own specialised implementations. A derivative that does not provide an implementation for all the pure-virtual methods it inherits becomes an ADT itself. However any implementations that it does provide can subsequently be inherited by its derivatives (those methods effectively become virtual methods rather than a pure-virtual method). Only classes that provide or inherit a complete implementation of all pure-virtual methods can physically be instantiated.

Going back to our shape class, the shape::draw() method is an ideal candidate for a pure-virtual function since it is impossible to draw a shape without knowing what type of shape it is. However, a circle class would be expected to know how to draw itself thus it can provide the specific implementation for drawing circles. Similarly, rectangles and triangles will provide their own specific implementations. This then makes it possible to store a collection of generic shapes and have them draw themselves without the need to know their actual type; as with all virtual methods, the derivatives behave according to their actual type.


Static ClassA static class is simply a class that contains nothing but static members. Like an abstract base class you cannot instantiate a static class, but because the members are static they can be accessed without the need to instantiate an object of the class. Static classes are useful in that they provide global functionality without the need to declare global variables and external functions that operate upon those variables (the variables can effectively be hidden in the class, thus limiting their exposure). They can be likened to a singleton class insofar as there can only ever be one instance of each data member. However, a static class is instantiated at compile time and exists for the entire duration of a program, whereas a singleton can normally be created and destroyed at any time. In terms of memory consumption alone, a singleton is far more efficient than a static class, which is one of the reasons static classes are often frowned upon.


Note that static classes have no need for any constructors, operators or destructors (they have no this pointer since there can never be any instances of the class), thus the compiler-generated default constructor, copy constructor, destructor and assignment operator must all be declared private. Some languages may do this automatically but in C++ (which has no concept of static classes) you must explicitly declare them as such.


While static classes do have their uses, bear in mind that the point of having a class in the first place is in order to instantiate independent objects from the class. Thus the only time you should ever use a static class is when the class data members must exist for the entire duration of the program and you want to ensure there can only ever be one instance of those members. However, for memory efficiency alone, a singleton class would be the preferred method. Moreover, if some or all of the static methods are closely associated with a generic class, then it makes more sense to encapsulate those methods as static members of that generic class rather than as a completely separate static class.

How do you prepare for Dot net certification?

Dot net is most popular programming language for Microsoft .NET Framework. You can go through from the book . Just see professional book by Wrox. The best way is also for industrial training and more you should go through practical often. Now a day online classes are also available.

What is CSharp?

The C# sharp programming language is a relatively young programming language created by Microsoft. It is heavily influenced by another (and older) programming language called C++, which in itself is often regarded as a succesor to the programming language C. As far to my knowledge C# is only used in order to develop .NET based applications.

How should you Swap 2 numbers in a single line?

Swapping two values in a single statement is made possible through a series of three XOR/assign operations, alternating the operands.


Consider the following declarations:


int x = 0;

int y = 1;


The following statement will swap the values of x and y:


x ^= y ^= x ^= y; // swap



The same statement implemented as a function:


void swap(int &x, int &y){ x ^= y ^= x ^= y; }





What is the C sharp programming language?

While I generally prefer "C" as a more robust language, I also consider anything that is released by Microsoft to be unreliable and likely to fail. Java is the product of Sun Microsystems, and has a very good reputation. While I'm not a Java programmer, I have heard nothing but good reports about Java.

AnswerThese two languages are functionally nearly identical. If one can do something, you can bet that the other can do it just as easily. Each has a huge library of built in packages full of classes to help you solve any problem you need to handle.

How do you write a program in c sharp to identify whether a character vowels and consonants?

<html>

<head>

<title>Assignment1</title>

</head>

<body>

Enter the String:<br><br>

<form action="ass1.php" method="post">

Name: <input type="text" name="fname" />

<input type="submit" name="Submit" />

</form>

<?php

if(isset($_POST['Submit']))

{

$vowels=array("a","e","i","o","u");

$length=strlen($_POST['fname']);

$count = 0;

for ($i = 0; $i!= $length; $i++)

{

if (array_search($_POST['fname'][$i], $vowels))

{

$count++;

}

}

}

echo 'There are ('.$count.') vowels in the string ('. $_POST['fname'].')';

?>

</body>

</html>

Write a program to merge two linked list and find out the running time?

#include<stdio.h>

#include<conio.h>

#define null 0

void create();

void display();

void insert();

void delet();

void erase();

void create2();

void display2();

void insert2();

void delet2();

void erase2();

void link1();

void link2();

void merge();

struct node

{

int info;

struct node *next;

}*start,*ptr,*temp,*prev;

struct node2

{

int info;

struct node2 *nex;

}*start2,*ptr2,*temp2,*prev2;

void main()

{

int op;

clrscr();

do

{

printf("\n1.link1\n2.link2\n3.merge\n4.exit");

printf("\nEnter your option");

scanf("%d",&op);

switch(op)

{

case 1:

link1();

break;

case 2:

link2();

break;

case 3:

merge();

break;

case 4:

break;

default:

printf("\nEnter correct option");

}

}while(op!=4);

getch();

}

void create()

{

int data;

printf("\nEnter the data");

scanf("%d",&data);

do

{

ptr=malloc(sizeof(struct node));

ptr->info=data;

ptr->next=NULL;

if(start==NULL)

start=ptr;

else

{

temp=start;

while(temp->next!=NULL)

{

temp=temp->next;

}

temp->next=ptr;

}

printf("\nEnter the data & Press 0 to terminate");

scanf("%d",&data);

}while(data!=0);

}

void display()

{

temp=start;

if(start==NULL)

printf("\nList is empty");

else

{

printf("\nElements of list:\n");

while(temp->next!=NULL)

{

printf("%d\t",temp->info);

temp=temp->next;

}

printf("%d\t",temp->info);

}

}

void insert()

{

int data,pos;

printf("\nEnter data & position to insert the element");

scanf("d",&data,&pos);

temp=start;

ptr=malloc(sizeof(struct node));

ptr->info=data;

while(temp->next!=NULL)

{

if(temp->info==pos)

{

ptr->next=temp->next;

temp->next=ptr;

break;

}

else

temp=temp->next;

}

if(temp->next==NULL)

{

temp->next=ptr;

ptr->next=NULL;

}

}

void delet()

{

int pos,flag=0;

if(start==NULL)

printf("List is empty");

else

{

printf("Enter element to be deleted");

scanf("%d",&pos);

temp=start;

if(start->info==pos)

{

flag=1;

start=start->next;

free(temp);

}

else

{

while(temp->next!=NULL)

{

prev=temp;

temp=temp->next;

if(temp->info==pos)

{

flag=1;

prev->next=temp->next;

free(temp);

break;

}

}

}

if(flag==0)

printf("\nElement is not present in list");

}

}

void erase()

{

if(start==NULL)

printf("\nList is empty");

else

{

while(start->next!=NULL)

{

temp=start;

start=start->next;

free(temp);

}

temp=start;

start=start->next;

free(temp);

printf("list is erased");

}

}

void create2()

{

int data;

printf("\nEnter the data");

scanf("%d",&data);

do

{

ptr2=malloc(sizeof(struct node2));

ptr2->info=data;

ptr2->nex=NULL;

if(start2==NULL)

start2=ptr2;

else

{

temp2=start2;

while(temp2->nex!=NULL)

{

temp2=temp2->nex;

}

temp2->nex=ptr2;

}

printf("\nEnter the data & Press 0 to terminate");

scanf("%d",&data);

}while(data!=0);

}

void display2()

{

temp2=start2;

if(start2==NULL)

printf("\nList is empty");

else

{

printf("\nElements of list:\n");

while(temp2->nex!=NULL)

{

printf("%d\t",temp2->info);

temp2=temp2->nex;

}

printf("%d\t",temp2->info);

}

}

void insert2()

{

int data,pos;

printf("\nEnter data & position to insert the element");

scanf("d",&data,&pos);

temp2=start2;

ptr2=malloc(sizeof(struct node2));

ptr2->info=data;

while(temp2->nex!=NULL)

{

if(temp2->info==pos)

{

ptr2->nex=temp2->nex;

temp2->nex=ptr2;

break;

}

else

temp2=temp2->nex;

}

if(temp2->nex==NULL)

{

temp2->nex=ptr2;

ptr2->nex=NULL;

}

}

void delet2()

{

int pos,flag=0;

if(start2==NULL)

printf("List is empty");

else

{

printf("Enter element to be deleted");

scanf("%d",&pos);

temp2=start2;

if(start2->info==pos)

{

flag=1;

start2=start2->nex;

free(temp2);

}

else

{

while(temp2->nex!=NULL)

{

prev2=temp2;

temp2=temp2->nex;

if(temp2->info==pos)

{

flag=1;

prev2->nex=temp2->nex;

free(temp2);

break;

}

}

}

if(flag==0)

printf("\nElement is not present in list");

}

}

void erase2()

{

if(start2==NULL)

printf("\nList is empty");

else

{

while(start2->nex!=NULL)

{

temp2=start2;

start2=start2->nex;

free(temp2);

}

temp2=start2;

start2=start2->nex;

free(temp2);

printf("list is erased");

}

}

void link1()

{

int op;

start=NULL;

do

{

printf("\n1.create\n2.display\n3.insert\n4.delete\n5.erase\n6.exit");

printf("\nEnter your option");

scanf("%d",&op);

switch(op)

{

case 1:

create();

break;

case 2:

display();

break;

case 3:

insert();

break;

case 4:

delet();

break;

case 5:

erase();

break;

case 6:

break;

default:

printf("\nEnter correct option");

}

}while(op!=6);

getch();

}

void link2()

{

int op;

start2=NULL;

do

{

printf("\n1.create\n2.display\n3.insert\n4.delete\n5.erase\n6.exit");

printf("\nEnter your option");

scanf("%d",&op);

switch(op)

{

case 1:

create2();

break;

case 2:

display2();

break;

case 3:

insert2();

break;

case 4:

delet2();

break;

case 5:

erase2();

break;

case 6:

break;

default:

printf("\nEnter correct option");

}

}while(op!=6);

getch();

}

void merge()

{

if(start==NULL)

{

start=start2;

}

else

{

temp=start;

while(temp->next!=NULL)

{

temp=temp->next;

}

temp->next=start2;

}

temp=start;

if(start==NULL)

printf("\nList is empty");

else

{

printf("\nElements of list:\n");

while(temp!=NULL)

{

printf("%d\t",temp->info);

temp=temp->next;

}

}

getch();

}

the above listed program is definitely good one, here is a program which just does merging job, http://www.refcode.net/2013/02/merging-linked-lists.html