Posts

Showing posts with the label C Language

Age and Gender Checking Program in C-language

Image
#include<stdio.h> void main() { char gen; //decleration of variable int age; //decleration of variable printf("Enter Your Gender, M for Male and F for Female"); scanf("%c",& gen); printf("Enter Your Age"); scanf("%i",& age); if(age > 16 && gen == 'F' || age > 16 && gen == 'f' ) { printf("Female is genius"); } else if(age > 16 && gen == 'M' || age > 16 && gen == 'm' ) { printf("Male have to do more effort"); } }

How to Check Even or Odd Number in C language

Image
#include<stdio.h> void main() { int num; //declaration of variables printf("Enter Any Number"); scanf("%i", &num); // getting the first value from user // if-else condition to check even or odd          if(num% 2 == 0) { printf("You have entered even number"); }         if(num% 2 == 1) { printf("You have entered odd number"); } }

C Program to Check Two Numbers If Even or Odd

Image
#include<stdio.h> void main() { int num1, num2; //declaration of variables printf("Enter First Number"); scanf("%i", &num1); // getting the first value from user printf("Enter Second Number"); scanf("%i", &num2); // getting the second value from user if(num1% 2 == 0 && num2% 2 == 0) { printf("You have entered two even numbers"); } if(num1% 2 == 1 && num2% 2 == 1) { printf("You have entered two odd numbers"); }         else { printf("You have entered one even number and one odd number"); } }

Calculator in C: Add, Sub, Mul and Div Using If-Else in C

Image
Related: Calculator in C language using a switch case. Calculator in C using the function.

C Basic data types Syntax: Int, Float, Character and Double

Image
In this post, I'll be discussing C language basic data types that are int, float, double and char. What are these? int - integer: used for a  whole number input. float - floating point: a number with a fractional part. double - a double-precision floating point value. char - a single character. C Basic Datatype Syntax Method 1 (int method): #include<stdio.h> int main() // the int needs to add return { //decleration of variable char c; // char data type variable decleration int i; // int data type variable decleration float f; // float data type variable decleration double d; // double data type variable decleration printf("Enter Any Character "); scanf("%c", &c); // %c is used to get character value printf("Enter Any Integer "); scanf("%i", &i); // %i or %d is used to get integer value printf("Enter Any Float "); scanf("%f", &f); // %f is used to get float va