ap3d #include <iostream> using namespace std ; //Program to print all the odd numbers till "n". int main (){ int n ; cout << "Enter a number: " ; cin >> n ; cout << "All the odd numbers till " << n << " are:" << endl ; for ( int i = 2 ; i <= n ; i ++){ if ( i % 2 == 0 ){ continue ; } cout << i << endl ; } return 0 ; }
ap3c #include <iostream> using namespace std ; //Program to print all the even numbers till "n". int main (){ int n ; cout << "Enter a number: " ; cin >> n ; cout << "All the even numbers till " << n << " are:" << endl ; for ( int i = 1 ; i <= n ; i ++){ if ( i % 2 != 0 ){ continue ; } cout << i << endl ; } return 0 ; }
ap3b #include <iostream> using namespace std ; //Print number from 1 to 100, skip nos. divisible by 3. int main (){ for ( int i = 0 ; i <= 100 ; i ++){ if ( i % 3 == 0 ){ continue ; } cout << i << endl ; } return 0 ; }
ap2m #include <iostream> using namespace std ; //Program to display multiplication table upto 10.(for loop) int main (){ int n ; cout << "Enter a positive number : " ; cin >> n ; cout << "Table of " << n << endl ; for ( int i = 1 ; i <= 10 ; ++ i ){ cout << n << " * " << i << " = " << n * i << endl ; } return 0 ; }
ap2j #include <iostream> using namespace std ; //Program to find sum of natural numbers till n.(for loop) int main (){ int n ; cout << "Enter number 'n' : " ; cin >> n ; int sum = 0 ; for ( int counter = 1 ; counter <= n ; counter ++){ sum = sum + counter ; } cout << "sum : " << sum << endl ; return 0 ; }