Pages

Tampilkan postingan dengan label c. Tampilkan semua postingan
Tampilkan postingan dengan label c. Tampilkan semua postingan

Rabu, 01 Juni 2016

C Program to display the different series output on the screen

C# Program to display the different series output on the screen

Program Statement:
Write a program which display the following output on the screen.
1 2 3 4 5
1 4 9 16 25
1 8 27 64 125

Solution:
 static void Main(string[] args)
{
for (int i = 1; i <= 5; i++)
Console.Write(i+" ");

Console.WriteLine();

for (int i = 1; i <= 5; i++)
Console.Write(i * i+" ");

Console.WriteLine();

for (int i = 1; i <= 5; i++)
Console.Write(i * i * i+" ");

Console.ReadLine();
}


Read More..

Sabtu, 28 Mei 2016

C Program which takes n values from user and then sort them using Bubble sort

C# Program which takes n values from user and then sort them using Bubble sort

Program Statement:
Write a program which takes n values from user and then sort them using Bubble sort

Solution:
 public class bubble
{
int n, x, y, z;
public void sort()
{
System.Console.Write(" Enter length of array : ");
n = Convert.ToInt32(System.Console.ReadLine());
int[] array = new int[n + 1];
int[] temp1 = new int[n + 1];
int[] temp2 = new int[n];
System.Console.WriteLine(" Enter {0} numbers : ", n);
for (x = 0; x < n; x++)
{
array[x] = Convert.ToInt32(System.Console.ReadLine());
}
for (y = n; y > 0; y--)
{
for (z = 0; z < y; z++)
{
if (array[z] > array[z + 1])
{
temp1[z] = array[z];
array[z] = array[z + 1];
array[z + 1] = temp1[z];
temp2[z] = array[z + 1];
}
else
{ temp2[z] = array[z]; }
}
}
Console.WriteLine(" >>>Ordered List<<< ");
for (int i = 0; i < n; i++)
{
Console.WriteLine(" {0}", temp2[i]);
}
}
}


Read More..

Rabu, 25 Mei 2016

Download C 2010 For Programmers Fourth Edition by DEITEL DEVELOPER SERIES

Download C# 2010 For Programmers Fourth Edition by DEITEL DEVELOPER SERIES
Download C# 2010 For Programmers Fourth Edition by DEITEL DEVELOPER SERIES



Welcome to Visual C#® 2010, C# 4 and the world of Microsoft® Windows® and Internet and web programming with Microsoft’s .NET 4 Framework! This book presents leadingedge computing technologies for professional software developers. We believe the book will give you an informative, challenging and entertaining C# educational experience. Below is the list of C# 2010 For Programmers Fourth Edition contents and download link

1. Introduction
2. Dive Into® Visual C# 2010 Express
3. Introduction to C# Applications
4. Introduction to Classes and Objects
5. Control Statements: Part 1
6. Control Statements: Part 2
7. Methods: A Deeper Look
8. Arrays
9. Introduction to LINQ and the List Collection
10. Classes and Objects: A Deeper Look
11. Object-Oriented Programming: Inheritance
12. OOP: Polymorphism, Interfaces and Operator Overloading
13. Exception Handling
14. Graphical User Interfaces with Windows Forms: Part 1
15. Graphical User Interfaces with Windows Forms: Part 2
16. Strings and Characters
17. Files and Streams
18. Databases and LINQ
19. Web App Development with ASP.NET
20. Searching and Sorting
21. Data Structures
22. Generics
23. Collections
24. GUI with Windows Presentation Foundation
25. WPF Graphics and Multimedia
26. XML and LINQ to XML
27. Web App Development with ASP.NET: A Deeper Look
28. Web Services
29. Silverlight and Rich Internet Applications
30. ATM Case Study, Part 1: Object-Oriented Design with the UML
31. ATM Case Study, Part 2: Implementing an Object-Oriented Design

Download C# 2010 for programmers 
Read More..

Convert C Coding into C Coding without using goto Statement

Convert C Coding into C# Coding without using goto Statement

Program Statement:
How many printf statements will be executed by this program and rewrite the following program without using goto statement.
void main( )
{
int i, j, k ;
for ( i = 1 ; i <= 3 ; i++ )
{
for ( j = 1 ; j <= 3 ; j++ )
{
for ( k = 1 ; k <= 3 ; k++ )
{
if ( i == 3 && j == 3 && k == 3 )
goto out ;
else
printf ( "%d %d %d ", i, j, k ) ;
}
}
}
out :
printf ( "Out of the loop at last!" ) ;
}

