Python not equal operator

  • Let's discuss python, not equal operators.  
  •  In python, there are different types of operators available,in that we have not equal operators.
  • Not equal to operator comes under the comparison operator as we compare the one variable with the other.
  • Python not equal to the operator is used for the same data type values.
  • When we compare one variable with another variable by using not equal operators we will get the boolean type values. bool type is True or False. if the values are not equal then it returns True value and if the values are equal then it returns the False value.
  • The syntax for not equal to is !=  mostly used in the python 3 versions.

#1. write a python program to describe not equal to operator using integer

  1. a=2.5
  2. b=1.0
  3. c=5.0
  4. print(a!=b)
  5. true
  6. print(b!=c)
  7. true
  8. print(a!=b!=c)
  9. true

python not equal operator

#2. write a python program to describe not equal to an operator using string

  • Python, not equal operator  using string
  1. x='apple'
  2. y='ball'
  3. print(x!=y)
output: true


C program to check whether a character is vowel or consonant

  • In this  program we will discuss about how to check whether a character is vowel or consonant.
  • In English language will be having 5 vowels and 21 consonants.
  • To check entered character is vowel or consonant, first Read input character from user using scanf.
  • There are only 5 vowels(A,E,I,O,U), so we need to check entered character is there in those 5 characters.
  • If it is present then we can say its an vowel, otherwise it is a consonant.
  • While checking we need to consider case sensitivity. So we need to check both uppercase vowels and lower case vowels.
  • Lets see an example program to check whether entered character is vowel or not.

check vowel or consonant in c


Write a program to determine whether the input character is a vowel or consonant or not an alphabet

  1. #include <stdio.h>
  2. //write a program to determine whether the input character is a vowel or consonant or not an alphabet
  3. //c program to check whether a character is vowel or consonant
  4. //www.InstanceofJava.com
  5. int main() {
  6.     char character;
  7.     int lowercaseVowel, uppercaseVowel;
  8.     printf("Enter a character  ");
  9.     scanf("%c", &character);

  10.     // assigns 1
  11.     lowercaseVowel = (character == 'a' || character == 'e' || character == 'i' || character == 'o' || character == 'u');

  12.     // evaluates to 1 if variable c is a uppercase vowel
  13.     uppercaseVowel = (character == 'A' || character == 'E' || character == 'I' || character == 'O' || character == 'U');

  14.     // evaluates to 1 (true) if c is a vowel
  15.     if (lowercaseVowel || uppercaseVowel)
  16.         printf("%c is a vowel.", character);
  17.     else
  18.         printf("%c is a consonant.", character);
  19.    getch();
  20. }


Output:
  1. Enter a character
  2. I
  3. I is an vowel


Print prime numbers from 1 to 100 in c

  • Lets discuss a program on how to print prime numbers from 1 to 100.
  • Here by default we need to print all prime numbers from 1 to 100.
  • No need to ask user to enter a number because we need to end loop at 100.
  • Using for loop iterate from 1 to 100
  • Take one more loop and check each number is divisible by 1 and itself or not.
  • Program to print prime number between 1 to 100 in c

#1.C program to print prime numbers from 1 to 100

  1. #include <stdio.h>

  2. // c program to print prime numbers from 1 to 100
  3. // www.instanceofjava.com
  4. int main()
  5. {
  6.    int n, i,k, count = 0;
  7.  
  8.  printf("Prime numbers from 1 to 100\n");
  9. for(i=2;i<=100;i++)
  10.  {
  11.   for(k=2;k<i;k++)
  12.   {
  13.    if(i%k==0)
  14.    break;
  15.    else if(i==k+1)
  16.    printf("%d\n",i);
  17. }
  18. }
  19.  
  20.     getch();
  21.     
  22. }
  23.     



prime numbers from 1 to 100



Sum of two integers in c

  •  Check here for printing an integer in c 
  • We have 4 basic data types in c programming language
  • int, char, float and double
  • For storing numbers or integers we will use int data type.
  • Lets see an example program sum of two integers in c programming language.
  • To add two integers we need two int type variables and third variable to store result of sum of two integers.
  • Its a basic level example program for beginners to understand integer data types

sum of two integers in c


Write a C program to add two integers / find sum of two integers in c

  1. #include<stdio.h>
  2. // c program to print integer using %d
  3. // c print integer
  4. //www.instanceofjava.com
  5. int main()
  6. {
  7.             //declare an integer variable 
  8. int number1, number2, sumOfTwoIntegers;
  9.             // read input from user using scanf
  10. printf ("Enter any two integers: ");
  11. scanf (" %d%d", &number1,&number2);
  12. //sum of two integers in c
  13. sumOfTwoIntegers=number1+number2;
  14.    //print the same number using %d
  15. printf("Sum of two integers : %d", sumOfTwoIntegers);
  16. getch();
  17. }
