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);
}


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 ...