Solution:
 public class _check
{
int i, j, k, check=0;
public void c()
{
for (i = 1; i <= 3; i++)
{
for (j = 1; j <= 3; j++)
{
for (k = 1; k <= 3; k++)
{
if (i == 3 && j == 3 && k == 3)
{
Console.WriteLine(" Out of the loop at last ");
break;
}
else
{
Console.WriteLine(" {0},{1},{2}", i, j, k);
check = check + 1;
}

}
}
}
Console.WriteLine(" Loop iterated {0} times! ", check);
}
}


Read More..

C Program to find Area of Triangle

C# Program to find Area of Triangle

Program Statement:
If the lengths of the sides of a triangle are denoted by a, b, and c, then area of triangle is given by
Area = S?S(S-a)(S-b)(S-c)
where, S = ( a + b + c ) / 2

Solution:
 class sq
{
int a, b, c;
double S, Area, temp2;
public double s(double t)
{
double lb = 0, ub = t, temp = 0; int count = 50;
while (count != 0)
{
temp = (lb + ub) / 2;
if (temp * temp == t)
{ return temp; }
else if (temp * temp > t)
{ ub = temp; }
else
{ lb = temp; }
count--;
}
return temp;
}
public void cal()
{
Console.Write(" Enter value of a : ");
a = Convert.ToInt32(Console.ReadLine());
Console.Write(" Enter value of b : ");
b = Convert.ToInt32(Console.ReadLine());
Console.Write(" Enter value of c : ");
c = Convert.ToInt32(Console.ReadLine());
S = (a + b + c) / 2;
temp2 = (S * (S - a) * (S - b) * (S - c));
Area = S * s(temp2);
Console.WriteLine(" Area = {0} ", Area);
}
}


Read More..

Selasa, 17 Mei 2016

C Program to check number is prime or composite

C# Program to check entered number is prime or composite 

Program Statement:
Write a program that takes an integer as an input from user and prints if it is a prime or composite number.

Solution:
 static void Main(string[] args)
{
int num, i;
Console.WriteLine("Enter the number to check number is prime or composite");
num=Convert.ToInt32(Console.ReadLine());
i = 2;
while (i <= num - 1)
{
if (num % i == 0)
{
Console.WriteLine("composite number: "+num);
break;
}
i++;
}
if (i == num)
Console.WriteLine("prime number: " + num);
Console.ReadLine();

}


Read More..

Senin, 16 Mei 2016

C Program to Print Triangles

C# Program to Print Triangles

Program Statement:
Write a program to produce the following output:
A B C D E F G F E D C B A
A B C D E F     F E D C B A
A B C D E           E D C B A
A B C D                 D C B A
A B C                        C B A
A B                               B A
A                                      A

Solution:
 static void Main(string[] args)
{
int a, x, n = 71, o = 70, y = 1, c;
for (x = 1; x <= 7; x++)
{
for (a = 65; a <= n; a++)
{
Console.Write(Convert.ToChar(a));
}
if (x == 2)
o = 70;
for (c = 2; c < y; c++)
Console.Write(" ");
for (a = o; a >= 65; a--)
Console.Write((char)a);
Console.WriteLine();
n--;
o--;
y = y + 2;
}

Console.ReadLine();
}


Read More..

C program to Check leap Year Using Conditional Statement

C# program to Check Year is leap or not Using Conditional Statement 

Program Statement: 
Write a program using conditional operators to determine whether a year entered through the keyboard is a leap year or not.

Solution:
static void Main(string[] args)
{
int year;
Console.WriteLine("Enter Year");
year = Convert.ToInt32(Console.ReadLine());
Console.WriteLine( year % 4 == 0 ? "Entered year is leap" : "Not leap year");
Console.ReadLine();}


Read More..

Jumat, 13 Mei 2016

C Program to check entered value is character integer or special symbol

C# Program to check entered value is character, integer or special symbol

Program Statement:
Write a program which takes one value from user and check whether the entered value is character, integer or special symbol.

