Wednesday, July 31, 2019

Alphabet patterns6

Alphabet patterns6:


Alphabet Patterns in cprograms


EEEEE
DDDDD
CCCCC
BBBBB
AAAAA


#include<stdio.h>
#include<conio.h>

void main()
{
char i,j;
clrscr();
for(i='E';i>='A';i--)
{
for(j='E';j>='A';j--)
{
printf("%c",i);
}
printf("\n");
}
getch();
}

Alphabet Patterns5

Alphabet Patterns5:


alphabet patternsin cprograms


A
AB
ABC
ABCD
ABCDE


#include<stdio.h>
#include<conio.h>

void main()
{
char i,j;
clrscr();
for(i='A';i<='E';i++)
{
for(j='A';j<=i;j++)
{
printf("%c",j);
}
printf("\n");
}
getch();
}

Alphabet Patterns4

Alphabet Patterns4:


alphabet patterns in cprograms


A
BB
CCC
DDDD
EEEEE


#include<stdio.h>
#include<conio.h>

void main()
{
char i,j;
clrscr();
for(i='A';i<='E';i++)
{
for(j='A';j<=i;j++)
{
printf("%c",i);
}
printf("\n");
}
getch();
}

Alphabet Pattern3

Alphabet Pattern3:

alphabet patterns in cprograms


EDCBA
EDCBA
EDCBA
EDCBA
EDCBA


#include<stdio.h>
#include<conio.h>

void main()
{
char i,j;
clrscr();
for(i='E';i>='A';i--)
{
for(j='E';j>='A';j--)
{
printf("%c",j);
}
printf("\n");
}
getch();
}

Monday, July 29, 2019

Alphabet Pattern2

Alphabet Pattern2:







ABCDE
ABCDE
ABCDE
ABCDE
ABCDE


#include<stdio.h>
#include<conio.h>

void main()
{
char i,j;
clrscr();
for(i='A';i<='E';i++)
{
for(j='A';j<='E';j++)
{
printf("%c",j);
}
printf("\n");
}
getch();
}

Alphabet Pattern1

Alphabet Pattern1:




AAAAA
BBBBB
CCCCC
DDDDD
EEEEE


#include<stdio.h>
#include<conio.h>

void main()
{
char i,j;
clrscr();
for(i='A';i<='E';i++)
{
for(j='A';j<='E';j++)
{
printf("%c",i);
}
printf("\n");
}
getch();
}

Numeric Pattern5

Numeric Pattern5:





10101
10101
10101
10101
10101

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
printf("%d",j%2);
}
printf("\n");
}
getch();
}

Numeric Pattern4

Numeric Pattern4:




11111
00000
11111
00000
11111

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if(i%2==0)
{
printf("0");
}
else
{
printf("1");
}
}
printf("\n");
}
getch();
}

Sunday, July 28, 2019

Numeric Pattern3

Numeric Pattern3:



55555
44444
33333
22222
11111

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j;
clrscr();
for(i=5;i>=1;i--)
{
for(j=1;j<=5;j++)
{
printf("%d",i);
}
printf("\n");
}
getch();
}

Numeric Pattern2

Numeric Pattern2:


11111
22222
33333
44444
55555


#include<stdio.h>
#include<conio.h>

void main()
{
int i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
printf("%d",i);
}
printf("\n");
}
getch();
}

Numeric Pattern1

Numeric Patterns:



11111
11111
11111
11111
11111

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
printf("1");
}
printf("\n");
}
getch();
}

Pattern 3

Pattern 3:



*****
****
***
**
*

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j;
clrscr();

for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();

}

Pattern2

Pattern2:




*
**
***
****
*****

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j;
clrscr();

for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}

Pattern1 Programs

Patterns 1.




*****
*****
*****
*****
*****

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
printf("*");
}
printf("\n");
}
getch();
}

Saturday, July 27, 2019

Revers String without strrev() function

Revers String without strrev() function:


Revers String without strrev() function


#include<stdio.h>
#include<conio.h>

