Showing posts with label Convert. Show all posts
Showing posts with label Convert. Show all posts

How To Write a C program that reads your first and last names and then converts them to upper-case and lower-case letters. The results will be printed to standard output console.

Write a C program that reads your first and last names and then converts them to upper-case and lower-case letters. The results will be printed to standard output console.



  1. //Write a C program that reads your first and last names and then converts them to upper-case and lower-case letters. The results will be printed to standard output console.
  2. #include<string.h>
  3. #include<iostream>
  4. using namespace std;
  5. int main()
  6. {
  7.     char c1[20],c2[20];
  8.     int i;
  9.     cin>>c1;
  10.     cin>>c2;
  11.     for(i=0;i<strlen(c1);i++)
  12.         if(c1[i]>='a'&&c1[i]<='z')
  13.             c1[i]=c1[i]-32;
  14.         else
  15.             if(c1[i]>='A'&&c1[i]<='Z')
  16.                 c1[i]=c1[i]+32;
  17.     for(i=0;i<strlen(c2);i++)
  18.         if(c2[i]>='a'&&c2[i]<='z')
  19.             c2[i]=c2[i]-32;
  20.         else
  21.             if(c2[i]>='A'&&c2[i]<='Z')
  22.                 c2[i]=c2[i]+32;
  23.         cout<<c1<<" "<<c2;
  24. }

C Program To Convert Decimal To Binary Using Recursion

How to write a C Program To Convert Decimal To Binary Using Recursion in C Programming Language ?

Solution For C Program :

/*C Program To Convert Decimal To Binary Using Recursion*/

#include<stdio.h>
void main()
{
void dectobin(int);
int n;
printf("\nEnter Any Decimal Number : ");
scanf("%d", &n);
dectobin(n);
}
void dectobin(int a)
{
int d;
d = a % 2;
if(a != 0)
{
dectobin(a / 2);
printf("%d", d);
}
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

C Program To Convert Temperature In Celsius To Fahrenheit, Using Function

How to write a C Program/Code To Convert Temperature In Celsius To Fahrenheit, Using Function in C Programming Language ?


Solution For C Program : 

/*C Program To Convert Temperature In Celsius To Fahrenheit, Using Function*/

#include <stdio.h>
void main()
{
void Fahrenheit(float c);
float c;
printf("\nEnter the Temperature in Celsius : ");
scanf("%f", &c);
Fahrenheit(c);
}
void Fahrenheit(float c)
{
printf("\nThe Temperature %0.2f Celsius = %0.2f Fahrenheit.", c, ( 9 * c) / 5 + 32);
return;
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable