Thursday 28 December 2017

Learn C language Part 22 Calculator using switch CASE And Function in c







#include <stdio.h>

#include <conio.h>



void plus(float a,float b);

void minus(float a,float b);

void multiply(float a,float b);

void divide(float a,float b);





main()

{



char c,d;

float x,y;



l1:

printf("------Press + for addition------");

printf("\n------Press - for Subtraction------");

printf("\n------Press * for Multiplication------");

printf("\n------Press / for Division------");



printf("\nSelect An Operation: ");

c=getchar();



printf("\nEnter 1st Number: ");

scanf("%f",&x);

printf("\nEnter 2nd Number: ");

scanf("%f",&y);





switch(c)

{



case '+':

plus(x,y);

break;





case '-':

minus(x,y);

break;





case '*':

multiply(x,y);

break;





case '/':

divide(x,y);

break;





default:

printf("\nInvalid Operation selected\n");

goto l1;

break;





}//switch scope end..............

l2:

printf("\n\n\n\nDo you want to continue....\n press (y/n)");

scanf(" %c",&d);

getchar();



if(d=='y'|| d=='Y')

{

printf("------------------------------------------------------------");



printf("\n\n\n\n");

printf("------------------------------------------------------------");



goto l1;



}

else if(d=='n'|| d=='N')



{

printf("Good bye......\n Press any key to exit!");

}



else

{

printf("Invalid Command !!!\n");

goto l2;

}



}//main function end..................................





void plus(float a,float b)

{

printf("%.2f",a+b);

}



void minus(float a,float b)

{

printf("%.2f",a-b);

}



void multiply(float a,float b)

{

printf("%.2f",a*b);

}

void divide(float a,float b)

{

printf("%.2f",a/b);

}












Learn C language Part 21 Introduction to Function, Difference b/w void ...







#include <stdio.h>

#include <conio.h>



int sum(int a,int b);



main()

{



int z,y,x;



printf("Enter the number: ");

scanf("%d",&x);

printf("Enter the 2nd number: ");

scanf("%d",&y);



z=sum(x,y);





printf("%d",z);





}

//main method end..............



int sum(int a,int b)

{

return a+b;

}

----------------------------------------------------------------------------------------------------------------

#include <stdio.h>
#include <conio.h>

void sum(int a,int b);

main()
{

int y,x;

printf("Enter the number: ");
scanf("%d",&x);
printf("Enter the 2nd number: ");
scanf("%d",&y);

sum(x,y);


//printf("%d",z);


}
//main method end..............

void sum(int a,int b)
{
printf("%d",a+b);
}


Tuesday 26 December 2017

Learn C language Part 20 Search Element in array in c language





#include <stdio.h>

#include <conio.h>



main()

{

int n,i,index=-1;

int x[6]{32,54,23,66,2,1};

printf("Enter the number that u want to search in array: ");

scanf("%d",&n);



for(i=0;i<6;i++)

{



if(x[i]==n)

{



index=i;

break;



}







} //loop end....



if(index==-1)

{

printf("%d doesnot exist in array",n );

}

else

{

printf("%d is found at %d position",n,index);

}



}

Learn C language Part 19 Two Dimenstional Array in C ,Sum and Differnce of Two Matrices

#include<stdio.h>
#include<conio.h>