void main()
{
int i,j,k;
char str[100];
char rev[100];
clrscr();

printf("Enter A String:-");
gets(str);

for(i=0;str[i]!='\0';i++)
{

}

       // printf("The Original String is%d\n",i);

   k = i;
for(j=0;j<=k;j++ , i--)
{
rev[j]=str[i];
printf("%c" , str[i]);
}

printf("The Revers String is %s\n",rev);
getch();
}

Output:





String in strcat() function

String in strcat() function:


String in strcat() function


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[]="this is", b[]="cprograms";
clrscr();

strcat(a,b);

puts(a);
puts(b);

getch();
}

Output:




String in strcpy() function

String in strcpy() function:


String in strcpy() function



The strcpy() function is defined in <string.h> header file.

The strcpy() function copies the string pointed by source

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[20]="cprograms";
char b[20];
char c[20];
clrscr();

strcpy(b,a);
strcpy(c,"hii");
puts(b);
puts(c);
getch();

}

Output:


String in strcmp() function

String in strcmp() function:

String in strcmp() function



in cproframs strcmp() function are Depended Ascii Value.

0:if both strings are identical (equal)
negative: if the ASCII value of first unmatched character is less than second.
positive integer:if the ASCII value of first unmatched character is greater than second.



#include<stdio.h>
#include<conio.h>

void main()
{
char name[]="abcd",name1[]="abcD",name2[]="abcd";
int result;
clrscr();
result=strcmp(name,name1);
printf("strcmp(name and name1)=%d\n",result);

result=strcmp(name,name2);
printf("strcmp(name and name2)=%d\n",result);

getch();
}

Output:


string len()function find length

string len()function find length:

string len()function find length


#include<stdio.h>
#include<conio.h>
void displaylen(char length[]);
void main()
{
char name[20];
clrscr();
printf("Enter Your Name :- ");
gets(name);

displaylen(name);
getch();
}
void displaylen(char length[])
{
int len;
len=strlen(length);

printf("length is %d",len);

}

Output:


passing string to a function print the name

passing string to a function print the name.


passing string to a function print the name



#include<stdio.h>
#include<conio.h>
void displayname(char name1[]);
void main()
{
char string[20];
clrscr();
printf("Enter Your Name:-");
gets(string);

displayname(string); // Passing The Function..
getch();
}
void displayname(char name1[])
{
puts(name1); //
}

Output:


string print the name

String print the name.


string print the name



// Include<string.h> including header file.

#include<stdio.h>
#include<conio.h>

void main()
{
char name1[20];
clrscr();
printf("Enter Your Name :-");
scanf("%s",&name1);


puts(name1);
getch();
}

Output:





print  the name with puts() and gets().

gets() and scanf() both are used to received input from the users.but gets() are show full string.

#include<stdio.h>
#include<conio.h>

void main()
{
char name1[20];
clrscr();
printf("Enter Your Name :-");
gets(name1);


puts(name1);
getch();
}

Output:













Thursday, July 25, 2019

Find Factors of any number

Tags
Find Factors of any number:


find a factors of any number.



#include<stdio.h>
#include<conio.h>

void main()
{
int i,no;
clrscr();
printf("Enter Your Number :- ");
scanf("%d",&no);

printf("Your Factor Numbers Are:-\n");

for(i=1;i<=no;i++)
{
if(no%i ==0)
{
printf("%d\n",i);
}
}
getch();
}

Output:



Find HCF(gcd) of two number

Tags
Find  HCF(gcd) of two number:


find hcf(gcd) of two number


#include<stdio.h>
#include<conio.h>

void main()
{
int i,num1,num2,temp,HCF=1;
clrscr();

printf("Enter Any Two Numbers To Find HCF:- ");
scanf("%d%d",&num1,&num2);

temp=(num1<num2)?num1:num2;

for(i=1;i<=temp;i++)
{
if(num1%i==0 && num2%i==0)
{
HCF=i;
}
}
printf("HCF of %d and %d=%d\n",num1,num2,HCF);
getch();
}


Output:



Find LCM of two number

Tags
Find  LCM  of Two Number:


find lcm number of two number


#include<stdio.h>
#include<conio.h>

