55555
4444
333
22
1
#include <stdio.h>
int main()
{
int i,j;
for(i=5; i>=1; i--)
{
for(j=1; j<=i; j++)
{
printf("%d", i);
}
printf("\n");
}
return 0;
}
C Programming Guide
Monday, June 22, 2020
Pattern
55555
4444
333
22
1
#include <stdio.h>
int main()
{
int i,j;
for(i=5; i>=1; i--)
{
for(j=5; j>i; j--)
{
printf(" ");
}
for(j=1; j<=i; j++)
{
printf("%d", i);
}
printf("\n");
}
return 0;
}
4444
333
22
1
#include <stdio.h>
int main()
{
int i,j;
for(i=5; i>=1; i--)
{
for(j=5; j>i; j--)
{
printf(" ");
}
for(j=1; j<=i; j++)
{
printf("%d", i);
}
printf("\n");
}
return 0;
}
Pattern " * "
* * * * *
* * * *
* * *
* *
*
#include <stdio.h>
int main() { int i,j; for(i=1; i<=5; i++){ for(j=i; j<=5; j++){ printf("*"); } printf("\n"); } return 0; }
or
#include <stdio.h> int main() { for (int i = 5; i >= 1; i--) { for (int j = i; j >= 1; j--) { printf("*"); } printf("\n"); } return 0; }
* * * *
* * *
* *
*
#include <stdio.h>
int main() { int i,j; for(i=1; i<=5; i++){ for(j=i; j<=5; j++){ printf("*"); } printf("\n"); } return 0; }
or
#include <stdio.h> int main() { for (int i = 5; i >= 1; i--) { for (int j = i; j >= 1; j--) { printf("*"); } printf("\n"); } return 0; }
Thursday, June 18, 2020
WAP to input a string and check if it's last letter is number or not.
#include <stdio.h>
int main() { name[100] last one = length - 1 i.e 100 - 1 = 99
name[99] gives last value 0-9 48 - 57 ( number ) char a[10];
printf("enter");
scanf("%s",a);
int as = a[9];
if (as >= 48 && as <=57){
printf("number");
} else{
printf("not");
}
return 0;
}
int main() { name[100] last one = length - 1 i.e 100 - 1 = 99
name[99] gives last value 0-9 48 - 57 ( number ) char a[10];
printf("enter");
scanf("%s",a);
int as = a[9];
if (as >= 48 && as <=57){
printf("number");
} else{
printf("not");
}
return 0;
}
WAP to input a string and check if it's 1st letter is uppercase or not.
#include<stdio.h>
int main() A-Z 65 - 90 ( uppercase alphabet )
{
char alive;
int ascii;
printf("enter number");
scanf("%c",&alive);
ascii=alive;
if(ascii>=65 && ascii<=90){
printf("uppercase");
}
else{
printf("not");
}
return 0;
}
int main() A-Z 65 - 90 ( uppercase alphabet )
{
char alive;
int ascii;
printf("enter number");
scanf("%c",&alive);
ascii=alive;
if(ascii>=65 && ascii<=90){
printf("uppercase");
}
else{
printf("not");
}
return 0;
}
WAP to check if the input character is vowel or not. ( a e i o u )
#include<stdio.h>
int main()
{
char vol;
int ascii;
printf("enter number");
scanf("%c",&vol);
ascii=vol;
if(ascii=='a' || ascii=='e' || ascii=='i' || ascii=='o' || ascii=='u'){
printf("vowel");
}
else{
printf("not vowel");
}
}
int main()
{
char vol;
int ascii;
printf("enter number");
scanf("%c",&vol);
ascii=vol;
if(ascii=='a' || ascii=='e' || ascii=='i' || ascii=='o' || ascii=='u'){
printf("vowel");
}
else{
printf("not vowel");
}
}
WAP to check if the input character is lowercase alphabet or not.
#include<stdio.h> {ascii value of a-z is 97 - 122}
int main()
{
char alive;
int ascii;
printf("enter number");
scanf("%c",&alive);
ascii=alive;
if(ascii>=97 && ascii<=122){
printf("lowercase");
}
else{
printf("not");
}
return 0;
}
Subscribe to:
Posts (Atom)
pattern
55555 4444 333 22 1 #include <stdio.h> int main() { int i,j; for(i=5; i>=1; i--) { for(j=1; j<=i;...
-
#include<stdio.h> #include<conio.h> void main() { int n,r,rev=0; printf("Enter a number"); scanf("%d&quo...
-
#include<stdio.h> int main() { char vol; int ascii; printf("enter number"); scanf("%c",&vol); asc...
-
#include <stdio.h> int main() { ...