Showing posts with label Console. Show all posts
Showing posts with label Console. 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 Defines the entry point for the console application

How to write a C Program to Defines the entry point for the console application in C Programming Language ?


Solution:


//Defines the entry point for the console application 
#include "stdio.h"


int main(int argc, char argv[])
{
  unsigned int x,y,p,n,ergebnis;
 printf("Bitte gegen sie die Zahl ein die Veraendert werden soll: ");
 scanf("%d", &x);
 printf("\nBitte geben sie die Zahl ein von der die zu Veraendernde Bits kommen sollen:");
 scanf("%d", &y);
 printf("\nBitte geben sie die Position der Bits ein von der an die Veraenderung stattfinden soll (Zaehlung beginnt rechts mit Bit 0): ");
 scanf("%d", &p);
 printf("\nBitte geben sie die Anzahl der Bits ein die veraendert werden sollen: ");
 scanf("%d", &n);
 ergebnis= ~y;
 ergebnis= ergebnis << (32-n);
 ergebnis= ergebnis >> (32-(p+1));
 ergebnis= ergebnis ^ x;
 ergebnis= ergebnis & x;
 printf("\n%d\n",ergebnis);
 
 char ch;
 scanf("%c",& ch);
 getchar();
 return 0;
}

C Program to Defines the entry point for the console application

How to write a C Program to Defines the entry point for the console application in C Programming Language ?


Solution:
/*Defines the entry point for the console application*/
//Defines the entry point for the console application.