void main()
{
int i,num1,num2,max,LCM;
clrscr();

printf("Enter Any Two Numbers To Find LCM:- ");
scanf("%d%d",&num1,&num2);

max=(num1>num2)?num1:num2;

for(i=0;i<max;i++)
{
if(max%num1==0 && max%num2==0)
{
LCM=max;
break;
}
max++;
}
printf("\n LCM of The Two Number=%d",LCM);
getch();
}

Output:


Creat a Natural Number

Tags
Creat a Natural Number:


natural numbers


#include<stdio.h>
#include<conio.h>

void main()
{
int i,no;
clrscr();
printf("enter your number:- ");
scanf("%d",&no);

for(i=1;i<=no;i++)
{
printf("%d\n",i);
}
getch();
}

Output:


create any number of table.

Tags
Create any number of table:


create any number of table.


#include<stdio.h>
#include<conio.h>

void main()
{
int no,i;
clrscr();
printf("Enter A Number:- ");
scanf("%d",&no);

for(i=1;i<=10;i++)
{

printf("%d*%d=%d\n",no,i,(no*i));
}
getch();
}

Output:




Print to odd and even number between 1 to10

Tags
Print to odd number between 1 to10


print to odd and even number between 1 to 10

#include<stdio.h>
#include<conio.h>

void main()
{
int i;
clrscr();

for(i=1;i<=10;i++)
{
if(i%2==0)
{
printf("\n Even %d",i);
}
else
{
printf("\n Odd %d",i);
}

}
getch();
}

Output:


c program to uppercase and lowercase.

c program to uppercase and lowercase:


check the number uppercase or lower case


//check the number uppercase or lower case

#include<stdio.h>
#include<conio.h>

void main()
{
char no;
clrscr();
printf("Enter Your Number :- ");
scanf("%c",&no);

if(no>='A'&& no<='Z')
{
printf("Upper Case %c",no);
}
else if(no>='a' && no<='z')
{
printf("Lower Case %c",no);
}
else
{
printf("Not Alphabet.");

}
getch();


}

Output:


input any character and check whether is alphabet,digit,or special character.

input any character and check whether is alphabet,digit,or special character:

in cprograms input any character and check whether is alphabet,digit,or special character.


//check Your Number Is alphabet,numeric And Special Character.

#include<stdio.h>
#include<conio.h>

void main()
{
char no;
clrscr();
printf("Enter Your Number:-");
scanf("%c",&no);

if((no>= 'a' && no<='z') ||(no>='A' && no<='Z'))
{
printf("Your Number Is Alphabet %c",no);
}
else if(no>='0' && no<='9')
{
printf("Your Number is Numeric %c",no);
}
else
{
printf("Your Number is Special Character");
}
getch();
}

Output:



c programing in Enter your marks to know your grade.

C programing  in Enter your marks to know your grade:

check your marks to know your grade.



//Enter Your Marks And know to your grade.


#include<stdio.h>
#include<conio.h>

void main()
{
int marks;
clrscr();
printf("Enter marks to know your grade:-");
scanf("%d",&marks);

if(marks<35)
{
printf("Fail");
}
else if(marks>=35 && marks<40)
{
printf("grade C");
}
else if(marks>=40 && marks<60)
{
printf("grad B");
}
else if(marks>=60 && marks<80)
{
printf("grad A");
}
else
{
printf("grade A+");
}
getch();
}


Output:


c program to your age is eligable for vote or not.

c program to your age is eligable for vote or not.

check your age is eligabe for vote or note.



//check your age is aligable for vote.

#include<stdio.h>
#include<conio.h>

void main()
{
int age;
clrscr();
printf("Enter Your Age :-");
scanf("%d",&age);

if(age>=18)
{
printf("Your Age is Eligible for vote..");
}
else
{
printf("!lSorry You are not eligible for vote");
}
getch();
}


Output:


write a c program to check gender male or female.

write a c program to check gender male or female.

check gender male or female



//check gender are you male or femaleusing or(||) Operator.

#include<stdio.h>
#include<conio.h>

void main()
{
char gen;
clrscr();
printf("Are You is a Male(y/n):");
scanf("%c",&gen);

if(gen=='y' || gen=='Y')
{
printf("Male");
}
else if(gen=='n' || gen=='N')
{
printf("Female");
}
else
{
printf("Invalid Choice");
}
getch();


}

Output: