Sunday, 11 December 2011

Write a program to print the use of pointer in structure in c

#include
#include
struct student
{
int rollno;
char name[20];
};
void main()
{
struct student s1={123,"mahesh"};
struct student *sptr;
clrscr();

sptr=&s1;
printf("\nThe details with the help of structure variable.....\n\n");
printf("The roll number of the student is%d\n\n",s1.rollno);
printf("The name of the student is%s\n\n",s1.name);
printf("\nNow the details with the help of pointer.....\n\n");
printf("\nThe roll number of the student is%d\n\n",sptr->rollno);
printf("The name of the student is %s\n\n",sptr->name);
getch();
}


OUTPUT
The details with the help of structure variable....

The roll number of the student is123

The name of the student is mahesh

Now the details with the help of pointer.....

The roll number of the student is123

The name of the student is mahesh

Write a program to print the structure variable pass in function in c

#include
#include
struct student
{
int rollno;
char name[40];
};
void main()
{
struct student s1;
clrscr();

printf("Enter roll number and name of the student:\n");
scanf("%d%s",&s1.rollno,s1.name);
display(s1);
getch();
}
display(struct student s)
{
printf("\nThe roll number of the student is:%d\n",s.rollno);
printf("\nThe name of the student is:%s",s.name);
}

OUTPUT

Enter roll number and name of the student:
23 RAM KUMAR

The roll number of the student is: 23

The name of the student is: RAM KUMAR

Write a program to print the name, roll no, and date of brith in c

#include
#include
struct date
{
int dd,mm,yy;
clrscr();
};
struct student
{
int roll;
char name[20];
struct date dob;
};
void main()
{
struct student p;
clrscr();
printf("Enter name");
gets(p.name);
printf("Enter roll no.");
scanf("%d",&p.roll);
printf("Enter dd/mm/yy");
scanf("%d%d%d",&p.dob.dd,&p.dob.mm,&p.dob.yy);
printf("\nName is %s",p.name);
printf("\nRoll No. is%d",p.roll);
printf("\nDOB is %d/%d/%d",p.dob.dd,p.dob.mm,p.dob.yy);
getch();
}

OUTPUT
Enter name :mahesh
Enter roll no. 23

Enter dd/mm/yy. 02/21/87

Name is mahesh
Roll No. is 23

DOB 02/21/87

Write a program to print the item,qty,price and multiplication of qty & price and find out his total value in c

