Skip to main content

Posts

Showing posts with the label Programming in c

Structure C programming - Used to Store More Then One Type Of Data.

Structure is used to store more then one values in different data types. struct keyword is used to declare the structure. Syntax struct structure_name{ int id; char name[50]; float salary; }; main() { struct structure_name object_of_structure; } How To Access Structure Member Variable ? Create the object of that structure. And access  the values of structure variable using "."(dot operator). Example struct emp{ int id; char name[50]; float salary; }; main() { struct emp e; printf("Enter the employee details\n"); printf("Id :"); scanf(%d,&e.id); printf("Name :"); scanf(%d,e.name); printf("Salary :"); scanf(%f,&e.salary); printf("\nEmployee details"); printf("\n%d",e.id); printf("\n%s",e.name); printf("\n%f",e.salary); } Output Enter the employee details Id : 25 Name : mrc Salary : 25000 Employee details 25 mrc 25000 From the above programme we declare the id,name and salary variables insi...

if control statement - Basic Programming Concepts With psudo Code

if( )  is a control statement. it based on some condition. if the condition can true the block of statements can execute other wise skip the statements. syntax if([condition]) { //statement; } example1, #include<stdio.h> #include<conio.h> main() int num=1; { if(num==1) { printf("\n its true"); } } from the above program we can declare the variable named as num and assign the value as 1. then, check the value 1 equal value of num through if statement.the statement can true.so, the block of statements can executed. example2, #include<stdio.h> #include<conio.h> main() int num=5; { if(num==1) { printf("\n its true"); } } suppose the value of num is 5.the block of if statement can skip to execution.

Functions-Basic Programming Concepts With psudo Code

Function  is a block of code or sub program used to divide the large programs into small parts.Mainly used for Debug Process. Use of functions used to reduce the lines of code easy to debug Reuse ability Syntax return_type function_name([argument1],[argument2]...) { //statement or block of code; } function_name([argument1],[argument2]...); Example, main() { fun(); } fun() { printf("\n function is called"); } Types Of Functions Function With Argument And Return Value Function Without Argument And Return Value Function With Argument And Without Return Value Function Without Argument And Return Value

do...while-Basic Programming Concepts With psudo Code

do...while( ) do...while is a looping statement. it used to execute the same task until reach the condition false. it is a exit checkup statement.which means conditions can check after loop execution. syntax do { //statements or block of code. } while([condition]) example, main() { int a=1; do { printf("\n %d",a); a++; } while(a<=10); }

Switch ... Case-Basic Programming Concepts With Sudo Code

switch...case it is used to execute the particular block of the code based on choice. syntax switch([choice]) { case 1://statement1 or block of program; break; case 2://statement1 or block of program; break; case 3://statement1 or block of program; break; } example, main() { int a; a=3; switch(a) { case 1:printf("\n one");break; case 2:printf("\n two");break; case 3:printf("\n three");break; case 4:printf("\n four");break; default:printf("\n values is not equal to 1 to 4 numbers"); } } default default is a keyword used to execute the default block pf statements. which means if the switch case the value did not match any cases to execute the default statements. break break is a keyword used to exit control statements statements.

if....else-Basic Programming Concepts With psudo Code

if...else if...else is a statement. it based on some condition. if the condition can be true the block of if statements can execute other wise the block of else statements can executed. syntax if([condition]) { //statements or code; } else { //statement or code; } example, #include<stdio.h> #include<conio.h> main() int num=1; { if(num==1) { printf("\n its true"); } else { printf("\n its false"); } }

Variable- Basic Programming Concepts

Variables Variables are used to store the values. it is the represent the name of the logical address. Rules Of Variable Names user defined. variable name should start in letters. variable names are can't start with numbers. variable names also start in underscore _. syntax data_type variable_name; example, int one; from the above example,we can declare the variable named as 'one'; How to assign the values in variables? data_type variable_name=value_of_the_variable; example, int one=1; from the above example,we can assign the value 1 for the variable one;