You are on page 1of 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