#include
#include
struct inv
{
int item;
int qty;
int price;
};
void main()
{
int i,count;
struct inv item[10];
clrscr();
printf("\nEnter Number of Itema:");
scanf("%d",&count);
printf("\n");
for(i=0;i {
printf("ITEM:QTY:PRICE:");
scanf("%d%d%d",&item[i].item,&item[i].qty,&item[i].price);
}
value(item,count);
getch();
}
value(cal,num)
struct inv cal[10];
int num;
{
int i;
int value;
printf("\n\n********S T O C K V A L U E**********\n");
printf("\nITEM\tQTY\tPRICE\t\tQTY *PRICE");
for(i=0;i {
value=cal[i].qty*cal[i].price;
printf("\n%d\t%d\t%d\t\t%d",cal[i].item,cal[i].qty,cal[i].price,value);
}
return(0);
}

OUTPUT
Enter Number of Item : 1
ITEM:QTY:PRICE:1 2 10
ITEM:QTY:PRICE:

**************S T O C K V A L U E******************
ITEM QTY PRICE QTY*PRICE
1 2 10 20

Write a program to print the details of a student in c

#include
#include
struct student
{
int rollno;
char name[20];
};
struct personal
{
int age;
char phone[10];
struct student s1;
};
void main()
{
struct personal p1;
clrscr();
printf("Enter roll number and name of the student:\n");
scanf("%d%s",&p1.s1.rollno,p1.s1.name);
printf("\nEnter age and phone number of the student :\n");
scanf("%d%s",&p1.age,p1.phone);
printf("\nThe roll number of the student is:%d",p1.s1.rollno);
printf("\nThe name of the student is:%s",p1.s1.name);
printf("\nThe age of the student is: %d",p1.age);
printf("\nThe phone number of the student is:%s\n",p1.phone);
getch();
}


OUTPUT
Enter roll number and name of the student:
23 RAM KUMAR VARMA

Enter age and phone number of the student:
20 277458

The roll number of the student is: 23

The name of the student is: mahesh

The age of the student is: 20

The phone number of the student is: 277458

Write a program to use of structure’s members form of array in c

#include
#include

struct employee
{
int empno;
char name[20];
int age;
}
e[5];
void main()
{
int i;
clrscr();
printf("Enter details for five employees\n");
for(i=0;i<5;i++)
{
printf("\nEnter the employee number name and age for employee %d\n",i+1);
fflush(stdin);
scanf("%d%s%d",&e[i].empno,e[i].name,&e[i].age);
}
for(i=0;i<5;i++)
{
printf("\n\nThe details of employee %d\n",i+1);
printf("%d\t%s\t%d",e[i].empno,e[i].name,e[i].age);
}
getch();
}

OUTPUT
Enter details for five employees
Enter the employee number name and age for employee 1
1MAHESH 23
Enter the employee number name and age for employee 2
2 raju 24
Enter the employee number name and age for employee 3
3 harish 22
Enter the employee number name and age for employee 4
4 SIKENDER 22
Enter the employee number name and age for employee 5
5 SANDEEP 23
The details of employee 1
1 MAHESH 23
The details of employee 1
2 VIJAYKUMAR 24
The details of employee 1
3 harish 22
The details of employee 1
4 SIKENDER 22
The details of employee 1
5 SANDEEP 23

Write a program to print the records in structure variable by user in c

#include
#include
struct data
{
int rno;
int marks;
char name[20];
};
void main()
{
struct data stu1;
clrscr();
printf("\n Enter Roll No.:");
scanf("%d",&stu1.rno);
printf("\n Enter Name:");
fflush(stdin);
gets(stu1.name);
printf("\n Enter Marks:");
scanf("%d",&stu1.marks);
printf("\n\n");
printf("\n\t Roll No.\tName\t\t Marks");
printf("\n%12d",stu1.rno);
printf("\t%15s",stu1.name);
printf("%12d",stu1.marks);
getch();
}


OUTPUT
Enter Roll No. 30

Enter Name:RAMKUMAR

Enter Marks: 90

Roll No. Name Marks
30 RAMKUMAR 90

Write a program to print structure’s element pass in function in c

#include
#include
main()
{
struct student
{
int rollno;
char name[40];
};
struct student s1;
clrscr();
printf("Enter roll number and name of the student;\n");
scanf("%d%s",&s1.rollno,s1.name);
display(s1.rollno,s1.name);
getch();
}
display(int x,char *s)
{
printf("\nThe roll number of the student is:%d\n",x);
printf("\nThe name of the student is:%s",s);
}
OUTPUT
Enter roll number and name of the student: 30 SYAM LAL
The roll number of the student is: 30
The name of the student is : SYAM LAL

Write a program to print that all members of union storage location is one in c

#include
union math
{
int a,b;
}value;
void main()
{
clrscr();
printf("\n Enter Numer-A-:");
scanf("%d",&value.a);
printf("Firsst Time Value of A is:%d\n",value.a);
printf("\n Enter Number-B-:");
scanf("5d",&value.b);
printf("Now Value of A is:%d\nand Value of B is:%d",value.a,value.b);
getch();
}
OUTPUT
Enter number-A-:4
First Time Value of A is :4
Enter Number-B-:Now Value of A is :7
And Value of B is :7

Write a program to find operators by using pointer in c

#include
#include
void main()
{
int x,a,y,b,*ptr1,*ptr2,c,d;
clrscr();
printf("\nENTER AN INTEGER:");
scanf("%d",&x);
fflush(stdin);
printf("\nENTER AN INTERGER:");
scanf("%d",&y);
ptr1=&x;
ptr2=&y;
a=*ptr1-*ptr2;
b=*ptr1* *ptr2+8;
printf("\na=%d\nb=%d",a,b);
printf("\nx-y or *ptr1-*ptr2=%d",a);
printf("\nx*y+8 Or *ptr1* *ptr2+8=%d",b);
printf("\nAddress of x=%u",ptr1);
printf("\nAddress of y=%u",ptr2);
c= 5-*ptr2 / *ptr1-2;
printf("\nc=%d",c);
*ptr1=*ptr2-5;
printf("\nx=%d",*ptr1);
d=*ptr1* *ptr2 *6;
printf("\nc=%d",d);
getch();
}

OUTPUT
ENTER AN INTEGER : 6

ENTER AN INTEGER : 3

a =3
b = 26
x-y Or *ptr1 – “ptr2=3
x*y + 8 Or *ptr1 * *ptr2 + 8 = 26
Address of x = 65524
Address of y= 65520
C = 3
X = -2
C = -36

Write a program to show function call by reference in c

#include
#include
void main()
{
int a;
a=200;
clrscr();
printf("\na = %d",a);
add(&a);
printf("\nAFTER RETURN FROM FUNCTION a=%d",a);
getch();
}
add(int*ptr)
{
*ptr = *ptr+200;
printf("\nIN FUNCTION a=%d",*ptr);
return;
}

OUTPUT
a = 200
IN FUNCTION a= 400
AFTER RETURN FROM FUNCTION a= 400

Write a program to find memory veriable by using pointer in c

#include
#include
void main()
{
int x=10,y=20;
char a='y',b='n';
float p=90.76,q=75.43;
clrscr();
printf("\n%d is stored at address %u",x,&x);
printf("\n%d is stored at address %u",y,&y);
printf("\n%c is stored at address %u",a,&a);
printf("\n%c is stored at address %u",b,&b);
printf("\n%f is stored at address %u",p,&p);
printf("\n%f is stored at address %u",q,&q);
getch();
}

OUTPUT
10 is stored at address 65524
20 is stored at address 65522
y is stored at address 65521
n is stored at address 65520
90.760002 is stored at address 65516
75.430000 is stored at address 65512

write a program to find address of integer and float number in c

#include
#include
void main()
{
int i,*iptr;
float f,*fptr;
clrscr();
printf("Enter an integer number:");
scanf("%d",&i);
printf("Enter a float number:");
scanf("%f",&f);
iptr=&i;
fptr=&f;
printf("\nThe address of integer variable is %u",iptr);
printf("\nThe value of integer variable is %d",i);
printf("\nThe value of the integer variable using pointer is%d\n",iptr);
printf("\nThe address of float variable is %u\n",fptr);
printf("The value of float variable is %f\n",f);
printf("The value of the float variable using pointer is%.2f\n",*fptr);
getch();
}

OUTPUT
Enter an integer number:55
Enter a float number:55.5

The address of integer variable is 65524
The value of integer variable is 55
The value of the integer variable using pointer is 55

The address of float variable is 65520
The value of float variable is 55.500000
The value of the float variable using pointer is 55.50

Write a program to print the numbers of sum in c

#include"stdio.h"
#include"conio.h"
int sum(int,int); /*function declaration*/
main()
{
int i=0,j=0,tot;
clrscr();
sum(i,j); /*function call*/
printf("Enter two value");
scanf("%d%d",&i,&j);
tot=sum(i,j);
printf("SUM=%d",tot);
getch();
}
int sum(int a,int b) /*function defination*/
{
int u;
u=a+b;
return(u);
}

Write a program to find out the sum of two numbers use of two Argument in c

#include
#include
int add(int,int);
void main()
{
int x,y,sum;
clrscr();
add(x,y);
printf("Enter two numbers:\n");
scanf("%d%d",&x,&y);
sum=add(x,y);
printf("The sum of two numbers is: %d",sum);
getch();
}
int add(int a,int b)
{
int c;
c=a+b;
return c;
}


OUTPUT
Enter two numbers :
5
18
The sum of two numbers is : 23

Write a program to input the two number and find out the sum of two numbers in c

#include
#include
void add();
main()
{
clrscr();
add();
getch();
}
void add()
{
int x,y,sum;
printf("Enter two numbers:\n");
scanf("%d%d",&x,&y);
sum=x+y;
printf("\nThe sum of two numbers is: %d",sum);
}

Write a program to use of function call by value in c

#include
#include
main()
{
int a;
a=200;
clrscr();
printf("\na=%d",a);
add(a);
printf("\nAFTER RETURN FROM FUNCTION a=%d",a);
getch();
}
add(int a)
{
a=a+200;
printf("\nIN FUNCTION a=%d",a);
return;
}

OUTPUT
A = 200
IN FUNCTION a = 400
AFTER RETURN FROM FUNCTION a = 200

Write a program to find out the Area in c

#include
#include
void main()
{
int l,b,area;
clrscr();
printf("Enter Length:");
l=read();
printf("Enter breadth:");
b=read();
area=l*b;
printf("\nThe Area is:%d",area);
getch();
}
read(int a)
{
scanf("%d",&a);
return a;
}

Write a program to print the Character and find out how many Vowel & Constant in c

#include
#include
main()
{
char n[20];
int j,v=0,c=0,as;
clrscr();
printf("Enter charactor:-\n");
gets(n);
for(j=0;n[j]!='\0';j++)
{
as=n[j];
if(as>=65 && as<=90)
{
if(n[j]=='A' || n[j]=='E' || n[j]=='I' || n[j]=='O' || n[j]=='U')
v++;
else
c++;
}
}
printf("Vowel= %d\n Constant= %d",v,c);
getch();
}


OUTPUT
Enter character:-MAHESH SOLANKI
Vowel = 6
Constant = 9

Write a program to input two dimensional array to convert Row to Column and Column to Row and print transpose value in c

#include
#include
main()
{
int arr1[3][3],arrt[3][3];
int i,j;
clrscr();
printf("Enter a 3 X 3 array:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&arr1[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
arrt[i][j]=arr1[j][i];
}
}
printf("The transpose of the matrix is\n");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
{
printf("arrt[%d][%d] = %d\t\t",i,j,arrt[i][j]);
}
}
getch();
}

