Skip to main content

Posts

Best Programming Habits and Practices

 Write commented code  Plan before you code  Use a good Text editor. With highlight features. Some suggested Text editors for C programming are; CodeBlocks NetBeans Eclipse Use version controlling like GitHub  What's the text editor of your choice? Share in comments. 

Latest trends in programming

Here are some latest trends in programming.  Light-weight syntax means using shorter keywords and more symbols Light-weight functions (aka lambdas/closures/blocks) are almost ubiquitous in new languages, sometimes with highly abbreviated syntax (like Scala/Swift placeholder syntax) Light-weight objects (objects you construct without declaring a new class/type) Light-weight threads (green threads / cooperative multithreading)

Finding the arithmetic operators

Below is a very simple program to find the arithmetic operator. Please feel free to put a comment if need an explanation. #include #include void main()   {     float a1,a2;     char operator;     printf("\n Enter the values of a1 operator a2\n");     scanf("%f%c%f",&a1,&operator,&a2);     switch(operator)      { case '+': printf("%.2f",a1+a2); break; case '-':  printf("%.2f",a1-a2);  break; case '*':  printf("%.2f",a1*a2); break; case '/':  if(a2==0)  printf("error\n");  else  printf("%.2f",a1/a2);  break; default: printf("unknown operatotr\n"); break;      }    }

Calculating the average of two numbers using C++

Though this site aims at understanding C language, I am writing a program for you in C++, to have a general idea about C++ too. A program in C++,to calculate the average of two numbers, which are entered by the keyboard while the execution of the program. Try to understand the program; #include &lt iostream &gt using namespace std; int main() {     float num1,num2,average,sum;     cout << "Enter the first number:";     cin >> num1;     cout << "Enter the second number:";     cin >> num2;     sum=num1+num2;     average=sum/2;     cout << "The sum of the two numbers is:"<< sum<<"\n"<<"The average of the two numbers is:" << average; return(0); } Explaination: The new file header used here in this C++ program is the #include . By this , we are asking the preprocessor to add the contents of the ...

C Reference app on Android

Android is one of the most rapidly growing mobile platform today. Most of us are opting for android devices , cell phones /tablets and so am I . While surfing around the Android Market (The place to download android apps) I came across an helpful app; " C Reference ".                                This app provides the reference to the standard C library. It also contains description of all the functions and macros in C, in a searchable from. This app could be very handy in while writing C programs.And the best part about this app is that , this app can be downloaded free from the android market. Screenshots: You can see and download this app from C Reference App

A C program to print the average of the numbers(Using While Loop)

Below is a program to print the average of two numbers that are input through the keyboard.   /* Read the numbers from the keyboard as input and * print out their average as output. */    #include &lt stdio &gt int main( ) { double x = 0.0, sum = 0.0; int count = 0; printf( "\t--- Calculate Average of the numbers ---\n" ); printf( "\nEnter the number you want to calulate average for:\n" "(Type a letter to end your input)\n" ); while ( scanf( "%lf", &x ) == 1 ) { sum += x; ++count; } if ( count == 0 ) printf( "No input data given!\n" ); else printf( "The average of given numbers is %.2f\n", sum/count ); return 0; } The output of the program:    

Turbo C++ for Windows 7 64 bit

 Its a very simple guide to install Turbo C++ on Windows 7 64 bit  operating system. Follow the steps below to install Turbo C++ compiler on your windows 7 ,64 bit operating system. Note - Please let me know whether the process is working for you or if you are getting some kind of error. Step 1) Install the software DOSBOX version 0.73(Search for it in the search bar). Step 2) Create a folder on your C drive, e.g.Turbo; (c:\Turbo\) Step 3) Extract TC into the created folder(e.g. c:\Turbo\);(you can search and download it) Step 4) Run the application DOSBOX 0.73,previously downloaded and installed. Step 5) Type the following commands at the command prompt that will appear, [z]: mount d c:\Turbo\ Following this you will get a message "Drive D is mounted as local directory c:\Turbo\" Step 6) Type d: to shift to d: Step 7) Then type commands mentioned below; cd tc cd bin tc or tc.exe Step 8) In the turbo C++ go to Options\Directories\ Chang...

Seminar Topics(100)

Excellent Seminar/Paper Presentation Topics for Students Put the desired topic name in search bar to get detail search about the topic. 1. 4G Wireless Systems 2. A BASIC TOUCH-SENSOR SCREEN SYSTEM 3. Artificial Eye 4. Animatronics 5. Automatic Teller Machine 6. Aircars 7. Adding interlligence to ineternet using satellite 8. ADSL 9. Aeronautical Communications 10. Agent oriented programing 11. Animatronics 12. Augmented reality 13. Autonomic Computing 14. Bicmos technology 15. BIOCHIPS 16. Biomagnetism 17. Biometric technology 18. BLUE RAY 19. Boiler Instrumentation 20. Brain-Computer Interface 21. Bluetooth Based Smart Sensor Networks 22. BIBS 23. CDMA Wireless Data Transmitter 24. Cellonics Technology 25. Cellular Positioning 26. Cruise Control Devices 27. Crusoe Processor 28. Cyberterrorism 29. Code division duplexing 30. Cellular Digital Packet Data 31. Computer clothing 32. Cordect WLL 33. CARBIN NANO TUBE ELEC...

Use Flowcharts(Tip)

FLOWCHART Use a flowchart to represent the logic of your program before coding.This will reduce lot of redundancy and helps improve your logic. In fact, even if you don't use a flow chart, but sure to spend some time thinking about your program design before diving in and writing code. If any questions and queries regarding flowchart,write in the comment box.

C Program to calculate roots of quadratic equations