Solution:
 static void Main(string[] args)
{
char value;
int a;
Console.WriteLine("Enter value to check Character, integer or special symbols ");
value = Convert.ToChar(Console.ReadLine());
a=(int)value;
if (a >= 65 && a <= 90 || a >= 97 && a <= 122)
Console.WriteLine("Entered Value is Character");
else if(a>=48 && a<=57)
Console.WriteLine("Entered Value is Integer");
else if(a>=0 && a<=47 || a>=58&&a<=64 || a>=91&&a<=96 || a>=123&&a<=127)
Console.WriteLine("Entered Value is Special Symbols");
else
Console.WriteLine("Invlaid input :(");
Console.ReadLine();
}


Read More..

C Main Function for Calling all classes

C# Main Function for Calling all classes

 void Main_Fun()
{
int num;
Program obj = new Program();
Console.Clear();
Console.ForegroundColor = ConsoleColor.Green;
Console.BackgroundColor = ConsoleColor.DarkCyan;
Console.WriteLine(" *****VISUAL PROGRAMMING*****");
Console.WriteLine(" ****ASSIGNMENT # 1**** ");
Console.Write(" If Run Project (Y/N) ? ");
obj.choice = Convert.ToChar(Console.ReadLine());
if (obj.choice != Y && obj.choice != y)
{
Console.WriteLine(" See you Next Time");
}
else
{
Console.Write(" Enter the Question No. : ");
num = Convert.ToInt32(Console.ReadLine());
switch (num)
{
case 1:
obj.Question_1();
break;
case 2:
obj.Question_2();
break;
case 3:
obj.Question_3();
break;
case 4:
obj.Question_4();
break;
case 5:
obj.Question_5();
break;
case 6:
obj.Question_6();
break;
case 7:
obj.Question_7();
break;
case 8:
obj.Question_8();
break;
case 9:
obj.Question_9();
break;
case 10:
obj.Question_10();
break;
case 11:
obj.Question_11();
break;
case 12:
obj.Question_12();
break;
case 13:
obj.Question_13();
break;
case 14:
obj.Question_14();
break;
case 15:
obj.Question_15();
break;
case 16:
obj.Question_16();
break;
case 17:
obj.Question_17();
break;
case 18:
obj.Question_18();
break;
case 19:
obj.Question_19();
break;
case 20:
obj.Question_20();
break;
case 21:
obj.Question_21();
break;
case 22:
obj.Question_22();
break;
case 23:
obj.Question_23();
break;
case 24:
obj.Question_24();
break;
case 25:
obj.Question_25();
break;
case 26:
obj.Question_26();
break;
case 27:
obj.Question_27();
break;
case 28:
obj.Question_28();
break;
case 29:
obj.Question_29();
break;
case 30:
obj.Question_30();
break;
case 31:
obj.Question_31();
break;
case 32:
obj.Question_32();
break;
case 33:
obj.Question_33();
break;
case 34:
obj.Question_34();
break;
case 35:
obj.Question_35();
break;
case 36:
obj.Question_36();
break;
case 37:
obj.QUestion_37();
break;
case 38:
obj.Question_38();
break;
case 39:
obj.Question_39();
break;
case 40:
obj.Question_40();
break;
case 41:
obj.Question_41();
break;
case 42:
obj.Question_42();
break;
case 43:
obj.Question_43();
break;
case 44:
obj.Question_44();
break;
case 45:
obj.Question_45();
break;
default:
Console.WriteLine(" Invalid Program Number Try Again");
break;
}
}
}


Read More..

C Program to Print Fibonacci series

C# Program to Print Fibonacci series

Program Statement:
Write a program which prints the Fibonacci series using loop.
1 1 2 3 5 8 13 21 34 …

Solution:
 public class _fib
{
int f = 0, s = 1, n, fib = 0;
public void _show()
{
Console.WriteLine(" Print fibonacci series 0 1 1 2 3 5 8 13 ... ");
Console.Write(" Enter range of terms of fibonacci series : ");
n = Convert.ToInt32(Console.ReadLine());
Console.Write(" First {0} terms are : ", n);
for (int x = 0; x < n; x++)
{
if (x <= 1)
{ fib = x; }
else
{
fib = f + s;
f = s;
s = fib;
}
Console.Write("{0} ", fib);
}
Console.WriteLine(" ");
}
}


Read More..

Senin, 09 Mei 2016

C Simple Loop Program example to print characters

Simple Loop Problem to Print A B D H P

Problem Statement:
Write a program using for loop which prints the following output. (You have to find a pattern to print alphabetics in this order)
A B D H P

