Showing posts with label C Programs. Show all posts
Showing posts with label C Programs. Show all posts

Sunday, 14 December 2014

C PROGRAM TO CONVERT A SINGLE LOWERCASE CHAR INTO UPPERCASE

Write a program to convert a single lowercase character into uppercase character.

#include<stdio.h>
#include<conio.h>
int main()
{
char a, b;
clrscr();
printf("enter a single character in lowercase\n");
a=getchar();
b=toupper(a);
putchar(b);
getch();
return(0);
}

OUTPUT:
Enter a single character in lowercase
h

H

C PROGRAM TO DISPLAY A SINGLE CHARACTER ENTERED BY THE USER ON THE SCREEN

Write a program to display what ever you want:

#include<stdio.h>
#include<conio.h>
int main()
{
char a;
clrscr();
printf("Enter any single character that you want to print on screen\n");
a= getchar();
putchar(a);
getch();
return(0);
}

OUTPUT:
Enter any single character that you want to print on screen
H

H

C PROGRAM AREA OF RECTANGLE

Write a program to find the Area of Rectangle:

#include<stdio.h>
#include<conio.h>
int main()
{
int area, a, b;
clrscr();
printf("Enter the two sides of the reactangle");
scanf("%d%d",&a,&b);
area=a*b;
printf("Area is %d",area)
getch();
return(0);
}

OUTPUT:
Enter the two sides of the reactangle 5 6

Area is 30

C PROGRAM TO CALCULATE SUBTRACTION AND ADDITION(USING FUNCTION)

Write a program to calculate the Subtraction and addition of two numbers by using functions.

#include<stdio.h>
#include<conio.h>
int sum(int, int);
int sub(int, int);
int main()
{
int a, b, c, d;
clrscr();
printf(" Enter the two numbers");
scanf("%d%d",&a,&b);
c=sum(a, b);
d=sub(a, b);
printf("The sum of the number is %d and the difference is %d",c,d);
getch();
return(0);
}
int sum(int x, int y)
{
int z;
z=x+y;
return(z);
}
int sub(int x, int y)
{
int z;
z=x-y;
return(z);
}

OUTPUT:
Enter the two numbers 8 4

The sum of the number is 12 and the difference is 4

C PROGRAM TO FIND SUM OF TWO NUMBERS (USING FUNCTION)

Write a program to find the sum of two numbers using function:

#include<stdio.h>
#include<conio.h>
int sum(int a, int b)
{
int c;
c=a+b;
return(c);
}
int main()
{
int x, y, z;
printf("Enter the two numbers");
scanf("%d %d",&x,&y);
z=sum(x,y);
printf("Sum of %d + %d is %d",x,y,z);
getch();
return(0);
}

Output:
Enter the two numbers
4 4

Sum of 4 + 4 is 8