OUTPUT
Enter a 3 X 3 array :
1
2
3
4
5
6
7
8
9
The transpose of the matrix is
arrt[0][0] = 1 arrt[0][1] = 4 arrt[0][2] = 7
arrt[1][0] = 2 arrt[1][1] = 5 arrt[1][2] = 8
arrt[2][0] = 3 arrt[2][1] = 6 arrt[2][2] = 9

Write a program to input two dimensional array of 4*4 and find out sum of his each Row and Column and Forward & Backward sum in c

#include
#include
main()
{
int mat[4][4],a,j,i;
int rtot=0,ctot,ftot=0,btot=0;
clrscr();
for(i=0;i<4;i++) { for(j=0;j<4;j++) { printf("Enter number:"); scanf("%d",&a); mat[i][j]=a; } } printf("\n"); for(i=0;i<4;i++) { for(j=0;j<4;j++) { printf("%d\t",mat[i][j]); rtot=rtot+mat[i][j]; } printf("ROW TOTAL:%d",rtot); rtot=0; printf("\n"); } printf("\n COLUMN TOTAL\n"); for(j=0;j<4;j++) { ctot=0; for(i=0;i<4;i++) ctot=ctot+mat[i][j]; printf("%d\t",ctot); } for(i=0;i<4;i++) ftot=ftot+mat[i][i]; printf("\n\n\nFORWARD TOTAL:%d",ftot); i=0; btot=0; for(j=3;j>=0;j--)
{
btot=btot+mat[j][j];
i++;
}
printf("\n\nBACKWARD TOTAL:%d",btot);
getch();
}


OUTPUT


Enter number = 1
Enter number = 2
Enter number = 3
Enter number = 4
Enter number = 5
Enter number = 6
Enter number = 7
Enter number = 8
Enter number = 9
Enter number = 10
Enter number = 11
Enter number = 12
Enter number = 13
Enter number = 14
Enter number = 15
Enter number = 16

1 2 3 4 ROW TOTAL = 10
5 6 7 8 ROW TOTAL = 26
9 10 11 12 ROW TOTAL = 42
13 14 15 16 ROW TOTAL = 58

COLUMN TOTAL

28 32 36 40


FORWARD TOTAL : 34


BACKWARD TOTAL : 34

Write a program to input first 3*3 array , second 3*3 array and find out its sum of matrics in c

#include
#include
main()
{
int arr1[3][3],arr2[3][3],sum[3][3];
int i,j;
clrscr();
printf("Enter First 3 X 3 array:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&arr1[i][j]);
}
}
printf("Enter Second 3 X 3 array :\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&arr2[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
sum[i][j]=arr1[i][j]+arr2[i][j];
}
}
printf("The sum of the matrix is\n");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
{
printf("sum[%d][%d] = %d\t\t",i,j,sum[i][j]);
}
}
getch();

}



OUTPUT


Enter first 3 X 3 array :

