- #include<stdio.h>
- # include<conio.h>
- void main()
- {
- int a[100],i,n,max,min;
- clrscr();
- printf("How many elements in the array : ");
- scanf("%d",&n);
- printf("Enter the elements : \n");
- for(i=0;i<=n-1;i++)
- {
- scanf("%d",&a[i]);
- }
- max = a[0];
- min = a[0];
- for(i=1;i<=n-1;i++)
- {
- if(max<a[i])
- max = a[i];
- if(min>a[i])
- min = a[i];
- }
- printf("maximum element in the array is :%d\n ",max);
- printf("minimum element in the array is : %d\n",min);
- getch();
- }
▼
Monday 12 December 2016
How to Find Maximum & Minimum Element in the Array Program in C
Get Web Browser Name In C#
- public string GetWebBrowserName()
- {
- string WebBrowserName = string.Empty;
- try
- {
- WebBrowserName = HttpContext.Current.Request.Browser.Browser;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- return WebBrowserName;
- }
DOS Command (CMS) Create Folder Current Datetime and Move Files Shared Folder
- @echo off
- set hh=%time:~-11,2%
- set /a hh=%hh%+100
- set hh=%hh:~1%
- set dateseed=%date:~10,4%%date:~4,2%%date:~7,2%_%hh%
- %time:~3,2%%time:~6,2%
- if not exist "\\140.175.165.10\Sharing\Databasebackup\
- %dateseed%" mkdir "\\140.175.165.10\Sharing
- \Databasebackup\%dateseed%"
- copy D:\HELLO "\\140.175.165.10\Sharing\Databasebackup\
- %dateseed%"
Friday 9 December 2016
How to Use While LOOP in SQL
- DECLARE @TOTALV BIGINT
- DECLARE @InitialValue BIGINT
- SET @InitialValue=1
- SET @TOTALV=12
- WHILE (@InitialValue<=@TOTALV)
- BEGIN
- print @InitialValue
- SET @InitialValue=@InitialValue+1
- END
Tuesday 6 December 2016
SQL Function Get Total Time in HH:MM:SS
- CREATE FUNCTION [dbo].TotalTime
- (
- @StartTime DATETIME,
- @EndTime DATETIME
- )
- RETURNS Varchar(10)
- AS
- begin
- DECLARE @D VARCHAR(400)='31784'
- Declare @outTime Varchar(10);
- SELECT @D = DATEDIFF(SECOND,@StartTime,@EndTime)
- SELECT @outTime =CONVERT(VARCHAR(5), @D/60/60)
- + ':' + RIGHT('0' + CONVERT(VARCHAR(2), @D/60%60), 2)
- + ':' + RIGHT('0' + CONVERT(VARCHAR(2), @D % 60), 2)
- RETURN @outTime
- END
- GO
- SELECT dbo.TotalTime('2016-08-10 10:36:01.000','2016-08-10 19:25:45.000')
How to remove empty lines in text In Visual
Visual Studio has ability to delete empty lines in replace operation using regular expressions.
- Click Ctrl-H (quick replace)
- Tick "Use Regular Expressions"
- In Find specify
^$\n
- In Replace box delete everything.
- Click "Replace All"
All empty lines will be deleted.
Regular expression for empty line consist of
Beginning of line
^
End of line
$
Line break
\n
SQL Group With Group Total
- SELECT isnull(WO_status,0) as WO_status,
- (case when MwO.WO_status=1 then 'Open' when MwO.WO_status=2 then 'Close' when MWO.WO_status=3 Then 'Short Close'
- when MwO.WO_status=4 then 'Cancel'
- else 'Total' end) as statusR,
- count(*) as countValue
- FROM M_WorkOrder MwO
- inner join M_WorkorderDetails MwOd on MwO.WOID=MwOd.WOD_WOID
- INNER join BILL_KEYWORD BK on BK.id=MwOd.WOD_KEYID
- INNER join billing_from bf on bf.id=MwO.WO_CID
- where (MwOd.WOD_CUserID=15 or 15 =0 )
- group by WO_status WITH ROLLUP
Copy All tables with Data in Another Database
- CREATE PROCEDURE [dbo].[uspCreateCopyTables]-- GOALTEST,GOAL
- -- parameters for the stored procedure here
- @toDatabase VARCHAR(100)
- ,@fromDatabase VARCHAR(100)
- AS
- BEGIN
- -- SET NOCOUNT ON added to prevent extra result sets from
- SET NOCOUNT ON;
- DECLARE @fullTableList VARCHAR(8000);
- DECLARE @idx INT;
- DECLARE @tableName VARCHAR(8000);
- DECLARE @SQLQuery NVARCHAR(500);
- DECLARE @ParameterDefinition NVARCHAR(100);
- -- this query gives the list of table name existing in the database.
- SELECT @fullTableList = ISNULL(@fullTableList + ',' + TABLE_NAME, TABLE_NAME)
- FROM INFORMATION_SCHEMA.TABLES
- WHERE TABLE_TYPE = 'BASE TABLE';
- SELECT @idx = 1
- /* this section splits the table name from comma separated string and copies that table name from
- one database to another database*/
- IF LEN(@fullTableList) > 1
- OR @fullTableList IS NOT NULL
- WHILE @idx != 0
- BEGIN
- SET @idx = CHARINDEX(',', @fullTableList)
- IF @idx != 0
- SET @tableName = LEFT(@fullTableList, @idx - 1)
- ELSE
- SET @tableName = @fullTableList
- IF (LEN(@tableName) > 0)
- SET @SQLQuery = 'SELECT * INTO [' + @toDatabase + '].[dbo].[' + @tableName + '] FROM [' + @fromDatabase + '].[dbo].[' + @tableName + ']'
- EXEC (@SQLQuery)
- SET @fullTableList = RIGHT(@fullTableList, LEN(@fullTableList) - @idx)
- IF LEN(@fullTableList) = 0
- BREAK
- END
- END
- GO