Solution:

static void Main(string[] args)
{
int i,j,ch=0,n;
Console.Write("A ");
for (i = 1; i <= 4; i++)
{
n = 1;
for (j = 1; j <= i; j++)
{
n = n * 2;
ch = 64 + n;
}
Console.Write((char)ch + " ");
}

Console.ReadLine();
}


Read More..

Professional C 2008

Professional C# 2008
Professional C# 2008 

If we were to describe the C# language and its associated environment, the .NET Framework, as the most important new technology for developers for many years, we would not be exaggerating. .NET is designed to provide a new environment within which you can develop almost any application to run on Windows, whereas C# is a new programming language that has been designed specifically to work with .NET. This Book Wrox Professional C# 2008 is best for learning C# and below its Content list.
Chapter 1: .NET Architecture
Chapter 2: C# Basics
Chapter 3: Objects and Types
Chapter 4: Inheritance
Chapter 5: Arrays
Chapter 6: Operators and Casts
Chapter 7: Delegates and Events
Chapter 8: Strings and Regular Expressions
Chapter 9: Generics
Chapter 10: Collections
Chapter 11: Language Integrated Query
Chapter 12: Memory Management and Pointers
Chapter 13: Reflection
Chapter 14: Errors and Exceptions
Chapter 15: Visual Studio 2008
Chapter 16: Deployment
Chapter 17: Assemblies
Chapter 18: Tracing and Events
Chapter 19: Threading and Synchronization
Chapter 20: Security
Chapter 21: Localization
Chapter 22: Transactions
Chapter 23: Windows Services
Chapter 24: Interoperability
Chapter 25: Manipulating Files and the Registry
Chapter 26: Data Access
Chapter 27: LINQ to SQL
Chapter 28: Manipulating XML
Chapter 29: LINQ to XML
Chapter 30: .NET Programming with SQL Server
Chapter 31: Windows Forms
Chapter 32: Data Binding
Chapter 33: Graphics with GDI+
Chapter 34: Windows Presentation Foundation
Chapter 35: Advanced WPF
Chapter 36: Add-Ins
Chapter 37: ASP.NET Pages
Chapter 38: ASP.NET Development
Chapter 39: ASP.NET AJAX
Chapter 40: Visual Studio Tools for Office
Chapter 41: Accessing the Internet
Chapter 42: Windows Communication Foundation
Chapter 43: Windows Workflow Foundation
Chapter 44: Enterprise Services
Chapter 45: Message Queuing
Chapter 46: Directory Services
Chapter 47: Peer-to-Peer Networking
Chapter 48: Syndication

Download


Read More..

C program to print nth iteration using loops

C# program to print 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 . . . nth iteration

Problem Statement:
Write a program using loop which prints the following output.
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 . . . nth iteration

Solution:
static void Main(string[] args)
{
int i, j, num;
Console.WriteLine("Enter value of num:");
num = Convert.ToInt32(Console.ReadLine());
for (i = 1; i <= num; i++)
{
for (j = 1; j <= i; j++)
Console.Write(i + " ");
}
Console.ReadLine();
}


Read More..

Array Problem Solving using C

Array Problem Solving using C#

Program Statement:
Create two arrays student_rollno and student_marks, both of same size. First array will save the rollnos of students and second array will save the marks of students against his rollno. e.g. if student_rollno[0] contains 197 then student_marks[0] will contains the marks of roll no 197.
You have to print the roll no of student with maximum marks.

Solution:
 public class stud
{
int n, max = 0, check = 0;
public void marks()
{
Console.Write(" Enter number of students : ");
n = Convert.ToInt32(Console.ReadLine());
int[] array1 = new int[n];
int[] array2 = new int[n];
for (int x = 0; x < n; x++)
{
Console.Write(" Enter Roll No : ");
array1[x] = Convert.ToInt32(Console.ReadLine());
Console.Write(" Enter Marks : ");
array2[x] = Convert.ToInt32(Console.ReadLine());
if (max < array2[x])
{
max = array2[x];
check = x;
}

}
Console.WriteLine(" Student {0} has maximum marks! ", array1[check]);
}
}


Read More..

Sabtu, 07 Mei 2016

C program to Find Worker efficiency using if else statement

C# program to find Worker efficiency using if_else statement 

