SOME IMPORTANT TRICKY PROGRAM OF 'C ' LANGUAGE
- Write a program to press 1 and gets 0 and when press 0 gets 1.
- Write a program where the user enter small letter but shown capital letter if the user enter capital letter then shown small letter.
- Write a program to show the ASCII value of input character which one you press.
- Write a program to show a string with out using semi colon (;).
- Write a program to show the input character is vowel or not.
- Write a program to show the next character which one you press.
- Write a program where the user enter the ASCII code and show the corresponding value on the screen.
CODE:
/* PRESS 1 TO SHOW 0 AND PRESS 0 TO SHOW 1 */
#include <stdio.h>
#include <conio.h>
int main()
{
char a;
printf("PRESS 1 OR 0 : ");
a = getch();
if(a ==48)
a++;
else
a--;
printf("%c",a);
getch();
return 0;
}
DISCUSSION:
Q2. Write a program where the user enter small letter but shown capital letter if the user enter capital letter then shown small letter.
CODE:
#include <stdio.h>
#include <conio.h>
int main()
{
char a;
printf("ENTER YOUR LETTER: ");
a = getch();
if(a >=96)
a-=32;
else
a+=32;
printf("%c",a);
getch();
return 0;
}
DISCUSSION:
Write a program to show the ASCII value of input character which one you press.
CODE:
/*Write a program to show the ASCII code of input character*/
#include<stdio.h>
#include<conio.h>
int main()
{
char a;
printf("\nEnter your character:= ");
a = getch();
printf("%d",a);
return 0;
}
OUTPUT:
DISCUSSION:
Write a program to show a string with out using semi colon (;).
Write a program to show the input character is vowel or not.
CODE:
/*rite a program to show the input character is vowel or not.*/
#include <stdio.h>
#include <conio.h>
int main()
{
char a;
printf("Enter your character: ");
a=getch();
if(a == 'a' || a == 'A' ||a == 'e' ||a == 'E' ||a == 'i' ||a == 'I' ||a == 'o' ||a == 'O' ||a == 'u' ||a == 'U')
printf("\n %c = VOWLE",a);
else
printf("\n %c = CONSONENT",a);
return 0;
}
Write a program to show the next character which one you press.
CODE:
/*Write a program to show the next character which one you press.*/
#include <stdio.h>
#include <conio.h>
int main()
{
char a;
printf("Enter your character: ");
a = getch();
printf("%c",++a);
return 0;
}
OUTPUT:
DISCUSSION:
Write a program where the user enter the ASCII code and show the corresponding value on the screen.
CODE
/*Write a program where the user enter the ASCII code and show the corresponding value on the screen.*/
#include <stdio.h>
#include <conio.h>
int main()
{
int a;
printf("Enter your ASCII code: ");
scanf("%d",&a);
printf("\n%c",a);
getch();
return 0;
}
OUTPUT:
OUTPUT:
DISCUSSION:
/*Write a program to show the ASCII code of input character*/
#include<stdio.h>
#include<conio.h>
int main()
{
char a;
printf("\nEnter your character:= ");
a = getch();
printf("%d",a);
return 0;
}
OUTPUT:
DISCUSSION:
Write a program to show a string with out using semi colon (;).
Write a program to show the input character is vowel or not.
CODE:
/*rite a program to show the input character is vowel or not.*/
#include <stdio.h>
#include <conio.h>
int main()
{
char a;
printf("Enter your character: ");
a=getch();
if(a == 'a' || a == 'A' ||a == 'e' ||a == 'E' ||a == 'i' ||a == 'I' ||a == 'o' ||a == 'O' ||a == 'u' ||a == 'U')
printf("\n %c = VOWLE",a);
else
printf("\n %c = CONSONENT",a);
return 0;
}
OUTPUT:
DISCUSSION:
CODE:
/*Write a program to show the next character which one you press.*/
#include <stdio.h>
#include <conio.h>
int main()
{
char a;
printf("Enter your character: ");
a = getch();
printf("%c",++a);
return 0;
}
OUTPUT:
DISCUSSION:
Write a program where the user enter the ASCII code and show the corresponding value on the screen.
CODE
/*Write a program where the user enter the ASCII code and show the corresponding value on the screen.*/
#include <stdio.h>
#include <conio.h>
int main()
{
int a;
printf("Enter your ASCII code: ");
scanf("%d",&a);
printf("\n%c",a);
getch();
return 0;
}
OUTPUT:
OUTPUT:
DISCUSSION: