#include <stdio.h>
#include <conio.h>
main()
{
char ch;
clrscr();
printf("\n Enter any character ");
scanf("\n %c",&ch);
if(ch>=65&&ch<=90)
{
printf("\n Character entered is Capital letter");
}
else
{
if(ch>=97&&ch<=122)
{
printf("\n Character entered is small letter");
}
else
{
if(ch>=48&&ch<=57)
{
printf("\n character is digit");
}
else
{
printf("Character is special symbols");
}
}
}
return(0);
}
output:-
enter the any character =50
character is digit
enter the character =120
character is small letter
Welcome ! to C Language Extreme Programmings Blog through learn the programming complete examples.
Write a c program to prints an ascii numbers.
#include <stdio.h>
#include <conio.h>
#define and &&
main()
{
int num=48;
clrscr();
while(num>=48&&num<=60)
{
printf("\n ascii= %d character = %c",num,num);
num++;
}
return(0);
}
output:-
ascii =48 character =0
ascii =49 character =1
ascii =50 character =2
ascii =51 character =3
ascii =52 character =4
ascii =53 character =5
ascii =54 character =6
ascii =55 character =7
ascii =56 character =8
ascii =57 character =9
ascii =58 character = :
ascii =59 character = ;
ascii =60 character = <
#include <conio.h>
#define and &&
main()
{
int num=48;
clrscr();
while(num>=48&&num<=60)
{
printf("\n ascii= %d character = %c",num,num);
num++;
}
return(0);
}
output:-
ascii =48 character =0
ascii =49 character =1
ascii =50 character =2
ascii =51 character =3
ascii =52 character =4
ascii =53 character =5
ascii =54 character =6
ascii =55 character =7
ascii =56 character =8
ascii =57 character =9
ascii =58 character = :
ascii =59 character = ;
ascii =60 character = <
Write a C program to find absolute value of a number.
#include <stdio.h>
#include <conio.h>
main()
{
int num;
clrscr();
printf("\n Enter any num to find absolute value");
scanf("\n %d",&num);
if(number<0)
{
num=(-1)*num;
printf("\n Absolute value is =%d",num);
}
return (0);
}
output:-
enter the value of num =-100
Absolute value
#include <conio.h>
main()
{
int num;
clrscr();
printf("\n Enter any num to find absolute value");
scanf("\n %d",&num);
if(number<0)
{
num=(-1)*num;
printf("\n Absolute value is =%d",num);
}
return (0);
}
output:-
enter the value of num =-100
Absolute value
Write a C program to check if all the three points fall on one straight line.
#include <stdio.h>
#include <conio.h>
main()
{
int x1,y1,x2,y2,x3,y3,x4,y4,slope1,slope2;
clrscr();
printf("\n Enter 1st co-ordinate (x1,y1)");
scanf("\n %d%d",&x1,&y1);
printf("\n Enter 2nd co-ordinate (x2,y2)");
scanf("\n %d%d",&x2,&y2);
printf("\n Enter 3rd co-ordinate (x3,y3)");
scanf("\n %d%d",&x3,&y3);
slope1=(y2-y1)/(x2-x1);
slope2=(y3-y2)/(x3-x2);
if(slope1==slope2)
{
printf("\n Three points fall on the same line");
}
else
{
printf("\nThree points doesn't fall on the same line");
}
return (0);
}
output:-
Enter 1st co-ordinate (x1,y1) =(1,1)
Enter 2nd co-ordinate (x2,y2) =(1,1)
Enter 3rd co-ordinate (x3,y3) =(1,1)
Three points fall on the same line
#include <conio.h>
main()
{
int x1,y1,x2,y2,x3,y3,x4,y4,slope1,slope2;
clrscr();
printf("\n Enter 1st co-ordinate (x1,y1)");
scanf("\n %d%d",&x1,&y1);
printf("\n Enter 2nd co-ordinate (x2,y2)");
scanf("\n %d%d",&x2,&y2);
printf("\n Enter 3rd co-ordinate (x3,y3)");
scanf("\n %d%d",&x3,&y3);
slope1=(y2-y1)/(x2-x1);
slope2=(y3-y2)/(x3-x2);
if(slope1==slope2)
{
printf("\n Three points fall on the same line");
}
else
{
printf("\nThree points doesn't fall on the same line");
}
return (0);
}
output:-
Enter 1st co-ordinate (x1,y1) =(1,1)
Enter 2nd co-ordinate (x2,y2) =(1,1)
Enter 3rd co-ordinate (x3,y3) =(1,1)
Three points fall on the same line
Write a c program to determine whether the seller profit or loss.
#include <stdio.h>
#include <conio.h>
main()
{
int cp,sp,total;
clrscr();
printf("\n enter cost price ");
scanf("\n %d",&cp);
printf("\n enter selling price");
scanf("\n %d",&sp);
total=sp-cp;
total=cp-sp;
if(total>0)
{
printf("\n total profit =%d",total);
}
else
{
if(total<0)
{
printf("\n total Loss =%d",total);
}
else
{
printf("\n neither total loss nor total profit");
}
}
return(0);
}
output:-
enter the cost price (cp) =100
enter the sell price (sp) =200
total profit =100
#include <conio.h>
main()
{
int cp,sp,total;
clrscr();
printf("\n enter cost price ");
scanf("\n %d",&cp);
printf("\n enter selling price");
scanf("\n %d",&sp);
total=sp-cp;
total=cp-sp;
if(total>0)
{
printf("\n total profit =%d",total);
}
else
{
if(total<0)
{
printf("\n total Loss =%d",total);
}
else
{
printf("\n neither total loss nor total profit");
}
}
return(0);
}
output:-
enter the cost price (cp) =100
enter the sell price (sp) =200
total profit =100
Subscribe to:
Posts (Atom)