1
2
3
4
5
6
7
8
9

Enter second 3 X 3 array :

1
2
3
4
5
6
7
8
9

the sum of the matrix is

sum[0][0] = 2 sum[0][1] = 4 sum[0][2] = 6
sum[1][0] = 8 sum[1][1] = 10 sum[1][2] = 12
sum[2][0] = 14 sum[2][1] = 16 sum[2][2] = 18

Write a program to print sorted array in c

#include
#include
main()
{
int array[10],i,j;
int temp;
clrscr();

printf("Enter ten number:\n");
for(i=0;i<10;i++) { scanf("%d",&array[i]); } for(i=0;i<5;i++) { for(j=0;j<10;j++) { if(array[j]>array[j+1])
{
temp=array[j];
array[j]=array[j+1];
array[j+1]=temp;
}
}
}
printf("The sorted array is:\n");
for(i=0;i<10;i++)
{
printf("%d\n",array[i]);
}
getch();
}

OUTPUT
Enter ten number :
4
8
2
3
4
6
1
6
2
4
The sorted array is :
1
2
2
3
4
4

a program to print a string and its change in c

#include
#include
main()
{
char n[20];
int j;
clrscr();
printf("Enter a string");
gets(n);
for(j=0;n[j]!='\0';j++)
{
if(n[j]>=65 && n[j]<=90) printf("%c",n[j]); else if(n[j]>=97 && n[j]<=122)
printf("%c",n[j]-32);
else
printf("%c",n[j]);
}
getch();
}

OUTPUT
Enter a string : tejkumar saharan
TEJKUMAR SAHARAN

Write a program to print the reverse number in c

#include
#include
main()
{
char str1[10];
int i,len=0,j;
clrscr();
printf("Enter the string:");
gets(str1);
for(i=0;str1[i]!='\0';i++)
{
len++;
}
printf("\n The reverse string is:");
for(j=len-1;j>=0;j--)
{
printf("%c",str1[j]);
}
getch();
}

OUTPUT
Enter the string :MAHESH
The reverse string is : HSWHAM

Write a program to find out the character is positive or negetive in c

