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.

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.

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.

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.

A prime number is a whole number greater than 1 whose only factors are 1 and itself. A factor is a whole numbers that can be divided evenly into another number. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19 and 23. Numbers that have more than two factors are called composite numbers. The number 1 is neither prime nor composite.

// AHF C PROGRAM SOLVING //solving here ITERATIVES STATEMENTS type of programming problem

#include<stdio.h> #include<math.h> #define pf printf int main() { int n,m,fact,i,j; //taking the number to continue loop as start point pf("Enter the first number: "); scanf("%d",&n); //taking the number to stop loop pf("\nEnter the second number: "); scanf("%d",&m); for(i=n;i<=m;i++) { int fact=0; //for no error in the result for(j=2;j<i/2;j++) //testing calculation for every number { if(i%j==0) { fact=1; break; //test will end and testing for another number will start from first loop } } if(fact==0) { pf("\n%d is prime number",i); continue; //the result will print and testing for another number will start from first loop } } return 0; }

Enter the first number: 5

Enter the second number: 30

5 is prime number

7 is prime number

11 is prime number

13 is prime number

17 is prime number

19 is prime number

23 is prime number

29 is prime number

Enter the second number: 30

5 is prime number

7 is prime number

11 is prime number

13 is prime number

17 is prime number

19 is prime number

23 is prime number

29 is prime number

- Print whether given number is prime or composite
- Prime number in a range
- Leap year in a range
- Print a multiplication table of Nth number
- Print even and odd number in a range
- Calculate power i.e., calculate x
^{n} - Calculate Summation of this series 1 + 1/2 + 1/3 + ...... + 1/x
- Calculate Summation of this series 1 + 1/5 + 1/9 + 1/13 + ...... + 1/x
- Calculate Summation of this series 1 + 2
^{2}+ 3^{3}+ ...... + x^{x} - Calculate Summation of this series 1 + 2
^{2}+ 3^{2}+ ...... + x^{2}

© 2018 - All rights reserved