Write a program in C# Sharp to insert the information of two books

  • برمجة سي شارب
  • برمجة

Write a program in C# Sharp to insert the information of two books. 
Test Data :

Insert the information of two books :                    
-----------------------------------------                
Information of book 1 :                                  
Input name of the book : BASIC                           
Input the author : S.TROELSTRA                           
                                                         
Information of book 2 :                                  
Input name of the book : C+                              
Input the author : G.RTRTG                               

Expected Output:

1: Title = BASIC,  Author = S.TROELSTRA                  
                                                         
2: Title = C+,  Author = G.RTRTG

الأجوبة

using System;

struct book 
{
	public string title;
	public string author;
}
public class strucExer9
{
public static void Main ()  
	{
	int nobook = 1000;  
	book [] books =new book [nobook];  
	int i,j,n=1,k=1;  
	Console.Write("\n\nInsert the information of two books :\n");
	Console.Write("-----------------------------------------\n");    
			for(j=0;j<=n;j++)
				{
			    Console.WriteLine("Information of book {0} :",k);

			    Console.Write("Input name of the book : ");
			    books[j].title= Console.ReadLine();
 
			    Console.Write("Input the author : ");
			    books[j].author= Console.ReadLine();
                k++;
			    Console.WriteLine();
			    }

	        for(i = 0;i <=n;i++)
	        {
            Console.WriteLine("{0}: Title = {1},  Author = {2}", i+1, books[i].title, books[i].author);
            Console.WriteLine();
	        }
	}
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...