main()
{

int r,c;
int a[3][3];
int b[3][3];
int d[3][3];
int e[3][3];

//matrices A................................

for(r=0;r<3;r++)
{


for(c=0;c<3;c++)
{
printf("Enter the number at A[%d,%d]: ",r,c);
scanf("%d",&a[r][c]);
}



} //outer loop



//matrices B................................

for(r=0;r<3;r++)
{


for(c=0;c<3;c++)
{
printf("Enter the number at B[%d,%d]: ",r,c);
scanf("%d",&b[r][c]);
}



} //outer loop


//sum of these matrices.............................


for(r=0;r<3;r++)
{


for(c=0;c<3;c++)
{
d[r][c]=a[r][c] +b[r][c];
}



} //outer loop


for(r=0;r<3;r++)
{


for(c=0;c<3;c++)
{
e[r][c]=a[r][c]-b[r][c];
}



} //outer loop





//printing the A.......................

printf("\n\n\nMatrices A: \n");


for(r=0;r<3;r++)
{

printf("|\t");
for(c=0;c<3;c++)
{
printf("%d\t",a[r][c]);
}

printf("|\n");



} //outer loop



//printing the A.......................

printf("\n\n\nMatrices B: \n");


for(r=0;r<3;r++)
{

printf("|\t");
for(c=0;c<3;c++)
{
printf("%d\t",b[r][c]);
}

printf("|\n");



} //outer loop









//printing the sum.......................



printf("\n\n\nMatrices D: (Sum of A & B)\n");



for(r=0;r<3;r++)
{

printf("|\t");
for(c=0;c<3;c++)
{
printf("%d\t",d[r][c]);
}

printf("|\n");



} //outer loop







//printing the sum.......................



printf("\n\n\nMatrices E: (Difference of A & B)\n");



for(r=0;r<3;r++)
{

printf("|\t");
for(c=0;c<3;c++)
{
printf("%d\t",e[r][c]);
}

printf("|\n");



} //outer loop







}

Learn C language Part 18 Two Dimenstional Array in C, MATRICES IN C

\



#include <stdio.h>

#include <conio.h>





main()

{

 textcolor(RED);

int  i,j;

int x[3][3];



for(i=0;i<3;i++)

{





for(j=0;j<3;j++)

{



printf("Enter the number that you want to save on position x[%d,%d] : ",i,j);

scanf("%d",&x[i][j]);



} //inner loop









} //outer loop





printf("\n\n\n");

//printing the matrices .........................................

printf("Matrices A\n");



for(i=0;i<3;i++)

{

printf("|\t");



for(j=0;j<3;j++)

{



printf("%d\t",x[i][j]);



} //inner loop

printf("|");



printf("\n\n");





} //outer loop





}

Learn C language Part 18 Two Dimenstional Array in C, MATRICES IN C

\



#include <stdio.h>

#include <conio.h>





main()

{

 textcolor(RED);

int  i,j;

int x[3][3];



for(i=0;i<3;i++)

{





for(j=0;j<3;j++)

{



printf("Enter the number that you want to save on position x[%d,%d] : ",i,j);

scanf("%d",&x[i][j]);



} //inner loop









} //outer loop





printf("\n\n\n");

//printing the matrices .........................................

printf("Matrices A\n");



for(i=0;i<3;i++)

{

printf("|\t");



for(j=0;j<3;j++)

{



printf("%d\t",x[i][j]);



} //inner loop

printf("|");



printf("\n\n");





} //outer loop





}

Learn C language Part 18 Two Dimenstional Array in C, MATRICES IN C

\



#include <stdio.h>

#include <conio.h>





main()

{

 textcolor(RED);

int  i,j;

int x[3][3];



for(i=0;i<3;i++)

{





for(j=0;j<3;j++)

{



printf("Enter the number that you want to save on position x[%d,%d] : ",i,j);

scanf("%d",&x[i][j]);



} //inner loop









} //outer loop





printf("\n\n\n");

//printing the matrices .........................................

printf("Matrices A\n");



for(i=0;i<3;i++)

{

printf("|\t");



for(j=0;j<3;j++)

{



printf("%d\t",x[i][j]);



} //inner loop

printf("|");



printf("\n\n");





} //outer loop





}

Thursday 21 December 2017

Learn C language Part 17 Sum of Arrays values





#include <stdio.h>

#include <conio.h>



main()

{



int x[6]; // array declaration......



x[0]=100;

x[1]=100;

x[2]=501;

x[3]=603;

x[4]=905;

x[5]=545;

int i,sum=0;







for(i=0;i<6;i++)

{



sum=sum+x[i];



}



printf("%d",sum);





}


Learn C language Part 16 Basic Introduction to Array





int x[5]; // array declaration......



x[0]=78;

x[1]=100;

x[2]=67;

x[3]=96;

x[4]=90;

printf("%d\n",x[4]);

Tuesday 19 December 2017

Learn C language Part 15 Print lower Trianlge pattern nested loop

#include <stdio.h>

#include <conio.h>



main()

