C programs neede befoe start of ACC Programs
1. Addition of two integer/float numbers.
2. Find the area of circle.
3. Calculate average of three numbers.
4. Check whether number is even or not.
5. Check whether character is vowel or consonant.
6. Check whether number is positive or negative.
7. Determine FIRST CLASS/SECOND CLASS/DISTINCTION for 5 subjects.
8. Switch case program for addition subtraction multiplication and division.
9. Switch case program for areas of circle,rectangle and triangle.
10. Calculate and display even number from 1 to 100 using for loop
11. Calculate and display even number from 1 to 100 using while loop.
12. Counting positive,negative and zeros from given list of numbers.
13. Program for displaying values from array.(Take values from program)
14. Program for displaying values from array.(Take values from user)
15. Addition of numbers in 1D array.
16. Displaying 2D array by taking numbers from program.
17. Displaying 2D array by taking numbers from user.
18. Addition of numbers in two different 2D arrays.
19. Display name of book,pages and price using structure.
20. Display name,salary,conatct no, mail id of employee using structure.
21. Display name of book,pages and price using array of structure.
22. Display name,salary,conatct no, mail id of employee using array of structure.
23. Display name,salary,conatct no, mail id of employee using union.
24. Multiplication of numbers using pointer.
25. Write a program to demonstrate the use of pointer to pointer
26. Display name of book,pages and price using pointer to structure.
27.Write a program to display content of file.
28. Copy the content of one file from the other file and display the contents.
29. Display content of string character by charatcter.
30. Find and display string length without using string function.
31. Copying content of string in another string without using string function.
32. Display reverse string without using string function.
33. Find and display number of vowels and consonants in the string.
34. Display array of string by taking from user.
35. Program to demonstrate string functions using switch case.
36. Multiplication of two number using pointer.
37. Display size of pointer.
38. Program to demonstrate pointer to structure .
39. Program to demonstrate Array of pointer.
40. Display string length using pointer.
2. Find the area of circle.
3. Calculate average of three numbers.
4. Check whether number is even or not.
5. Check whether character is vowel or consonant.
6. Check whether number is positive or negative.
7. Determine FIRST CLASS/SECOND CLASS/DISTINCTION for 5 subjects.
8. Switch case program for addition subtraction multiplication and division.
9. Switch case program for areas of circle,rectangle and triangle.
10. Calculate and display even number from 1 to 100 using for loop
11. Calculate and display even number from 1 to 100 using while loop.
12. Counting positive,negative and zeros from given list of numbers.
13. Program for displaying values from array.(Take values from program)
14. Program for displaying values from array.(Take values from user)
15. Addition of numbers in 1D array.
16. Displaying 2D array by taking numbers from program.
17. Displaying 2D array by taking numbers from user.
18. Addition of numbers in two different 2D arrays.
19. Display name of book,pages and price using structure.
20. Display name,salary,conatct no, mail id of employee using structure.
21. Display name of book,pages and price using array of structure.
22. Display name,salary,conatct no, mail id of employee using array of structure.
23. Display name,salary,conatct no, mail id of employee using union.
24. Multiplication of numbers using pointer.
25. Write a program to demonstrate the use of pointer to pointer
26. Display name of book,pages and price using pointer to structure.
27.Write a program to display content of file.
28. Copy the content of one file from the other file and display the contents.
29. Display content of string character by charatcter.
30. Find and display string length without using string function.
31. Copying content of string in another string without using string function.
32. Display reverse string without using string function.
33. Find and display number of vowels and consonants in the string.
34. Display array of string by taking from user.
35. Program to demonstrate string functions using switch case.
36. Multiplication of two number using pointer.
37. Display size of pointer.
38. Program to demonstrate pointer to structure .
39. Program to demonstrate Array of pointer.
40. Display string length using pointer.
#include
ReplyDeletevoid main()
{
int a,b,c;
printf("\n\tEnter two number:");
scanf("%d%d",&a,&b);
c=a+b;
printf("addition of two number=%d",c);
}
#include
ReplyDelete#define pi 3.14
void main()
{
float area,r;
printf("enter the radius");
scanf("%f",&r);
area=pi*r*r;
printf("\n\t Area of circle=%f",area);
}
#include
ReplyDeletevoid main()
{
float avg,a,b,c;
printf("\n\t Enter the three values");
scanf("%f%f%f",&a,&b,&c);
avg=((a+b+c)/3);
printf("\n\tAverage=%f",avg);
}
#include
ReplyDeletevoid main()
{
int a;
printf("\n\tEnter a number");
scanf("%d",&a);
if(a%2==0)
{
printf("\nno is even");
}
else
{
printf("\n\tno is odd");
}
}
#include
ReplyDeletevoid main()
{
char ch;
printf("\n\tEnter a character");
scanf("%c",&ch);
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
{
printf("\n\t VOWELL");
}
else
{
printf("\n\t CONSONANT");
}
}
#include
ReplyDeletevoid main()
{
int num;
printf("\n\tenter a number");
scanf("%d",&num);
if(num>0)
{
printf("\n\t positive no");
}
if(num<0)
{
printf("\n\t negative no");
}
if(num==0)
{
printf("\n\t zero no");
}
}
#include
ReplyDelete#define pi 3.14
void main()
{
int ch;
float r,l,b,h;
printf("\n1.Area of Circle\n2. Area of Triangle\n3.Area of Rectangle");
printf("\nEnter your choice:");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("Enter radius:");
scanf("%f",&r);
printf("Area of Circle=%f",pi*r*r);
break;
case 2:
printf("Enter a length and breadth:");
scanf("%f%f",&l,&b);
printf("Area of Triangle=%f",l*b);
break;
case 3:
printf("Enter a length, breadth, hight:");
scanf("%f%f%f",&l,&b,&h);
printf("Area of Rectangle=%f",l*b*h);
break;
}
}
/* information of book */
ReplyDelete#include
void main()
{
struct book;
{
char name[10];
float price;
int pages;
}b;
printf("enter the name of book");
scanf("%s",b.book name);
printf("enter the price of book");
scanf("%f",b.price);
printf("enter the pages of book");
scanf("%d",&b.pages);
}
printf("\n\t book name=%s,book price=%f,book pages=%d,",b.name,b.price.,b.pages);
\* area of circle*\
ReplyDelete# include
#define pi 3.14
void main()
{
inr r;
float area;
printf("\n\t enter the radious");
scanf("%d",&r);
area=pi*r*r;
printf("\n\t area of circle=%f",area);
}
#include
ReplyDelete#define pi 3.14
void main()
{
float area,r;
printf("enter the radius");
scanf("%f",&r);
area=pi*r*r;
printf("\n\tarea of circle=%f",area);
}
#include
ReplyDeletevoid main()
{
int a,b,c;
printf("\n\t enter the two number");
scanf("%d%d",&a,&b);
c=a+b;
printf("addition=%d",&c);
}
#include
ReplyDeletevoid main()
{
char ch;
printf("Enter a character");
scanf("%c",&ch);
if(ch=='a'|| ch=='e'|| ch=='i'|| ch=='o'|| ch=='u')
{
printf("vowel");
}
else
{
printf("consonant");
}
}
#include
ReplyDeletevoid main()
{
int x,y,temp;
printf("Enter values of x & y\n");
scanf("%d%d,&x,&y);
printf("Before swapping\nx=%d\ny=%d\n",x,y);
temp=x;
x=y;
y=temp;
printf("After swapping\nx=%d\ny=%d\n"x,y);
}
#include
ReplyDeletevoid main()
{
float avg,a,b,c;
printf("\n\tenter the three values");
scanf("%f%f%f",&a,&b,&c);
avg=((a+b+c)/3);
printf("/n/taverage=%f",avg);
}
#include
ReplyDeletevoid main()
{
int x,y,temp;
printf("Enter values of x & y\n");
scanf("%d%d,&x,&y);
printf("Before swapping\nx=%d\ny=%d\n",x,y);
temp=x;
x=y;
y=temp;
printf("After swapping\nx=%d\ny=%d\n"x,y);
}
#include
ReplyDeletevoid main()
{
struct book
{
char name[10];
int pages;
float price;
}b;
printf("\n\t Enter name of book");
scanf("%s",b.name);
printf("\n\t Enter price of book");
scanf("%f",&b.price);
printf("\n\t Enter pages of book");
scanf("%d",&b.pages);
printf("\n\t book name=%s,book price=%f,book pages=%d",b.name,b.price,b.pages);
}
#include
ReplyDeletevoid main()
{
int a[5]={5,10,15,20,25};
int j;
for(j=0;j<=4;j++)
{
printf("\n\t%d",a[j]);
}
}
#include
ReplyDeletevoid main()
{
int a[2],b[2],c[2];
int i;
printf("\n\tEnter the elements of first array:");
for(i=0;i<=1;i++)
{
scanf("%d",&a[i]);
}
printf("\n\tEnter the elements of second array:");
for(i=0;i<=1;i++)
{
scanf("%d",&b[i]);
}
printf("\n\tAddition of two array elements=");
for(i=0;i<=1;i++)
{
c[i]=a[i]+b[i];
printf("\n\taddition=%d",c[i]);
}
}
#include
ReplyDeletevoid main()
{
int a[2][2]={
{5,10},
{15,20},
};
int j,i;
for(j=0;j<=1;j++)
{
for( i=0;i<=1;i++)
{
printf("\n\t%d",a[j][i]);
}
}
}
#include
ReplyDeletevoid main()
{
struct book
{
char name[10];
float price;
int pages;
}b;
printf("\n\tEnter the name of book");
scanf("%s",b.name);
printf("\n\tEnter the price of book");
scanf("%f",&b.price);
printf("\n\tEnter the pages of book");
scanf("%d",&b.pages);
printf("\n\tBook Name=%s,Book Price=%f,Book Pages=%d",b.name,b.price,b.pages);
}
#include
ReplyDeletevoid main()
{
struct book1
{
char name[10];
float price;
int pages;
}b[10];
int i;
for(i=0;i<=9;i++)
{
printf("\n\tEnter the name of boot\n\t");
scanf("%s",b[i].name);
printf("\n\tEnter the price of book\n\t");
scanf("%f",&b[i].price);
printf("\n\tEnter the pages of book\n\t");
scanf("%d",&b[i].pages);
}
for(i=0;i<=9;i++)
{
printf("\n\tBook Name=%s\n\tBook Price=%f\n\tBook Pages=%d",b[i].name,b[i].price,b[i].pages);
}
}
#include
ReplyDeletevoid main()
{
struct book1
{
char name[10];
float price;
int pages;
}b[10];
int i;
for(i=0;i<=9;i++)
{
printf("\n\tEnter the name of boot\n\t");
scanf("%s",b[i].name);
printf("\n\tEnter the price of book\n\t");
scanf("%f",&b[i].price);
printf("\n\tEnter the pages of book\n\t");
scanf("%d",&b[i].pages);
}
for(i=0;i<=9;i++)
{
printf("\n\tBook Name=%s\n\tBook Price=%f\n\tBook Pages=%d",b[i].name,b[i].price,b[i].pages);
}
}
#include
ReplyDeletevoid main()
{
int a[2][2],b[2][2],c[2][2];
int i,j;
printf("\n\tEnter the elements of first array:");
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\n\tEnter the elements of second array:");
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
scanf("%d",&b[i][j]);
}
}
printf("\n\tAddition of two arrat elements=");
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf("\n\taddition=%d",c[i][j]);
}
}
}
#include
ReplyDeletevoid main()
{
struct employee
{
char name[10];
float salary;
int id;
int contactno;
}e;
printf("\n\tEnter the name of employee");
scanf("%s",e.name);
printf("\n\tEnter the salary of employee");
scanf("%f",&e.salary);
printf("\n\tEnter the id of employee");
scanf("%d",&e.id);
printf("\n\tEnter the contactno of employee");
scanf("%d",&e.contactno);
printf("\n\tEmployee Name=%s,Employee salary=%f,Employee id=%d,Contactno=%d",e.name,e.salary,e.id,e.contactno);
}
#include
ReplyDeletevoid main()
{
struct emp
{
char name[50];
float salary;
int id;
int contactno;
}e[10];
int i;
for(i=0;i<=9;i++)
{
printf("\n\tEnter the name of employee\n\t");
scanf("%s",e[i].name);
printf("\n\tEnter the salary of employee\n\t");
scanf("%f",&e[i].salary);
printf("\n\tEnter the id of employee\n\t");
scanf("%d",&e[i].id);
printf("\n\tEnter the contactno of employee");
scanf("%d",&e[i].contactno);
}
for(i=0;i<=9;i++)
{
printf("\n\tEmployee Name=%s,Employee salary=%f,Employee id=%d,Contactno=%d",e[i].name,e[i].salary,e[i].id,e[i].contactno);
}
}
#include
ReplyDeletevoid main()
{
union emp
{
char name[50];
float salary;
int id;
int contactno;
}u[10];
int i;
for(i=0;i<=9;i++)
{
printf("\n\tEnter the name of employee\n\t");
scanf("%s",u[i].name);
printf("\n\tEnter the salary of employee\n\t");
scanf("%f",&u[i].salary);
printf("\n\tEnter the id of employee\n\t");
scanf("%d",&u[i].id);
printf("\n\tEnter the contactno of employee");
scanf("%d",&u[i].contactno);
}
for(i=0;i<=9;i++)
{
printf("\n\tEmployee Name=%s,Employee salary=%f,Employee id=%d,Contactno=%d",u[i].name,u[i].salary,u[i].id,u[i].contactno);
}
}
#include
ReplyDeletevoid main()
{
int i=1;
while(i<=100)
{
if(i%2==0)
{
printf("%d\n\t",i);
}
i++;
}
}
#include
ReplyDeletevoid main()
{
int a,b;
int *ptr1,*ptr2;
ptr1=&a;
ptr2=&b;
printf("\n\tEnter two no");
scanf("%d%d",&a,&b);
printf("mul=%d",(*ptr1)*(*ptr2));
}
/*To display the information of book using array of stucture*/
ReplyDelete#include
void main()
{
int i;
struct book
{
char name[100];
float price;
int pages;
}b[5];
for(i=0;i<=4;i++)
{
printf("\n\tEnter the name of book");
scanf("%s",b[i].name);
printf("\n\tEnter the price of book");
scanf("%f",&b[i].price);
printf("\n\tEnter the pages of book");
scanf("%d",&b[i].pages);
}
for(i=0;i<=4;i++)
{
printf("\n\tNAME=%s \n\tPRICE=%f \n\tPAGES=%d",b[i].name,b[i].price,b[i].pages);
}
}
#include
ReplyDeletevoid main()
{
int x,y,temp;
printf("Enter values of x & y\n");
scanf("%d%d,&x,&y);
printf("Before swapping\nx=%d\ny=%d\n",x,y);
temp=x;
x=y;
y=temp;
printf("After swapping\nx=%d\ny=%d\n"x,y);
}
#include
ReplyDeletevoid main()
{
char ch;
printf("Enter a character");
scanf("%c",&ch);
if(ch=='a'|| ch=='e'|| ch=='i'|| ch=='o'|| ch=='u')
{
printf("vowel");
}
else
{
printf("consonant");
}
}
#include
ReplyDeletevoid main()
{
struct book
{
char name[10];
float price;
int pages;
}b;
struct book *p;
p=&b;
printf("\n\tEnter the book name");
scanf("%s",p->name);
printf("\n\tEnter the price name");
scanf("%f",&p->price);
printf("\n\tEnter the pages name");
scanf("%d",&p->pages);
printf("\n\tBook name=%s,Book price=%f,Book pages=%d",p->name,p->price,p->pages);
}
/*To calculate Average of three numbers ,20-7-16*/
ReplyDelete#include
void main()
{
int a,b,c;
float avg;
printf("\n\tEnter the first number");
scanf("%d",&a);
printf("\n\tEnter the second number");
scanf("%d",&b);
printf("\n\tEnter the third number");
scanf("%d",&c);
avg=a+b+c/3;
printf("\n\tavg=%f",avg);
}
/*To accept two different array & make their addition*/
ReplyDelete#include
void main()
{
int i,j,a[2][2],b[2][2],c[2][2];
printf("\n\tEnter the elements of first 2D array");
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
scanf("\n\t%d",&a[i][j]);
}
}
printf("\n\tEnter the elements of second 2D array");
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
scanf("\n\t%d",&b[i][j]);
}
}
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf("\n\tAddition=%d",c[i][j]);
}
}
}
/*To display the information of book using array of stucture*/
ReplyDelete#include
void main()
{
int i;
struct book
{
char name[100];
float price;
int pages;
}b[5];
for(i=0;i<=4;i++)
{
printf("\n\tEnter the name of book");
scanf("%s",b[i].name);
printf("\n\tEnter the price of book");
scanf("%f",&b[i].price);
printf("\n\tEnter the pages of book");
scanf("%d",&b[i].pages);
}
for(i=0;i<=4;i++)
{
printf("\n\tNAME=%s \n\tPRICE=%f \n\tPAGES=%d",b[i].name,b[i].price,b[i].pages);
}
}
/*Addition of two numbers in 1D array*/
ReplyDelete#include
void main()
{
int i,a[5],b[5],c[5];
printf("\n\tEnter the elements of first array");
for(i=0;i<=4;i++)
{
scanf("%d",&a[i]);
}
printf("\n\tEnter the elements of second array");
for(i=0;i<=4;i++)
{
scanf("%d",&b[i]);
}
for(i=0;i<=4;i++)
{
c[i]=a[i]+b[i];
printf("\n\tAddition=%d",c[i]);
}
}
/*To display 2D array*/
ReplyDelete#include
void main()
{
int i,j;
int a[2][2]={ {5,10},
{15,20}};
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
printf("a[%d][%d]=%d",i,j,a[i][j]);
}
}
}
/*To display 2D array by taking the values from user*/
ReplyDelete#include
void main()
{
int i,j,a[2][2];
printf("\n\tEnter the elements of array:");
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
scanf("\n\t%d",&a[i][j]);
}
}
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
printf("\n\t%d",a[i][j]);
}
}
}
/*To display the array,take values from user*/
ReplyDelete#include
void main()
{
int i;
int a[5];
printf("\n\tEnter the elements of array");
for(i=0;i<=4;i++)
{
scanf("\n\t%d",&a[i]);
}
for(i=0;i<=4;i++)
{
printf("\n\t%d",a[i]);
}
}
/*To display even number from 1to 10 by using while loop,20-7-16*/
ReplyDelete#include
void main()
{
int i=1;
while(i<=10)
{
if(i%2==0)
{
printf("%d",i);
}
i++;
}
}
/*To calculate display even number from 1to 100 by using while loop,20-7-16*/
ReplyDelete#include
void main()
{
int i=1;
while(i<=100)
{
if(i%2==0)
{
printf("%d",i);
}
i++;
}
}
/*To calculate and display even number from 1 to 100 by using for loop*/
ReplyDelete#include
void main()
{
int i=1;
for(i=1;i<=100;i++)
{
if(i%2==0)
{
printf(" \n Given no %d is even \n ",i);
}
}
}
/*To displaying values from array*/
ReplyDelete#include
void main()
{
int a[5]={1,2,3,4,5},i;
for(i=0;i<=4;i++)
{
printf("\n\t%d",a[i]);
}
}
/*To displaying values from array*/
ReplyDelete#include
void main()
{
int a[5]={1,2,3,4,5},i;
for(i=0;i<=4;i++)
{
printf("\n\t%d",a[i]);
}
}
#include
ReplyDeletevoid main()
{
struct employe
{
char name[10];
float salary;
int id;
}e;
printf("\n\t Enter name of employe");
scanf("%s",&e.name);
printf("\n\t Enter salary of employe");
scanf("%f",&e.salary);
printf("\n\t Enter id of employe");
scanf("%d",&e.id);
printf("\n\t employe name=%s,employe salary=%f,employe id=%d",e.name,e.salary,e.id);
}
/*To calculate Average of three numbers */
ReplyDelete#include
void main()
{
int a,b,c;
float avg;
printf("\n\tEnter the first number");
scanf("%d",&a);
printf("\n\tEnter the second number");
scanf("%d",&b);
printf("\n\tEnter the third number");
scanf("%d",&c);
avg=a+b+c/3;
printf("\n\tavg=%f",avg);
}
#include
ReplyDeletevoid main()
{
int num,cnt1,cnt2,cnt3;
int i;
for(i=1;i<=5;i++)
{
printf("\n\tEnter the num");
scanf("%d",&num);
if(num>0)
cnt1++;
if(num<0)
cnt2++;
if(num==0)
cnt3++;
}
}
printf(Total positive);
}
/*To accept two different array & make their addition*/
ReplyDelete#include
void main()
{
int i,j,a[2][2],b[2][2],c[2][2];
printf("\n\tEnter the elements of first 2D array");
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
scanf("\n\t%d",&a[i][j]);
}
}
printf("\n\tEnter the elements of second 2D array");
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
scanf("\n\t%d",&b[i][j]);
}
}
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf("\n\tAddition=%d",c[i][j]);
}
}
}
#include
ReplyDeletevoid main()
{
float avg,a,b,c;
printf("\n\tenter the three values");
scanf("%f%f%f",&a,&b,&c);
avg=((a+b+c)/3);
printf("/n/taverage=%f",avg);
}
/*Addition of two numbers in 1D array*/
ReplyDelete#include
void main()
{
int i,a[5],b[5],c[5];
printf("\n\tEnter the elements of first array");
for(i=0;i<=4;i++)
{
scanf("%d",&a[i]);
}
printf("\n\tEnter the elements of second array");
for(i=0;i<=4;i++)
{
scanf("%d",&b[i]);
}
for(i=0;i<=4;i++)
{
c[i]=a[i]+b[i];
printf("\n\tAddition=%d",c[i]);
}
}
/*To calculate Average of three numbers ,20-7-16*/
ReplyDelete#include
void main()
{
int a,b,c;
float avg;
printf("\n\tEnter the first number");
scanf("%d",&a);
printf("\n\tEnter the second number");
scanf("%d",&b);
printf("\n\tEnter the third number");
scanf("%d",&c);
avg=a+b+c/3;
printf("\n\tavg=%f",avg);
}
/*To display the information of book using array of stucture*/
ReplyDelete#include
void main()
{
int i;
struct book
{
char name[100];
float price;
int pages;
}b[5];
for(i=0;i<=4;i++)
{
printf("\n\tEnter the name of book");
scanf("%s",b[i].name);
printf("\n\tEnter the price of book");
scanf("%f",&b[i].price);
printf("\n\tEnter the pages of book");
scanf("%d",&b[i].pages);
}
for(i=0;i<=4;i++)
{
printf("\n\tNAME=%s \n\tPRICE=%f \n\tPAGES=%d",b[i].name,b[i].price,b[i].pages);
}
}
/*To calculate display even number from 1to 100 by using while loop,20-7-16*/
ReplyDelete#include
void main()
{
int i=1;
while(i<=100)
{
if(i%2==0)
{
printf("%d",i);
}
i++;
}
}
/*To calculate and display even number from 1 to 100 by using for loop*/
ReplyDelete#include
void main()
{
int i=1;
for(i=1;i<=100;i++)
{
if(i%2==0)
{
printf(" \n Given no %d is even \n ",i);
}
}
}
#include
ReplyDeletestruct employee
{
char name[20],mail[20];
int contact;
float salary;
}e[100];
void main()
{
int n,i;
printf("\n\nenter the number of employees\n");
scanf("%d",&n);
for(i=0;i<=n-1;i++)
{
printf("\nEnter contact no.\n ");
scanf("%d",&e[i].contact);
printf("\nenter the name of employee\n");
scanf("%s",e[i].name);
printf("\nEnter salary of employee\n ");
scanf("%f",&e[i].salary);
printf("\nEnter mail id\n");
scanf("%s",e[i].mail);
}
printf("name\tcontact no\tsalary\tmail id\n");
printf("-------------------------------------------------\n");
for(i=0;i<=n-1;i++)
{
printf("\n%s\t%d\t%f\t%s\t",e[i].name,e[i].contact,e[i].salary,e[i].mail);
}
}
#include
ReplyDeletevoid main()
{
float per;
printf("Enter your percentage");
scanf("%f",&per);
if(per>=60)
{
printf("First class");
}
else if(per>=50)
{
printf("Second class");
}
else if(per>=40)
{
printf("Thrid Class");
}
else
{
printf("Fail");
}
}
#include
ReplyDeletevoid main()
{
int x,y,temp;
printf("Enter values of x & y\n");
scanf("%d%d,&x,&y);
printf("Before swapping\nx=%d\ny=%d\n",x,y);
temp=x;
x=y;
y=temp;
printf("After swapping\nx=%d\ny=%d\n"x,y);
}
/*To calculate display even number from 1to 100 by using while loop,20-7-16*/
ReplyDelete#include
void main()
{
int i=1;
while(i<=100)
{
if(i%2==0)
{
printf("%d",i);
}
i++;
}
}
#include
ReplyDeletevoid main()
{
struct book
{
char name[10];
float price;
int pages;
}b;
struct book *p;
p=&b;
printf("enter name of book");
scanf("%s",p->name);
printf("enter price of book");
scanf("%f",&p->price);
printf("enter pages of book");
scanf("%d",&p->pages);
printf("book name=%s,book price=%f,book pages=%d,p->name,p->price,p->pages");
}
#include
ReplyDeletevoid main()
{
int ch,add,sub,mul,div,a,b;
printf("Enter the number 1..");
scanf("%d",&a);
printf("Enter the number 2..");
scanf("%d",&b);
printf("Choose option to perform operation.....\n1..Addition \n2..Subtraction \n3..Multiplication \n4..Division \n");
printf("\nEnter......");
scanf("%d",&ch);
switch(ch)
{
case 1:add=a+b;
printf("\nADDITION=%d\n",add);
break;
case 2:sub=a-b;
printf("\nSUBTRACTION=%d\n",sub);
break;
case 3:mul=a*b;
printf("\nMULTIPLICATION=%d\n",mul);
break;
case 4:div=a/b;
printf("\nDIVISION=%d\n",div);
break;
default:
printf("\nPlease enter valid option.........\n\nRun Again...........\n");
break;
}
}
/* Area of circle, triangle,rectangle using switch case*/
ReplyDelete#include
#define pi 3.14
void main()
{
int ch;
float r,l,b,h;
printf("\n1.Area of circle\n2.Area of Rectangle\n3.Area of Triangle\n");
printf("\nEnter your choice:");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\nEnter a radius:");
scanf("%f",&r);
printf("\nArea of circle=%f\n",(pi*r*r));
break;
case 2:
printf("\nEnter a length and breadth:");
scanf("%f%f",&l,&b);
printf("\nArea of Rectangle=%f\n",(l*b));
break;
case 3:
printf("\nEnter a base,height:");
scanf("%f%f%f",&l,&b,&h);
printf("\nArea of Triangle=%f\n",(0.5*b*h));
break;
default:
printf("\nWrong choice:\n");
}
}