Missing the inclusion of appropriate header file in c program will generate an error. Such a program may compile but the linker will given an error message as it will not be able to find the functions used in the program.

When you are using SWITCH case, it is important to keep in mind that the inclusion of DEFAULT LABEL. This will inform you whether you are executing your program in right or wrong way. So, it is always recommended to use DEFAULT LABEL in the SWITCH st

The test expression done on exact statement. The good habit of using test expression on exact or fulfill statement. So do not use floating point numbers for checking for equality in the test expression.

Not putting // before the start of single statement comment is a compiler error. Not putting the */ after the termination of block comment is a compiler error.

The iterative statement is one of the most important and interesting statements in the programming world. An iterative statement is used to repeat the execution of a list of statements, depending on the value of an integer expression.

// AHF C PROGRAM SOLVING //solving here basic type of programming problem

#include<stdio.h> #include<math.h> #include<stdlib.h> #define pf printf int main() { int choice; while(1){ pf("\nEnter your choice "); pf("\nEnter 1 for summation "); pf("\nEnter 2 for subtraction "); pf("\nEnter 3 for multiplication "); pf("\nEnter 4 for division .......... "); pf("\nEnter 5 to Exit .......... "); scanf("%d",&choice); switch(choice) { case 1: { int x,y,sum=0; pf("\nEnter first and second number: "); scanf("%d %d",&x,&y); sum=x+y; pf("\nThe summation = %d",sum); } break; case 2: { int x,y,sub=0; pf("\nEnter first and second number: "); scanf("%d %d",&x,&y); sub=x-y; pf("\nThe summation = %d",sub); } break; case 3: { int x,y,mul=0; pf("\nEnter first and second number: "); scanf("%d %d",&x,&y); mul=x*y; pf("\nThe summation = %d",mul); } break; case 4: { float x,y,div=0; pf("\nEnter first and second number: "); scanf("%f %f",&x,&y); div=x/y; pf("\nThe summation = %f",div); } break; case 5: exit(1); default : pf("\nInvalid Input."); } } return 0; }

Enter your choice

Enter 1 for summation

Enter 2 for subtraction

Enter 3 for multiplication

Enter 4 for division ..........

Enter 5 to Exit .......... 1

Enter first and second number: 1 2

The summation = 3

Enter your choice

Enter 1 for summation

Enter 2 for subtraction

Enter 3 for multiplication

Enter 4 for division ..........

Enter 5 to Exit .......... 2

Enter first and second number: 3 6

The summation = -3

Enter your choice

Enter 1 for summation

Enter 2 for subtraction

Enter 3 for multiplication

Enter 4 for division ..........

Enter 5 to Exit .......... 3

Enter first and second number: 2 3

The summation = 6

Enter your choice

Enter 1 for summation

Enter 2 for subtraction

Enter 3 for multiplication

Enter 4 for division ..........

Enter 5 to Exit .......... 4

Enter first and second number: 5 6

The summation = 0.833333

Enter your choice

Enter 1 for summation

Enter 2 for subtraction

Enter 3 for multiplication

Enter 4 for division ..........

Enter 5 to Exit .......... 5

The program is finished.

Enter 1 for summation

Enter 2 for subtraction

Enter 3 for multiplication

Enter 4 for division ..........

Enter 5 to Exit .......... 1

Enter first and second number: 1 2

The summation = 3

Enter your choice

Enter 1 for summation

Enter 2 for subtraction

Enter 3 for multiplication

Enter 4 for division ..........

Enter 5 to Exit .......... 2

Enter first and second number: 3 6

The summation = -3

Enter your choice

Enter 1 for summation

Enter 2 for subtraction

Enter 3 for multiplication

Enter 4 for division ..........

Enter 5 to Exit .......... 3

Enter first and second number: 2 3

The summation = 6

Enter your choice

Enter 1 for summation

Enter 2 for subtraction

Enter 3 for multiplication

Enter 4 for division ..........

Enter 5 to Exit .......... 4

Enter first and second number: 5 6

The summation = 0.833333

Enter your choice

Enter 1 for summation

Enter 2 for subtraction

Enter 3 for multiplication

Enter 4 for division ..........

Enter 5 to Exit .......... 5

The program is finished.

- Eligible age for vote
- Calculate area of a circle
- Calculate area of a triangle
- Calculate area of a rectangle
- Calculate area of a rectangle, triangle and circle
- Bonus on employment salary
- Print even or odd number
- Leap year
- Input any key from key-board and display key's feature
- Find large number of two or three given numbers
- Print ASCII value of a character and number
- Print all ASCII value

© 2018 - All rights reserved