{



int i=0,j=0;

for(i=0;i<10;i++)

{





for(j=0;j<=i;j++)

{



printf("x");



}

printf("\n");













}

//outer loop end...................



























}




Learn C language Part 14 Print Upper Trianlge pattern nested loop





#include <stdio.h>

#include <conio.h>



main()

{





int i=0,j=0;







for(i=0;i<5;i++)

{





for(j=i;j<5;j++)

{



printf("*");

}



printf("\n");







} //outer looop





























}




Learn C language Part 13 Print Square using nested loop





#include <stdio.h>

#include <conio.h>



main()

{





int i=0,j=0;







for(i=0;i<5;i++)

{





for(j=0;j<15;j++)

{



printf("*");

}



printf("\n");







} //outer looop





























}




Sunday 17 December 2017

Learn C language Part 11 Do while loop in C language




#include <stdio.h>
#include <conio.h>

main()
{

int x=1;

do
{
printf("salman");
x++;
}
while(x>1);

}

Learn C language Part 10 Factorial program using while loop in c





#include <stdio.h>

#include <conio.h>



main()

{



int fac=1,x=4;



printf("Enter the number: ");

scanf("%d",&x);



int y=x;

while(x>1)

{



fac=fac* x;



x--;

}



printf("%d ! = %d ",y,fac);



}


Learn C language Part 9 while loop in c





#include <stdio.h>

#include <conio.h>



main()

{



int x=0;



while(x<=10)

{



printf("salman %d\n",x);

x++;

}



printf("\nLoop break");







}

Thursday 14 December 2017

Learn C language Part 8 how to show Maths tables using for loop





#include <stdio.h>

#include <conio.h>



main()

{



int t,n,i;

printf("Enter the number which table you want to show: ");

scanf("%d",&t);



printf("Enter the limit of table: ");

scanf("%d",&n);







for(i=1;i<=n;i++)

{



printf("%d  x  %d = %d\n",t,i,t*i);





}







}


Learn C language Part 7 sum of natural n numbers & limit of a integer v...







#include <stdio.h>

#include <conio.h>



main()

{



 //1 -100

int i=0,n;

float x;

l1:
x=0;


printf("Enter the number: ");

scanf("%d",&n);



for(i=1;i<=n;i++)

{



x=x+i;



}



printf("sUM OF 100 = %.1f",x);

printf("\n\n\n");

printf("----------------------------------------------");



goto l1;





}


Learn C language Part 6 (How For Loop Works in all Programming languages)







#include <stdio.h>

#include <conio.h>



main()

{





int i=0;



for(i=1;i<=10;i++)

{

printf("salman%d\n",i);

}

printf("Loop break");







}


Wednesday 13 December 2017

Learn Sql server in hindi/urdu part-25 (many to many relationship)







create table tblstudent

(

st_id int primary key identity,

st_name nvarchar(20) not null

)

insert into tblstudent

values('Ali')

insert into tblstudent

values('Bilal')

insert into tblstudent

values('Zahid')

insert into tblstudent

values('Fahad')

insert into tblstudent

values('saleem')

insert into tblstudent

values('kamran')

select * from tblstudent



create table tblcourses

(

c_id int primary key identity,

c_title nvarchar(20) not null



)



insert into tblcourses

values('data structure')

insert into tblcourses

values('database&management')

insert into tblcourses

values('Data Audit')

insert into tblcourses

values('data warehosuing')

insert into tblcourses

values('data mining')

insert into tblcourses

values('data Analytics')



select* from tblcourses

select * from tblstudent







create table course_student

(

cs_id int primary key identity,

cs_fk_st int foreign key references tblstudent(st_id),

cs_fk_cu int foreign key references tblcourses(c_id),



)



insert into course_student

values(1,3)

insert into course_student

values(1,5)

insert into course_student

values(1,6)





insert into course_student

values(2,2)

insert into course_student

values(2,3)

insert into course_student

values(2,6)







insert into course_student

values(3,1)

insert into course_student

values(3,2)

insert into course_student

values(3,3)







select s.st_id,c.c_id,s.st_name,c.c_title from course_student cs inner join tblstudent s on s.st_id=cs.cs_fk_st inner join tblcourses c on c.c_id=cs.cs_fk_cu