#include
#include
#include
main()
{
char string[20];
char *ptr,c;
clrscr();
printf("Enter A string:");
gets(string);
printf("Enter a character which u wish to check:");
scanf("%c",&c);
ptr=strchr(string,c);
if(ptr)
printf("The character %c is at position:%d\n",c,ptr-string+1);
else
printf("The character was not found\n");
getch();
}

OUTPUT
Enter A string: MAHESH
Enter a character which u wish to check : A
The character h is at position 7

Write a program to length of String in c

#include
#include
void main()
{
char str[100];
int len=0,i;
clrscr();
printf("Enter A String:");
gets(str);
for(i=0;str[i]!='\0';i++)
{
len++;
}
printf("The Lenth of The String is:%d",len);
getch();
}


OUTPUT

Enter A String: MAHESH SOLANKI
The Length of The String is : 15

Write a program to print the elements Array and find out the minimum number in c

#include
#include
void main()
{
int arr[10];
int i,temp;
clrscr();
printf("enter the elements in the array:\n");
for(i=0; i<10; i++) { scanf("%d",&arr[i]); } temp=arr[0]; for(i=1; i<10; i++) { if(temp>arr[i])
temp=arr[i];
}
printf("the minimum number is:%d",temp);
getch();
}



OUTPUT


Enter the elements in the Array :

1
5
9
4
3
6
4
8
2
4

The minimum number is : 2

Write a program to merged Array in c