C Program to calculate roots of quadratic equations This is a simple C program to calculate roots of quadratic equations.A function sqrt() is used in this program to find the square root.Also, we will have to include the math.h header. #include #include main() { int a,b,c,d; float root1,root2; printf("Enter the values of a,b,c"); scanf("%d%d%d",&a,&b,&c); d=b*b-4*a*c; root1=((-b)+sqrt(d))/(2*a); root2=((-b)-sqrt(d))/(2*a); printf("root1=%f and root2=%f",root1,root2); }

Program to Propose a girl(Funny)

Ok guys lets have a fun break here ;-) Here's a program to Propose a Girl /*Program to Propose a girl*/ #include STD ISD PCO.h #include mobile.h #include sms.h #include love.h #define Cute beautiful_lady main() { goto college; scanf("100%",&ladies); if(lady ==Cute) line++; while( !reply ) { printf("I Love U"); scanf("100%",&reply); } if(reply == "GAALI") main(); /* go back and repeat the process */ else if(reply == "SANDAL ") exit(1); else if(reply == "I Love U") { lover =Cute ; love = (heart*)malloc(sizeof(lover)); } goto restaurant; restaurant: { food++; smile++; pay->money = lover->money; return(college); } if(time==2.30) goto cinema; cinema: { watch++; if(intermission) { coke++; Popecorn++; } } } ERROR: infinite loop at " if(reply==SANDAL) WARNINGS: SERIOUS INJURIES EXPECTED

C Program using While loop to Convert Fahrenheit to Celsius

This is a C program to convert Fahrenheit to Celcius. Let us take a look at the program . This can be easily accomplished with a for loop or a while loop: #include int main() { int a; a = 0; while (a { printf("%4d degrees F = %4d degrees C\n", a, (a - 32) * 5 / 9); a = a + 10; } return 0; } If you run this program, it will produce a table of values starting at 0 degrees F and ending at 100 degrees F. The output will look like this: 0 degrees F = -17 degrees C 10 degrees F = -12 degrees C 20 degrees F = -6 degrees C 30 degrees F = -1 degrees C 40 degrees F = 4 degrees C 50 degrees F = 10 degrees C 60 degrees F = 15 degrees C 70 degrees F = 21 degrees C 80 degrees F = 26 degrees C 90 degrees F = 32 degrees C 100 degrees F = 37 degrees C The table's values are in increments of 10 degrees. You can see that you can easily change the starting, ending or increment values of the table that the p...

Good Programming habits

Some of good programming habits: 1. Before sitting down for coding, you must have formal or a paper-napkin design of the solution to be coded. Never start coding without any design unless the code is trivial one. 2. Good code documentation is as important as good knowledge of a programming language. Write brief logic for each major block of your code as comments in source code file itself. Its good to mention creation and modification dates of your program along-with why modification was required. 3. Maintaining versions of your program is another important task. Some present-day programming tools already have a built-in version management. Whenever you make any change to your program, they save its copy as .bak file.

Tip-Always make a backup

Always make sure that when you have a program with more lines of code, you make a backup copy somewhere. Once you find you made some huge mistake, or decide there is a better way to code the entire thing, you'll be glad you made that backup so many hours/days ago instead of re-coding hundreds of lines of code.
C language is widely famous and founds its applications everywhere because of its versatility and flexibility.In fact C language is a Programmers’s language. Not all computer programming languages are for programmers. For instance the COBOL and BASIC are not the languages for programmers.C was created,influenced, and tested by working programmers. That’s the reason C gives the programmer what the programmer wants.C is the language with few restrictions, few complaints, block structures, stand alone functions, and a compact set of keywords.Using C Language , you can nearly achieve the efficiency of assembly code combined with the structure of ALGOL.This has made C language highly popular between professional programmers. C was initially used for systems programming. Here are few example of system programming; 1) Operating systems 2) Interpreters 3) Editors 4) Compilers 5) File utilities 6) Performance enhancers 7) Real-time executives C founds wide application in many because of...

The While Loop

The While Loop While programming we often need to do something a fixed number of times. In such cases the While loop is used. Lets study it with the help of an example below; /* Calculation of simple interest for 3 sets of p, n and r */ main( ) { int p, n, count ; float r, si ; count = 1 ; while ( count <= 3 ) { printf ( "\nEnter values of p, n and r " ) ; scanf ( "%d %d %f", &p, &n, &r ) ; si = p * n * r / 100 ; printf ( "Simple interest = Rs. %f", si ) ; count = count + 1 ; } } The program above executes all statements after while three times.The logic of calculating simple interest is written in braces after the while word and is called as the body of the while loop.The brackets after the while contains the condition.All the statements within the loop are executed till the condition is true. Another program which uses while loop,to print the average of the numbers input . The Program

loops2

The versatility of the computer lies in its ability to perform a set of instructions repeatedly. This involves repeating some portion of the program either a specified number of times or until a particular condition is being satisfied. This repetitive operation is done through a loop control instruction. There are three methods by way of which we can repeat a part of a program; (1) Using a for statement (2) Using a while statement (3) Using a do-while statement

Loops

Till now we have studied the use of Decision or Sequential Control statements. When executed thesestatements always perform the same series of actions, in the same way, exactly once.But in order to perform programs that can do an action over and over,we need LOOPS. Thus in the next post we are going to discuss about the Loops.

Forms of IF statement

Forms of IF Statement: The if statement can take any of the given forms: (1) if ( condition ) do this ; (2) if ( condition ) { do this ; and this ; } (3) if ( condition ) do this ; else do this ; (4) if ( condition ) { do this ; and this ; } else { do this ; and this ; } (5) if ( condition ) do this ; else { if ( condition ) do this ; else { do this ; and this ; } } (6) if ( condition ) { if ( condition ) do this ; else { do this ; and this ; } } else do this ;