0% found this document useful (0 votes)
20 views

Program To Print The No Is Odd or Even

The document contains 6 C programming code snippets that perform various tasks: 1) Checks if a number entered is odd or even 2) Checks if a number is positive, negative, or zero 3) Reads two numbers from the user 4) Performs arithmetic operations (addition, subtraction, etc.) on the two numbers based on user selection 5) Checks if a character is uppercase, lowercase, digit or not an alphabet 6) Reads a character and prints its ASCII value

Uploaded by

happydsurvivor
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Program To Print The No Is Odd or Even

The document contains 6 C programming code snippets that perform various tasks: 1) Checks if a number entered is odd or even 2) Checks if a number is positive, negative, or zero 3) Reads two numbers from the user 4) Performs arithmetic operations (addition, subtraction, etc.) on the two numbers based on user selection 5) Checks if a character is uppercase, lowercase, digit or not an alphabet 6) Reads a character and prints its ASCII value

Uploaded by

happydsurvivor
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

program to print the no is odd or even

#include<stdio.h> main() { int n; printf("\n Enter any number: "); scanf("%d",&n); if(n%2==0) { printf("the number is even"); } else { printf("the number is odd"); } getch(); }

program to check whether a number entered by user is positive , negative or zero


#include<stdio.h> main() { int n, i; printf("Enter a number: "); scanf("%d",&n); if(n>0) { printf("the number is positive"); } if(n<0) {

printf("the number is negative"); } if(n==0) { printf("the number is zero"); } getch(); }

program to read two values from user


#include<stdio.h> main() { int a,b,c,d,e,f,g,h; printf("Enter two number: "); scanf("%d%d",&a,&b);

printf("\n Press 1 for Addition"); printf("\n Press 2 for Subtractiont"); printf("\n Press 3 for Multiplication"); printf("\n Press 4 for Division"); printf("\n Press 5 for Modulus"); printf("\n Enter your choice: "); scanf("%d",&c); if(c==1) { d = a + b; printf(" Addition : %d",d); } if(c==2) {

e = a-b; printf("\n Subtraction: %d",e); } if(c==3) { f = a*b; printf("\n Multiplication: %d",f); } if(c==4) { g = a/b; printf("\n Division: %d",g); } if(c==5) { h = a%b; printf("\n Modulus: %d",h); } getch(); }

check whether character entered by user is capital or small or not an alphabet


#include<stdio.h> main() { char i; printf("Enter any character: "); scanf("%c",&i); if(i>=65 && i<=90) { printf("\n The character is an uppercase letter"); }

if(i>=97 && i<=122) { printf("\n The character is an lowercase letter"); } if(i>=48 && i<=57) { printf("\n The character is an digit"); } getch(); }

program to read a character from user & print its ASCII value
#include<stdio.h> main() { int i; char a; printf("Enter any character: "); scanf("%c",&a); i=a; printf("Ascii value= %d",i); getch(); }

program to read small character from keyboard & convert it into capital
#include<stdio.h> main() { char a; printf("Enter any character: "); scanf("%c",&a); if(97<a<122) {

a=a-32; printf("\n Lowercase letters=%c",a); } if(65<a<90) { a=a+32; printf("\n Uppercase letters=%c",a); } getch(); }

You might also like