#include
#include
#include
main()
{
int array1[100],array2[100],array3[200];
int i,j,k;
int m,n,p;
clrscr();
printf("How many elements you want in first array:");
scanf("%d",&m);
if(m>100)
{
printf("Array out of bound, press any key to exit...");
getch();
exit(1);
}
printf("Enter %d elements in the first array:\n",m);
for(i=0;i100)
{
printf("Array out of bound,press any key to exit...");
getch();
exit(1);
}
printf("\nEnter %d elements for the second array:\n",n);
for(i=0;i {
scanf("%d",&array2[i]);
}
for(i=0;i {
array3[i]=array1[i];
}
for(j=m,k=0;k {
array3[j]=array2[k];
}
p=m+n;
printf("The merged array is\n");
for(i=0;i {
printf("array3[%d]=%d\n",i,array3[i]);
}
getch();
}



OUTPUT

How many elements you want in first array : 4

Enter 4 elements in the first array

1
3
5
7

How many elements you want is second array : 4

Enter 4 elements for the second array

1
2
4
6

The merged array is

array3[0] = 1
array3[0] = 3
array3[0] = 5
array3[0] = 7
array3[0] = 1
array3[0] = 2
array3[0] = 4
array3[0] = 6

prowtec

#include
#include
void main()
{
int arr[10];
int i,temp;
clrscr();
printf("enter the elements in the array:\n");
for(i=0;i<10;i++)
{
scanf("%d",&arr[i]);
}
temp=arr[0];
for(i=1; i<10 ; i++)
{
if(temp temp=arr[i];
}
printf("The maximum numbers : %d",temp);
getch();
}


OUTPUT


Enter the elements in the array:
4
2
9
6
7
5
8
3
2
1

The maximum number is: 9

Write a program to print a String of 3*3 matrix in c

#include
#include
main()
{
int mat[3][3];
int i,j;
clrscr();
printf("Enter a 3 X 3 array:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&mat[i][j]);
}
}
printf("The array in the matrix form is\n");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
{
printf("MAT[%d][%d] =%d\t\t",i,j,mat[i][j]);
}
}
getch();
}


OUTPUT
Enter a 3 X 3 array:
1
2
3
4
5
6
7
8
9
The array in the matrix form is
MAT[0][0]=1 MAT[0][1]=2 MAT[0][2]=3
MAT[1][0]=4 MAT[1][1]=5 MAT[1][2]=6
MAT[2][0]=7 MAT[2][1]=8 MAT[2][2]=9

Write a program to print a String and find out of its total Character in c

#include
#include
main()
{
char a[20];
int j;
clrscr();
printf("Enter a string:");
gets(a);
for(j=0;a[j]!='\0';j++);
{
printf("\nTotal char=%d",j);
}
getch();
}

OUTPUT
Enter a string: TEJKUMAR SAHARAN
Total char = 15

Write a program to print a String and a another String and connect it in c

#include
#include
main()
{
char string1[20],string2[20],string3[40];
int i,j,k;
int len=0;
clrscr();
printf("Enter a string:");
gets(string1);
printf("Enter Another string:");
gets(string2);
for(i=0;string1[i]!='\0';i++)
{
string3[i]=string1[i];
len++;
}
for(j=len,k=0;string2[k]!='\0';j++,k++)
{
string3[j]=string2[k];
}
string3[j]='\0';
printf("The concatenated string is:%s",string3);
getch();
}

OUTPUT
Enter a string:MAHESH
Enter Another string: SOLANKI
The concatenated string is : MAHESHSOLANKI

Write a program to copy of String in c

#include
#include
main()
{
char str1[100],str2[100];
int i;
clrscr();
printf("Enter the string:");
gets(str1);
for(i=0;str1[i]!='\0';i++)
{
str2[i]=str1[i];
}
str2[i]='\0';
printf("\n The Original string is:%s",str1);
printf("\n The Copied string is: %s",str2);
getch();
}

OUTPUT
Enter the string: MAHESH
The Original string is : MAHESH
The Copied string is: MAHESH

Write a program to print a String in c

#include
#include
main()
{
char n[20];
int j;
clrscr();
printf("Enter a string");
gets(n);
for(j=0;n[j]!='\0'; j++)
{
if(n[j]>=65 && n[j]<=90) printf("%c",n[j]+32); else if(n[j]>=97 && n[j]<=122)
printf("%c",n[j]);
}
getch();
}

OUTPUT
Enter a string MAHESH
tejkumar

Write a program to print this Series with do while loop in c

#include
#include
main()
{
int i=1;
clrscr();
do
{
printf("%d\t",i);
i=i+2;
}
while(i<100);
getch();
}


OUTPUT

1 3 5 7 9 11 13 15 17 19 ………………. 99

Write a program to print the sum of numbers from 1 to 10 with do while loop in c

#include
#include
main()
{
int i;
int sum=0;
clrscr();
i=1;

do
{
sum=sum+i;
i++;
}while(i<=10);
printf("\nThe sum of numbers from 1 to 10 is:%d",sum);
getch();
}


OUTPUT

The of numbers from 1 to 10 is: 55

Write a program to to print spaces in c

#include
#include
main()
{
int i,sp;
clrscr();
printf("Enter The Number of Spaces:");
scanf("%d",&sp);
i=0;
while(i<=sp)
{
printf(" ");
i=i+1;
}
printf("*");
getch();
}


OUTPUT
Enter The Number of Spaces: 5
*

Write a program to a program N Triangular Number in c

#include
#include
main()
{
int n,i=1,sum=0;
clrscr();
printf("Enter any value");
scanf("%d",&n);
while(i<=n)
{
sum=sum+i;
printf("N Triangular of %d is %d\n",sum);
i++;
}
getch();
}

OUTPUT

Enter any value: 4
N Triangular of 1 is 2400
N Triangular of 3 is 2400
N Triangular of 6 is 2400

Write a program to print the triangle value in c

#include
#include
main()
{
int n,sum=0;
clrscr();
printf("Enter any value");
scanf("%d",&n);
while(n>0)
{
sum=sum+n;
n--;
}
printf("Triangular value is %d",sum);
getch();
}


OUTPUT

Enter any value : 5

Triangular value is 15

Write a program to print Series by user in c

#include
#include
main()
{
int f=0,f1=1,f2=0,n;
clrscr();
printf("Enter fast range");
scanf("%d",&n);
while(f1 {
printf("%d",f2);
f=f1+f2;
f1=f2;
f2=f;
}
getch();
}

OUTPUT

Enter fast range : 5
0 1 1 2 3 5

Write a program to print fabonnaci series of given number input by user in c

#include
#include
main()
{
int f=0,f1=1,f2=0,n,i=0;
clrscr();
printf("Enter any value");
scanf("%d",&n);
while(i {
printf("%4d",f2);
f=f1+f2;
f1=f2;
f2=f;
i++;
}
getch();
}

OUTPUT

Enter any value: 5
0 1 1 2 3

Write a program to print sum of given digits by user in c

#include
#include
void main()
{
int n, p=0,s,x=1,ct=0,sum=0;
clrscr();
printf("Enter The Number:");
scanf("%d",&n);
while(ct0)
{
p=(p*10)+(s%10);
s=s/10;
}
if(x==p)
{
sum=sum+x;
ct++;
}
x++;
}
printf("sum is: %d",sum);
getch();
}



OUTPUT

Enter The Number : 6
Sum is : 21

Write a program to print smallest in given 10 numbers in c

#include
#include
main()
{
int num,i,temp;
clrscr();
i=0;
printf("Enter A Number:");
scanf("%d",&num);
temp=num;
while(i<9) { printf("\nEnter A Number:"); scanf("%d",&num); if(temp>num)
{
temp=num;
}
i++;
}
printf("\n\nThe Smallest Number is:%d",temp);
getch();
}

OUTPUT

Enter a number : 5

Enter a number : 4

Enter a number : 56

Enter a number : 8

Enter a number : 6

Enter a number : 3

Enter a number : 8

Enter a number : 9

Enter a number : 10

Enter a number : 23

The Smallest Number is : 3

Write a program to print fabonnaci series as fast range in c

#include
#include
main()
{
int f=0,f1=1,f2=0,n;
clrscr();
printf("Enter fast range");
scanf("%d",&n);
while(f1 {
printf("%d",f2);
f=f1+f2;
f1=f2;
f2=f;
}
getch();
}
OUTPUT
Enter fast range :
0 1 1 2 3 5

Write a program to print square of input number given by user in c

#include
#include
main()
{
int num,square;
char ans='y';
clrscr();
while(ans=='y'||ans=='Y')
{
printf("Enter a number\n");
scanf("%d",&num);
square=num*num;
printf("The square of %d is %d",num,square);
printf("\nDo You wish to enter another number (y for yes):");
fflush(stdin);
scanf("%c",&ans);
}
getch();
}


OUTPUT

Enter a number : 7
The square of 7 is 49
Do You wish to enter another number (y for yes):

Write a program to print sum of 1,2,…,10 number with while loop in c

#include
#include
main()
{
int i;
int sum=0;
clrscr();
i=1;
while(i<=10)
{
sum=sum+i;
i++;
}
printf("\n The sum of numbers from 1 to 10 is:%d",sum);
getch();
}


OUTPUT

The sum of numbers from 1 to 10 is : 55

Write a program to print this series:-1 3 5 7 9 11 13 15 17 19 21 23 25 ………… 99 with while loop in c

#include
#include
main()
{
int i=1;
clrscr();
while(i<=100)
{
printf("%d\t",i);
i=i+2;
}
getch();
}

OUTPUT

1 3 5 7 9 11 13 15 17 19 21 23 25 ………… 99

Write a program to print a back triangle in c

#include
#include
main()
{
int n,i,j;
clrscr();
printf("Enter The Number:");
scanf("%d",&n);
for(i=n+1;i>0;i--)
{
for(j=0;j {
printf("*");
}
printf("\n");
}
getch();
}

OUTPUT:-
Enter The Number: 5
*****
****
***
**
*

Write a program to print a triangle with for loop in c

#include
#include
void main()
{
int i,j;
clrscr();
for(i=0;i<=10;i++)
{
for(j=0;j {
printf("*");
}
printf("\n");
}
getch();
}

OUTPUT
*
**
***
****
*****