Output:
  1. Enter any two integers:
  2. 10
  3. 20
  4. Sum of two integers : 30

Print an integer in c language

  • For declaring numbers we use int data type in c.
  • In order to read using scanf we use %d.
  • using printf we can print same variable. 

print interger in c


#Write a C Program to print an integer 

  1. #include<stdio.h>
  2. // c program to print integer using %d
  3. // c print integer
  4. //www.instanceofjava.com
  5. int main()
  6. {
  7.             //declare an integer variable 
  8. int number;
  9.             // read input from user using scanf
  10. printf ("Enter an Integer: ");
  11. scanf (" %d", &number);
  12.    //print the same number using %d
  13. printf("You Entered : %d", number);
  14. getch();
  15. }

Output:
  1. Enter an Integer: 3
  2. You Entered : 3

Sum of even numbers in c

  • Please check this below program which prints even numbers from 1 to n.
  • Print even numbers in c 
  • To print sum of even numbers from 1 to n first we need to get all the even numbers and add them.
  • Using for or while loop iterate from 1 to n number and get all even numbers
  • sum=sum+evenNumber
  • C program to find sum of even numbers using while loop

sum of even numbers in c

C program to find sum of even numbers using while loop

  1. #include<stdio.h> 
  2. //write a program to print even numbers in c using while loop
  3. //www.instanceofjava.com
  4. int main()
  5. {
  6.     // declare variables 
  7.     int number,i,sum=0;
  8.     //read input from user 
  9.     printf("Enter a number: ");
  10.     scanf("%d", &number);

  11.    //iterate and check if it a even number or not 
  12.      i=1;
  13.        
  14.         while(i<=number){
  15.                 
  16.         if(i%2 ==0){
  17.         
  18.           printf("%d\n" ,i);
  19.            sum=sum+i;    
  20.         }
  21.           i++  ;  
  22.         }
  23.          printf("sum of all even numbers = %d",sum);
  24.          
  25.    getch();
  26. }


Output:
  1. Enter a number:8
  2. 2
  3. 4
  4. 6
  5. 8
  6. sum of all even numbers= 20


Print even numbers in c

  • Lets see how to write a c program to print even numbers using c programming.\
  • Its a basic example to print only even numbers 
  • Use for loop and iterate from 1 to n.
  • In each iteration check if number if divisible by 2 (n%2 == 0). if yes then its a even number otherwise it is a odd number.
  • C program to print even numbers from 1 to n. 
print even numbers in c


  1. #include<stdio.h> 
  2. //write a program to print even numbers in c 
  3. //www.instanceofjava.com
  4. int main()
  5. {
  6.     // declare variables 
  7.     int number,i;
  8.     //read input from user 
  9.     printf("Enter a number: ");
  10.     scanf("%d", &number);

  11.    //iterate and check if it a even number or not 
  12.   
  13.     for (i=1; i<=number; i++){
  14.         
  15.         if(i%2 ==0){
  16.           printf("%d\n" ,i);
  17.                
  18.         }
  19.               
  20.         }
  21.         
  22.    getch();
  23. }


Output:
  1. Enter a number: 12
  2. 2
  3. 4
  4. 6
  5. 8
  6. 10
  7. 12


#2 print even numbers in c using while loop

  • Now we will try to print even numbers using while loop
  • Only difference is replace for with while loop
  • Variable initialization will be done before loop
  • condition will be inside while(condition)
  • increment or decrement will be last line of while block 
  • Lets print even numbers using while loop from 1 to n.


  1. #include<stdio.h> 
  2. //write a program to print even numbers in c using while loop
  3. //www.instanceofjava.com
  4. int main()
  5. {
  6.     // declare variables 
  7.     int number,i;
  8.     //read input from user 
  9.     printf("Enter a number: ");
  10.     scanf("%d", &number);

  11.    //iterate and check if it a even number or not 
  12.      i=1;
  13.        
  14.         while(i<=number){
  15.                 
  16.         if(i%2 ==0){
  17.           printf("%d\n" ,i);
  18.                
  19.         }
  20.           i++  ;  
  21.         }
  22.         
  23.    getch();
  24. }


Output:
  1. Enter a number: 20
  2. 2
  3. 4
  4. 6
  5. 8
  6. 10
  7. 12
  8. 14
  9. 16
  10. 18
  11. 20


Select Menu