Program statement:
In a company, worker efficiency is determined on the basis of the time required for a worker to complete a particular job. If the time taken by the worker is between 2 – 3 hours, then the worker is said to be highly efficient. If the time required by the worker is between 3 – 4 hours, then the worker is ordered to improve speed. If the time taken is between 4 – 5 hours, the worker is given training to improve his speed, and if the time taken by the worker is more than 5 hours, then the worker has to leave the company. If the time taken by the worker is input through the keyboard, find the efficiency of the worker.

Solution:
static void Main(string[] args)
{
double time;
Console.WriteLine("Enter the Workers Time to complete Task:");
time = Convert.ToDouble(Console.ReadLine());
if (time >= 2 && time <=3)
Console.WriteLine("Good! Worked Efficiently");
else if(time>3 && time<=4)
Console.WriteLine("Improved Your working Speed");
else if(time>4 && time<=5)
Console.WriteLine("Required Tranning to improve Speed");
else if(time>5)
Console.WriteLine("Leave this company");
else
Console.WriteLine("No Result for this input");
Console.ReadLine();
}


Read More..

program to Print Sum of factorial Series in C

C# program to Print Sum of factorial Series

Program Statement:
Write a program to display the sum of the following series.
2/1! + 4/3! + 6/5! + 8/7! + 10/9! + . . . + n/(n-1)!

Solution:
 public class factorial
{
int n;
public void ser()
{
double f, sum = 2, res = 1, up = 2;

Console.WriteLine(" Series = 2/1! + 4/3! + 6/5! + 8/7! + 10/9! + . . . + n/(n-1)!");
Console.WriteLine();
Console.Write(" Enter ending point : ");
n = Convert.ToInt16(Console.ReadLine());

for (int i = 2; i <= n; i++)
{
if (i % 2 == 1)
{
f = 1;
for (int x = i; x > 0; x--)
{ f = f * x; }
up = up + 2;
res = up / f;
sum = sum + res;
}
}
Console.WriteLine(" Sum : {0} ", sum);
Console.WriteLine();
}
}


Read More..

Kamis, 05 Mei 2016

C Program to print Rectangle

C# Program to print Rectangle $

Program Statement:
Write a program using for loop which prints the following output on the screen.
$$$$$$$$$$$

$                $

$                $

$                $

$$$$$$$$$$$

Solution:
 static void Main(string[] args)
{
for (int i = 1; i <= 11; i++)
Console.Write("$");
Console.WriteLine();
Console.WriteLine();

for (int i = 1; i <= 3; i++)

Console.WriteLine("$ $ ");

for (int i = 1; i <= 11; i++)
Console.Write("$");
Console.ReadLine();
}


Read More..

Rabu, 04 Mei 2016

C Program which takes n values from user and then sort them in ascending order

C# Program which takes n values from user and then sort them in ascending order

Program Statement:
Write a program which takes n values from user and then sort them in ascending order.

Solution:
 public class sort
{
int n, x, y, z;
public void s()
{
Console.Write(" Enter number of values you want to sort : ");
n = Convert.ToInt32(Console.ReadLine());
int[] arr = new int[n];
for (int i = 0; i < n; i++)
{
Console.Write(" Enter number : ");
arr[i] = Convert.ToInt32(Console.ReadLine());
}
for (x = 0; x < n; x++)
{
for (y = x + 1; y < n; y++)
if (arr[x] > arr[y])
{
int temp;
temp = arr[y];
arr[y] = arr[x];
arr[x] = temp;
}
}
Console.WriteLine(" >>>Ascending Order<<< ");
for (z = 0; z < n; z++)
{
Console.WriteLine(" {0}", arr[z]);
}
}
}


Read More..

Selasa, 03 Mei 2016

C Program to Print Triangle in Square

C# Program to Print Triangle in Square

Program Statement:
Write a program which display the following output on the screen.
####$####
###$#$###
##$###$##
#$#####$#
$#######$

Solution:
 class shape
{
int x, y;
public void sh()
{
Console.WriteLine();
for (x = 1; x <= 5; x++)
{
for (y = 1; y <= 5 - x; y++)
{
Console.Write("#");
}
Console.Write("$");
for (y = 2; y <= x * 2 - 1; y++)
{
Console.Write("#");
}
Console.Write(" $");
for (y = 1; y <= 5 - x; y++)
{
Console.Write("#");
}
Console.WriteLine(" ");
}
}
}


Read More..