What are bad coding practices

Developers Worst Coding Practices

What are all called as bad coding practices? 1) Not following standard 2) Not keeping performance in mind 3) History, Indentation, Comments are not appropriate. 4) Readability is poor 5) Open files are not closed 6) Allocated memory has not been released 7) Too many global variables. 8) Too  ..

Swapping using temporary variable

C program to swap using temporary varible

This program uses a temporary variable 'temp' to swap two values. #include<stdio.h> #include<conio.h> int swap(int x,int y); int main() { int a,b; printf("enter the values"); scanf("%d%d",&a,&b); swap(a,b); getch(); } int swap(int x,int y) {   ..

Check input is character digit or symbol

C program to check input is character digit or symbol

This program checks whether the input is symbol, digit or character using functions. #include<stdio.h> #include<conio.h> int charac(char ch); char ch; int main() { int result; printf("enter input"); scanf("%c",&ch); result=charac(ch); if (result==0) printf("it is a charcter"); else if(result==1) printf("it is a  ..

Arithmetic operations using function and switch case

C program to perform arithmetic operations using function and switch case

This program uses function to perform the selected mathematical operation. Here switch case is used to select the options. #include<stdio.h> #include<conio.h> int res; int sum(int x,int y); int sub(int x,int y); int mul(int x,int y); int div(int x,int y); int main() { int choice,a,b; printf("select anyone of the following operation\n");   ..

Fibbonaci series

C program to find fibbonaci series

This program calculates the fibonacci series of a number. the number can be got as input at run time using scanf statement. #include<stdio.h> #include<conio.h> int main() { int i,a,f1=0,f2=1,f3=0; for(i=0; i<5; i++) { f3=f1+f2; printf("%d\n",f1);   ..


C program to find factorial

This program calculates factorial of a number. The number can also be got as input at run time by including scanf statement. #include<stdio.h> #include<conio.h> int main() { int i,a,fact=1,even=0; for(i=5; i>1; i--) { fact*=i;   ..

Find the number of odd and even numbers

C program to find number of odd and even numbers

This program calculates the number of odd and even numbers. Here for loop is used for iterative purpose and if statement to check the condition. #include<stdio.h> #include<conio.h> int main() { int i,a,odd=0,even=0; for(i=0; i<=5; i++) { scanf("%d",&a);   ..

Sum of numbers

C program to find sum of numbers

This program calculates the sum of first five numerals. A for loop is used for this purpose. #include<stdio.h> #include<conio.h> int main() { int i,sum=0; for(i=0; i<=5; i++) { sum+=i; printf("%d\t",i); } printf("\nsum is  ..

Length of a string

C program to find length of a string

This program counts the number of letters in input string. Here gets function is used to get input. But scanf can also be used to get string at run time. Here a count variable is been intialised to zero to count the letters in the string. If condition is checked  ..

Display ascii values of characters

C program to display ascii values

This program prints the ascii values of the given input sting. Input can also be given in run time using for loop. This program user for loop and strlen function to find the length of the given word or statement. #include<stdio.h> #include <string.h> int main() { int i; char a[10]={"hello"}; printf("ascii values of entered string "); for(i=0;i<strlen(a);i++) printf("%d ",a[i]); } Output ascii values of  ..

Display multiplication table of a given number

C programming to display tables

To display multiplication table we use for loop in our program. coding: #include<stdio.h> #include<conio.h> int main() { int n,i,res; printf("enter a number to display its tables"); scanf("%d",n); printf("tables "); for(i=0;i<n;i++) { res=n*i; printf("%d*%d=%d ",n,i,res); } getch(); } Output enter a number to display its tables5 tables 5*0=0 5*1=5 5*2=10 5*3=15 5*4=20 5*5=25 5*6=30 5*7=35 5*8=40 5*9=45 5*10=50   ..

Bit fields

Using bit fields in structures

BIT FIELDS It is possible to allocate lesser memory for variables than the compiler would ordinarily allocate. For example integer usually requires 4 bytes OF memory but when the value is very small large memory becomes a waste therefore using bit fields we can use memory efficiently. struct display { int a:8; int b:4; int c:6; } Here,  ..


Structure model

STRUCTURE: Struct keyword is used for aggregating different datatypes as one object. STRUCTURE MODEL: struct structure_name { structure members; structure members; } struct_varible;   ..

Precedence of operators

C++ precedence of operators

C++ operators are divided into 16 categories. operatos within each category have equal precedence. The unary, conditional and assignment operators associate right to left and all other operators associate left to right. category   ..

Conditional operator

C++ conditional operators

The conditional operator evaluates an expression returning a value if that expression is true and a different one if the expression is evaluated as false. conditional operator is also called as ternary operator. syntax: condition ? expression1 : expression2 #include <iostream.h> void main() {   ..

1 2 3 4 Next

Tech Bluff