Learn Sql server in hindi/urdu part-24 (one to many relationship with pr...







create table customer

(

c_id int identity primary key,

c_name nvarchar(20) not null

)



insert into customer

values('asim')

insert into customer

values('basit')

insert into customer

values('danish')

insert into customer

values('Ebad')



select * from customer



create table product

(

p_id int identity primary key,

p_name nvarchar(20) not null



)



select * from product







create table tblorder

(

o_id int identity primary key,

o_product_id int foreign key references product(p_id),

o_date datetime,

o_c_id int foreign key references customer(c_id),

)





insert into tblorder

values(3,GETDATE(),4)





select c.c_id,c.c_name,p.p_name,o.o_id,o.o_date from tblorder o inner join product p on p.p_id=o.o_product_id inner join customer c on c.c_id=o.o_c_id








Tuesday 12 December 2017

Learn C language Part 5 goto unconditional jump stattements with marksheet program

#include<stdio.h>
#include<conio.h>

main()
{

int eng,math,phy,urdu,islamiat;
float percentage;
l1:
printf("Enter the marks obtained in English: ");
scanf("%d",&eng);

if(eng<0)
{
printf("\nInvalid input !obtained Marks cannot be negative\n\n");
goto l1;
}


l2:
printf("\nEnter the marks obtained in Mathematics: ");
scanf("%d",&math);


if(math<0)
{
printf("\nInvalid input !obtained Marks cannot be negative\n\n");
goto l2;
}



l3:
printf("\nEnter the marks obtained in Physics: ");
scanf("%d",&phy);
if(phy<0)
{
printf("\nInvalid input !obtained Marks cannot be negative\n\n");
goto l3;
}



l4:

printf("\nEnter the marks obtained in Urdu: ");
scanf("%d",&urdu);

if(urdu<0)
{
printf("\nInvalid input !obtained Marks cannot be negative\n\n");
goto l4;
}




l5:
printf("\nEnter the marks obtained in Islamiat: ");
scanf("%d",&islamiat);
if(islamiat<0)
{
printf("\nInvalid input !obtained Marks cannot be negative\n\n");
goto l5;
}





percentage= ((eng+math+phy+urdu+islamiat)*100/500);

printf("Percentage: %.2f",percentage);

printf("\n\n\n Grade:");
if(percentage>=80)
{
printf("A+");

}
else if(percentage>=70)
{
printf("A");
}
else if(percentage>=60)
{
printf("B");
}
else if(percentage>=50)
{
printf("C");
}
else
{
printf("F");

}





}

Learn C language Part -4 if else ,ladder if else, nested if else statements with practical example

#include <stdio.h>
#include <conio.h>

main()
{

int age;

printf("Enter your age: ");
scanf("%d",&age);

if(age>=18)
{
// printf("YOU ARE ELIGIBLE FOR THIS JOB......");
if(age<=20)
{
printf("YOU ARE ELIGIBLE FOR clerk JOB......");
}

else if(age<=25)
{

printf("YOU ARE ELIGIBLE FOR HR JOB......");
}

else if(age<=30)
{

printf("YOU ARE ELIGIBLE FOR manager JOB......");
}
else
{
printf("age limit exceeded!......");
}


}


else
{
printf("YOU ARE NOT ELIGIBLE FOR THIS JOB......");
}







}

Monday 11 December 2017

Learn Sql server in hindi/urdu part-23(one to one relationship)





create table car

(

car_id int identity primary key,

car_name nvarchar(20) not null,

car_model nvarchar(10) not null,



)



insert into car

values('Mehran','1980')



select * from car



create table employee

(

emp_id int identity primary key,

emp_name nvarchar(20) not null,

emp_desig nvarchar(20) not null,

emp_car_fk int unique foreign  key references car(car_id)



)











insert into employee

values('ahmed','officer',2)





select  e.emp_id,e.emp_name,e.emp_desig,c.car_id,c.car_model,c.car_name from employee e inner join car c on c.car_id=emp_car_fk


Sunday 10 December 2017

Learn C language Part 3 swapping the values of two variables







#include <stdio.h>

#include <conio.h>





main()

{



int x,y,z;



printf("Enter the value of x: ");

scanf("%d",&x); //5



printf("Enter the value of y: ");

scanf("%d",&y);//10



z=x; //z=5

x=y; //x=10

y=z; //y=5







printf("\n\n\n\nx=%d",x);

printf("\ny=%d",y);









}

Learn C language Part 3 swapping the values of two variables







#include <stdio.h>

#include <conio.h>





main()

{



int x,y,z;



printf("Enter the value of x: ");

scanf("%d",&x); //5



printf("Enter the value of y: ");

scanf("%d",&y);//10



z=x; //z=5

x=y; //x=10

y=z; //y=5







printf("\n\n\n\nx=%d",x);

printf("\ny=%d",y);









}

Learn C language Part 3 swapping the values of two variables







#include <stdio.h>

#include <conio.h>





main()

{



int x,y,z;



printf("Enter the value of x: ");

scanf("%d",&x); //5



printf("Enter the value of y: ");

scanf("%d",&y);//10



z=x; //z=5

x=y; //x=10

y=z; //y=5







printf("\n\n\n\nx=%d",x);

printf("\ny=%d",y);









}

Learn C language Part 2 scanf command, sum of two integer numbers





#include<stdio.h>

#include<conio.h>



main()

{



int x,y;

int z;



printf("Enter the value of x :");

scanf("%d",&x);



printf("Enter the value of y :");

scanf("%d",&y);



z=x+y;



printf("value of z = %d",z);











}

Learn C language Part 2 scanf command, sum of two integer numbers





#include<stdio.h>

#include<conio.h>



main()

{



int x,y;

int z;



printf("Enter the value of x :");

scanf("%d",&x);



printf("Enter the value of y :");

scanf("%d",&y);



z=x+y;



printf("value of z = %d",z);











}

Learn C language in very easy manner ( Part 1 Printf command)







#include<stdio.h>

#include<conio.h>



main()

{



printf("Hello world\nHello salman");







}


Wednesday 6 December 2017

Learn Sql server in hindi/urdu part-20(Triggers IN SQL SERVER)

select * from sys.tables


-----------------------------------------------------------------------------
CREATE TABLE tblEmployee
(
  Id int Primary Key,
  Name nvarchar(30),
  Salary int,
  Gender nvarchar(10),
  DepartmentId int
)


Insert into tblEmployee values (1,'John', 5000, 'Male', 3)
Insert into tblEmployee values (2,'Mike', 3400, 'Male', 2)
Insert into tblEmployee values (3,'Pam', 6000, 'Female', 1)
----------------------------------------------------------------------------------------------

CREATE TABLE tblEmployeeAudit
(
  Id int identity(1,1) primary key,
  AuditData nvarchar(1000)
)
--------------------------------------------------------------------------------------------
CREATE TRIGGER tr_tblEMployee_ForInsert
ON tblEmployee
FOR INSERT
AS
BEGIN
 Declare @Id int
 Select @Id = Id from inserted

 insert into tblEmployeeAudit
 values('New employee with Id  = ' + Cast(@Id as nvarchar(5)) + ' is added at ' + cast(Getdate() as nvarchar(20)))
END
-------------------------------------------------------------------------------------------------------------
CREATE TRIGGER tr_tblEMployee_ForDelete
ON tblEmployee
FOR DELETE
AS
BEGIN
 Declare @Id int
 Select @Id = Id from deleted

 insert into tblEmployeeAudit
 values('An existing employee with Id  = ' + Cast(@Id as nvarchar(5)) + ' is deleted at ' + Cast(Getdate() as nvarchar(20)))
END



-------------------------------------------------------------------------------------------------------------


Create trigger tr_tblEmployee_ForUpdate2
on tblEmployee
for Update
as
Begin


 Declare @Id int
 Select @Id = Id from inserted


 insert into tblEmployeeAudit
 values('An existing employee with Id  = ' + Cast(@Id as nvarchar(5)) + ' is updated at ' + Cast(Getdate() as nvarchar(20)))

 Select * from deleted
 Select * from inserted


End


-------------------------------------------------------------------------------------------------------------

Monday 4 December 2017

Learn Sql server in hindi/urdu part-18(Updateable Views IN SQL SERVER)





CREATE TABLE tblEmployee

(

  Id int Primary Key,

  Name nvarchar(30),

  Salary int,

  Gender nvarchar(10),

  DepartmentId int

)





Insert into tblEmployee values (1,'John', 5000, 'Male', 3)

Insert into tblEmployee values (2,'Mike', 3400, 'Male', 2)

Insert into tblEmployee values (3,'Pam', 6000, 'Female', 1)

Insert into tblEmployee values (4,'Todd', 4800, 'Male', 4)

Insert into tblEmployee values (5,'Sara', 3200, 'Female', 1)

Insert into tblEmployee values (6,'Ben', 4800, 'Male', 3)









Create view vWEmployeesDataExceptSalary

as

Select Id, Name, Gender, DepartmentId

from tblEmployee





Select * from vWEmployeesDataExceptSalary

select * from tblEmployee





Update vWEmployeesDataExceptSalary



Set Name = 'salman' Where Id = 2





Update vWEmployeesDataExceptSalary

set salary=20000 where id=2




Learn Sql server in hindi/urdu part-17(Views/virtual table IN SQL SERVER)

--What is a View?
--A view is nothing more than a saved SQL query. A view can also be considered as a virtual table.


CREATE TABLE tblEmployee
(
  Id int Primary Key,
  Name nvarchar(30),
  Salary int,
  Gender nvarchar(10),
  DepartmentId int
)
CREATE TABLE tblDepartment
(
 DeptId int Primary Key,
 DeptName nvarchar(20)
)

Insert into tblDepartment values (1,'IT')
Insert into tblDepartment values (2,'Payroll')
Insert into tblDepartment values (3,'HR')
Insert into tblDepartment values (4,'Admin')


Insert into tblEmployee values (1,'John', 5000, 'Male', 3)
Insert into tblEmployee values (2,'Mike', 3400, 'Male', 2)
Insert into tblEmployee values (3,'Pam', 6000, 'Female', 1)
Insert into tblEmployee values (4,'Todd', 4800, 'Male', 4)
Insert into tblEmployee values (5,'Sara', 3200, 'Female', 1)
Insert into tblEmployee values (6,'Ben', 4800, 'Male', 3)
Insert into tblEmployee values (7,'salman',51800, 'Male', 4)



select * from tblDepartment
select * from tblEmployee


create view viewforall
as
select * from tblEmployee


select * from viewforall

create view viewforreception
as
select id,Name,Gender,DepartmentId from tblEmployee

select * from viewforreception



create view viewforrecpetionwithdeptname
as

select e.Id,e.Name,e.Gender,d.DeptName from tblEmployee e inner join tblDepartment d on d.DeptId=e.DepartmentId


select * from viewforrecpetionwithdeptname



Create View vWEmployeesCountByDepartment
as
Select DeptName, COUNT(Id) as TotalEmployees
from tblEmployee
join tblDepartment
on tblEmployee.DepartmentId = tblDepartment.DeptId
Group By DeptName


select * from tblDepartment
select * from tblEmployee


select * from vWEmployeesCountByDepartment

Friday 1 December 2017

Learn Sql server in hindi/urdu part-16(String fucntions-2 IN SQL SERVER)





Select LTRIM('      Hello')





Select RTRIM (LTRIM('  Hello   '))



Select LOWER('CONVERT This String Into Lower Case')

Select UPPER('CONVERT This String Into Lower Case')

Select REVERSE('ABCDEFGHIJKLMNOPQRSTUVWXYZ')

Select LEN('ABCDEFGHIJKLMNOPQRSTUVWXYZ')


Learn Sql server in hindi/urdu part-15(String fucntions IN SQL SERVER)





use stringfunction





print ASCII('A')

print CHAR(51)









declare @number int

set @number=65

while(@number<=90)

begin



print CHAR(@number)



set @number=@number+1

end


Learn Sql server in hindi/urdu part-15(String fucntions IN SQL SERVER)





use stringfunction





print ASCII('A')

print CHAR(51)









declare @number int

set @number=65

while(@number<=90)

begin



print CHAR(@number)



set @number=@number+1

end


Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...