Submit Search
Upload
Pattern printing programs
•
1 like
•
13,387 views
M
Mukesh Tekwani
Follow
C# - Pattern printing programs
Read less
Read more
Education
Report
Share
Report
Share
1 of 8
Download now
Download to read offline
Recommended
C# labprograms
C# labprograms
Jafar Nesargi
C#
C#
actacademy
C# console programms
C# console programms
Yasir Khan
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs
Abhishek Jena
.net progrmming part1
.net progrmming part1
Dr.M.Karthika parthasarathy
Isc computer project final upload last
Isc computer project final upload last
Arunav Ray
Java Practical File Diploma
Java Practical File Diploma
mustkeem khan
Java practical(baca sem v)
Java practical(baca sem v)
mehul patel
Recommended
C# labprograms
C# labprograms
Jafar Nesargi
C#
C#
actacademy
C# console programms
C# console programms
Yasir Khan
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs
Abhishek Jena
.net progrmming part1
.net progrmming part1
Dr.M.Karthika parthasarathy
Isc computer project final upload last
Isc computer project final upload last
Arunav Ray
Java Practical File Diploma
Java Practical File Diploma
mustkeem khan
Java practical(baca sem v)
Java practical(baca sem v)
mehul patel
.net progrmming part2
.net progrmming part2
Dr.M.Karthika parthasarathy
High performance web programming with C++14
High performance web programming with C++14
Matthieu Garrigues
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
Sumant Tambe
Whats new in_csharp4
Whats new in_csharp4
Abed Bukhari
C++ file
C++ file
Mukund Trivedi
Java practical
Java practical
shweta-sharma99
39927902 c-labmanual
39927902 c-labmanual
Srinivasa Babji Josyula
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diploma
mustkeem khan
Java_practical_handbook
Java_practical_handbook
Manusha Dilan
delegates
delegates
Owais Masood
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.
Nishan Barot
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
GeeksLab Odessa
Java PRACTICAL file
Java PRACTICAL file
RACHIT_GUPTA
Dotnet 18
Dotnet 18
dhruvesh718
C programs
C programs
Vikram Nandini
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
NAVER / MusicPlatform
CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)
Karan Bora
Java simple programs
Java simple programs
VEERA RAGAVAN
Data structures lab manual
Data structures lab manual
Syed Mustafa
Computer basics Intro
Computer basics Intro
Jafar Nesargi
Executive newswire 14
Executive newswire 14
Lukáš Havlín
брифы и мифы
брифы и мифы
Red Keds
More Related Content
What's hot
.net progrmming part2
.net progrmming part2
Dr.M.Karthika parthasarathy
High performance web programming with C++14
High performance web programming with C++14
Matthieu Garrigues
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
Sumant Tambe
Whats new in_csharp4
Whats new in_csharp4
Abed Bukhari
C++ file
C++ file
Mukund Trivedi
Java practical
Java practical
shweta-sharma99
39927902 c-labmanual
39927902 c-labmanual
Srinivasa Babji Josyula
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diploma
mustkeem khan
Java_practical_handbook
Java_practical_handbook
Manusha Dilan
delegates
delegates
Owais Masood
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.
Nishan Barot
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
GeeksLab Odessa
Java PRACTICAL file
Java PRACTICAL file
RACHIT_GUPTA
Dotnet 18
Dotnet 18
dhruvesh718
C programs
C programs
Vikram Nandini
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
NAVER / MusicPlatform
CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)
Karan Bora
Java simple programs
Java simple programs
VEERA RAGAVAN
Data structures lab manual
Data structures lab manual
Syed Mustafa
What's hot
(19)
.net progrmming part2
.net progrmming part2
High performance web programming with C++14
High performance web programming with C++14
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
Whats new in_csharp4
Whats new in_csharp4
C++ file
C++ file
Java practical
Java practical
39927902 c-labmanual
39927902 c-labmanual
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diploma
Java_practical_handbook
Java_practical_handbook
delegates
delegates
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java PRACTICAL file
Java PRACTICAL file
Dotnet 18
Dotnet 18
C programs
C programs
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)
Java simple programs
Java simple programs
Data structures lab manual
Data structures lab manual
Viewers also liked
Computer basics Intro
Computer basics Intro
Jafar Nesargi
Executive newswire 14
Executive newswire 14
Lukáš Havlín
брифы и мифы
брифы и мифы
Red Keds
Fallisia ilhamnia 09 xtkj2
Fallisia ilhamnia 09 xtkj2
fallisia15
Україна в полум'ї війни
Україна в полум'ї війни
zntulib
Evolucion del logo de los productos de marca
Evolucion del logo de los productos de marca
lorena sanabria
Sanjay Kedia
Sanjay Kedia
Sanjay Kedia
ころりんベイビークラス
ころりんベイビークラス
Yuka Motobe
LTG Mary Legere: Tips to Become an Effective Mentor
LTG Mary Legere: Tips to Become an Effective Mentor
Ltg Mary Legere
Taller gbi lunes segundo corte
Taller gbi lunes segundo corte
alexander castillo barbosa
เฉลยสถาบันหลักของชาติ M.5
เฉลยสถาบันหลักของชาติ M.5
Kunnai- เบ้
Engagement with the Indian Community in Logan
Engagement with the Indian Community in Logan
regionalpartnerships
Copyof resume navdeep-latest
Copyof resume navdeep-latest
Navdeep Singh
De guias ppodddddddd
De guias ppodddddddd
jgfhyrfd
The Film Industry
The Film Industry
AlexandraGHF
Viewers also liked
(15)
Computer basics Intro
Computer basics Intro
Executive newswire 14
Executive newswire 14
брифы и мифы
брифы и мифы
Fallisia ilhamnia 09 xtkj2
Fallisia ilhamnia 09 xtkj2
Україна в полум'ї війни
Україна в полум'ї війни
Evolucion del logo de los productos de marca
Evolucion del logo de los productos de marca
Sanjay Kedia
Sanjay Kedia
ころりんベイビークラス
ころりんベイビークラス
LTG Mary Legere: Tips to Become an Effective Mentor
LTG Mary Legere: Tips to Become an Effective Mentor
Taller gbi lunes segundo corte
Taller gbi lunes segundo corte
เฉลยสถาบันหลักของชาติ M.5
เฉลยสถาบันหลักของชาติ M.5
Engagement with the Indian Community in Logan
Engagement with the Indian Community in Logan
Copyof resume navdeep-latest
Copyof resume navdeep-latest
De guias ppodddddddd
De guias ppodddddddd
The Film Industry
The Film Industry
Similar to Pattern printing programs
Java parallel programming made simple
Java parallel programming made simple
Ateji Px
Golang dot-testing-lite
Golang dot-testing-lite
Richárd Kovács
C#.net
C#.net
vnboghani
ASP.NET
ASP.NET
chirag patil
Mouse programming in c
Mouse programming in c
gkgaur1987
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
Jaydip JK
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paper
Deepak Singh
srgoc
srgoc
Gaurav Singh
System programmin practical file
System programmin practical file
Ankit Dixit
Class 16: Making Loops
Class 16: Making Loops
David Evans
pattern-printing-in-c.pdf
pattern-printing-in-c.pdf
RSathyaPriyaCSEKIOT
Roslyn: el futuro de C# y VB.NET by Rodolfo Finochietti
Roslyn: el futuro de C# y VB.NET by Rodolfo Finochietti
.NET Conf UY
Roslyn: el futuro de C#
Roslyn: el futuro de C#
Rodolfo Finochietti
39927902 c-labmanual
39927902 c-labmanual
Srinivasa Babji Josyula
C# Variables and Operators
C# Variables and Operators
Sunil OS
Cluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in C
Steffen Wenz
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
Phil Calçado
Java Simple Programs
Java Simple Programs
Upender Upr
Cbse question-paper-computer-science-2009
Cbse question-paper-computer-science-2009
Deepak Singh
C Sharp Jn (3)
C Sharp Jn (3)
jahanullah
Similar to Pattern printing programs
(20)
Java parallel programming made simple
Java parallel programming made simple
Golang dot-testing-lite
Golang dot-testing-lite
C#.net
C#.net
ASP.NET
ASP.NET
Mouse programming in c
Mouse programming in c
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paper
srgoc
srgoc
System programmin practical file
System programmin practical file
Class 16: Making Loops
Class 16: Making Loops
pattern-printing-in-c.pdf
pattern-printing-in-c.pdf
Roslyn: el futuro de C# y VB.NET by Rodolfo Finochietti
Roslyn: el futuro de C# y VB.NET by Rodolfo Finochietti
Roslyn: el futuro de C#
Roslyn: el futuro de C#
39927902 c-labmanual
39927902 c-labmanual
C# Variables and Operators
C# Variables and Operators
Cluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in C
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
Java Simple Programs
Java Simple Programs
Cbse question-paper-computer-science-2009
Cbse question-paper-computer-science-2009
C Sharp Jn (3)
C Sharp Jn (3)
More from Mukesh Tekwani
Computer Science Made Easy - Youtube Channel
Computer Science Made Easy - Youtube Channel
Mukesh Tekwani
The Elphinstonian 1988-College Building Centenary Number (2).pdf
The Elphinstonian 1988-College Building Centenary Number (2).pdf
Mukesh Tekwani
Circular motion
Circular motion
Mukesh Tekwani
Gravitation
Gravitation
Mukesh Tekwani
ISCE-Class 12-Question Bank - Electrostatics - Physics
ISCE-Class 12-Question Bank - Electrostatics - Physics
Mukesh Tekwani
Hexadecimal to binary conversion
Hexadecimal to binary conversion
Mukesh Tekwani
Hexadecimal to decimal conversion
Hexadecimal to decimal conversion
Mukesh Tekwani
Hexadecimal to octal conversion
Hexadecimal to octal conversion
Mukesh Tekwani
Gray code to binary conversion
Gray code to binary conversion
Mukesh Tekwani
What is Gray Code?
What is Gray Code?
Mukesh Tekwani
Decimal to Binary conversion
Decimal to Binary conversion
Mukesh Tekwani
Video Lectures for IGCSE Physics 2020-21
Video Lectures for IGCSE Physics 2020-21
Mukesh Tekwani
Refraction and dispersion of light through a prism
Refraction and dispersion of light through a prism
Mukesh Tekwani
Refraction of light at a plane surface
Refraction of light at a plane surface
Mukesh Tekwani
Spherical mirrors
Spherical mirrors
Mukesh Tekwani
Atom, origin of spectra Bohr's theory of hydrogen atom
Atom, origin of spectra Bohr's theory of hydrogen atom
Mukesh Tekwani
Refraction of light at spherical surfaces of lenses
Refraction of light at spherical surfaces of lenses
Mukesh Tekwani
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
Mukesh Tekwani
Cyber Laws
Cyber Laws
Mukesh Tekwani
XML
XML
Mukesh Tekwani
More from Mukesh Tekwani
(20)
Computer Science Made Easy - Youtube Channel
Computer Science Made Easy - Youtube Channel
The Elphinstonian 1988-College Building Centenary Number (2).pdf
The Elphinstonian 1988-College Building Centenary Number (2).pdf
Circular motion
Circular motion
Gravitation
Gravitation
ISCE-Class 12-Question Bank - Electrostatics - Physics
ISCE-Class 12-Question Bank - Electrostatics - Physics
Hexadecimal to binary conversion
Hexadecimal to binary conversion
Hexadecimal to decimal conversion
Hexadecimal to decimal conversion
Hexadecimal to octal conversion
Hexadecimal to octal conversion
Gray code to binary conversion
Gray code to binary conversion
What is Gray Code?
What is Gray Code?
Decimal to Binary conversion
Decimal to Binary conversion
Video Lectures for IGCSE Physics 2020-21
Video Lectures for IGCSE Physics 2020-21
Refraction and dispersion of light through a prism
Refraction and dispersion of light through a prism
Refraction of light at a plane surface
Refraction of light at a plane surface
Spherical mirrors
Spherical mirrors
Atom, origin of spectra Bohr's theory of hydrogen atom
Atom, origin of spectra Bohr's theory of hydrogen atom
Refraction of light at spherical surfaces of lenses
Refraction of light at spherical surfaces of lenses
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
Cyber Laws
Cyber Laws
XML
XML
Recently uploaded
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
Thiyagu K
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
christianmathematics
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
TeacherCyreneCayanan
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
Celine George
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
VishalSingh1417
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
AreebaZafar22
Application orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
RamjanShidvankar
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University of Engineering & Technology, Jamshoro
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
Admir Softic
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
VishalSingh1417
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
Dr. Mazin Mohamed alkathiri
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Celine George
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
AyushMahapatra5
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
Celine George
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
National Information Standards Organization (NISO)
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
TechSoup
Recently uploaded
(20)
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
Application orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
Pattern printing programs
1.
Generated by Foxit
PDF Creator © Foxit Software http://www.foxitsoftware.com For evaluation only. Prof. Mukesh N Tekwani (9869 488 356) PATTERN PRINTING PROGRAMS 1. 1 23 456 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 using System; namespace Pattern1 { class Program { static void Main() { int num = 1; int i, j; for (i = 1; num <= 55; i++) { for (j = 1; j <= i; j++) { Console.Write(num.ToString() + " "); num++; } Console.Write("n"); } Console.ReadLine(); } } } Page 1 of 8
2.
Generated by Foxit
PDF Creator © Foxit Software http://www.foxitsoftware.com For evaluation only. Prof. Mukesh N Tekwani (9869 488 356) 2. // Program to print the following output: // 0 1 0 1 0 // 1 0 1 0 1 // 0 1 0 1 0 // 1 0 1 0 1 // 0 1 0 1 0 // Logic: // Consider first row as r = 0 and first col as c = 0. // From output, we observe that whenever r + c is an even no, // we display a 0 and whenever r + c is odd we display a 1. using System; namespace Pattern2 { class Program { static void Main() { int[,] x = new int[5, 5]; for (int r = 0; r < 5; r++) { for (int c = 0; c < 5; c++) { if ((r + c) % 2 == 0) x[r, c] = 0; else x[r, c] = 1; } } for (int r = 0; r < 5; r++) { for (int c = 0; c < 5; c++) { Console.Write("{0}t", x[r, c]); } Console.WriteLine(); } Console.ReadLine(); } } } Page 2 of 8
3.
Generated by Foxit
PDF Creator © Foxit Software http://www.foxitsoftware.com For evaluation only. Prof. Mukesh N Tekwani (9869 488 356) 3. I/p: Enter no. of rows 8 O/p: 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 using System; namespace Pattern6 { class Program { public static void Main() { int h; // height of triangle Console.WriteLine("Enter no. of rows "); h = int.Parse(Console.ReadLine()); Console.WriteLine("1"); for (int r = 1; r < h; r++) { for(int c = 0; c <= r; c++) { if((r + c) % 2 == 0) Console.Write("1t"); else Console.Write("0t"); } Console.WriteLine(); } Console.ReadLine(); } } } Page 3 of 8
4.
Generated by Foxit
PDF Creator © Foxit Software http://www.foxitsoftware.com For evaluation only. Prof. Mukesh N Tekwani (9869 488 356) 4. Enter no. of rows 8 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 1 0 1 0 1 1 using System; namespace Pattern7 { class Program { public static void Main() { int h; // height of triangle Console.WriteLine("Enter no. of rows "); h = int.Parse(Console.ReadLine()); for (int r = h; r >= 1; r--) { for (int c = 1; c <= r; c++) { if ((r + c) % 2 == 0) Console.Write("1t"); else Console.Write("0t"); } Console.WriteLine(); } Console.ReadLine(); } } } Page 4 of 8
5.
Generated by Foxit
PDF Creator © Foxit Software http://www.foxitsoftware.com For evaluation only. Prof. Mukesh N Tekwani (9869 488 356) 5. 1 22 333 4444 55555 using System; namespace Pattern100 { class Program { static void Main() { for (int r = 1; r <= 5; r++) { Console.WriteLine(" "); if (r >= 10) break; for (int c = 1; c <= 5; c++) { // Console.Write(" * "); Console.Write(r); if (c == r) goto loop1; } loop1: continue; } Console.ReadLine(); } } } Page 5 of 8
6.
Generated by Foxit
PDF Creator © Foxit Software http://www.foxitsoftware.com For evaluation only. Prof. Mukesh N Tekwani (9869 488 356) 6. //To print the pattern: // 1 2 3 4 // 5 6 7 8 // 9 10 11 12 using System; namespace Arrays4 { class TwoD { public static void Main() { int r, c; int[,] x = new int[3, 4]; for (r = 0; r < 3; ++r) { for (c = 0; c < 4; ++c) { x[r, c] = (r * 4) + c + 1; Console.Write(x[r, c] + " "); } Console.WriteLine(); } Console.ReadLine(); } } } Page 6 of 8
7.
Generated by Foxit
PDF Creator © Foxit Software http://www.foxitsoftware.com For evaluation only. Prof. Mukesh N Tekwani (9869 488 356) 7. Bubble sort of a numeric array Org list 12 -20 1 -32 65 -44 11 370 9 19 Sorted list -44 -32 -20 1 9 11 12 19 65 370 using System; namespace BubbleSort { class Program { static void Main() { int[] a = {12, -20, 1, -32, 65, -44, 11, 370, 9, 19}; int temp; int ind = 0; int n = a.Length; //display the original list Console.WriteLine("Org list"); for (int i = 0; i < n; i++) { Console.Write(a[i] + "t"); } // now sort do { ind = 0; for (int i = 0; i < n-1; i++) { if (a[i] > a[i + 1]) { temp = a[i]; a[i] = a[i + 1]; a[i + 1] = temp; ind = 1; // since swapping has taken ind = 1 } } } while (ind != 0); //display the sorted list Console.WriteLine("Sorted list"); for (int i = 0; i < n; i++) { Console.Write(a[i] + "t"); } Console.ReadLine(); } } } Page 7 of 8
8.
Generated by Foxit
PDF Creator © Foxit Software http://www.foxitsoftware.com For evaluation only. Prof. Mukesh N Tekwani (9869 488 356) 8. Exception – from question paper. WAP to display an error msg if name entered is consisting of more than 15 characters Please enter a name Mumbai, Maharashtra Name entered is too long using System; namespace ThrowingExceptions { class StringTooLong : Exception { } class MyCheck { static public string chkinput(string x) { if (x.Length > 15) throw (new StringTooLong()); return (x); } } class Program { static void Main() { string name; try { Console.WriteLine("Please enter a name "); name = Console.ReadLine(); MyCheck.chkinput(name); Console.WriteLine("Program ends here"); Console.ReadLine(); } catch (StringTooLong) { Console.WriteLine("Name entered is too long"); Console.ReadLine(); } } } } Page 8 of 8
Download now