Академический Документы
Профессиональный Документы
Культура Документы
/* Output :
My name is Pankaj
*/
2-WAP to add two numbers .
/*Output:
/*Output:
/* Output:
/* Output:
/*Output
/*Output:
7
7
7
Equilateral
*/
8-WAP to print the days of a week using Switch Case.
Coding:
/* Output:
Enter your choice 4
Wednesday*/
9- WAP to print the number of days in a Month.
Coding: \* Print the number of days in a month.*\
#include<conio.h>
#include<stdio.h>
void main()
{
int n;
clrscr();
printf(“Enter your choice”);
scanf(“%d”,&n);
switch(n)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
{
printf(“31”);
break;
}
case 4:
case 6:
case 9:
case 11:
{
printf(“30”);
break;
}
case 2:
{
printf(“29”);
break;
}
default
{
printf(“Wrong Input”);
break;
}}
getch();
}
/* Output:
Enter your choice 2
29*/
10-WAP to print the number from 1 to n using FOR loop.
Coding:
/*Output:
Enter the value of n 3
1
2
3
*/
11-WAP to print the number from 1 to n using WHILE.
Coding:
/* Output:
/*Output:
/*Output:
/*Output:
/*Output:
Enter a number
123
6
*/
16- WP to check whether the given number is Armstrong or not.
Coding:
/*Output:
Enter a number
153
Number is Armtrong.
*/
17-WAP to find the revere of a number.
Coding:
\* Reverse a number*\
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r=0,a;
clrscr();
printf(“Enter a number”);
scanf(“%d”,&n);
while(n!=0)
{
a=n%10;
r=(r*10)+a;
n=n/10;
}
printf(“%d”,r);
getch();
}
/*Output:
Enter a number
153
351
*/
18-WAP to check whether the given number is Palindrome or not.
Coding:
/*Output:
Enter a number
151
Palindrome
*/
19-WAP to check whether the given number is prime or not.
Coding:
/*Output:
Enter a number
7
Number is prime
*/
20-WAP to find the Fibonacci series up to a fixed number.
Coding:
/*Output:
/*Output:
Enter the number
4
*
**
***
****
*/
22-WAP to form a pyramid as shown: 1234
123
12
1
Coding:
\* To form a pyramid*\
#include<stdio.h>
#include<conio.h>
void main()
{
int num,i,j;
clrscr();
printf(“Enter a number”);
scanf(“%d”,&num);
for(i=1;i<=num;i++)
{
for(j=1;j<=num-i+1;j++)
{
printf(“%d”,j);
}
printf(“\n”);
}
getch();
}
/*Output:
Enter a number
4
1234
123
12
1
*/
23-WAP to form a pyramid as shown: 4
43
432
4321
Coding:
\* To form a pyramid.*\
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j,k;
clrscr();
printf(“Enter a number”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n-i;j++)
{
printf(“ “);
}
for(k=n;k>=n-i+1;k--)
{
printf(“%d”,k);
}
printf(“\n”);
}
getch();
}
/*Output:
Enter a number
4
4
43
432
4321
*/
24-WAP to form the pyramid.
Coding:
/*Output:
Enter a number
4
1234
13
12
1
12
123
1234
*/
25-WAP to print the sum of the given series.
Coding:
/*Output:
/*Output:
/*Output:
Enter the number of elements 5
Enter the element to search 4
3
4
5
6
7 */
Element is present at 2 position
29-WAP to sort an array in Ascending order.
Coding:
\* Sort an array in Ascending order.*\
#include<stdio.h>
#include<conio.h>
void main()
{
int i,a[20],n,j,t;
clrscr();
printf(“Enter no. of elements”);
scanf(“%d”,&n);
for(i=0;i<=n-1;i++)
{
scanf(“%d”,&a[i]);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<=n-1;i++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}}}
for(i=0;i<=n-1;i++)
{
printf(“%d\n”,a[i]);
}
getch();
}
/*Output:
Enter no. of elements 5
4
6
8
2
1
1
2
4
6
8
*/
30-WAP of multiplication of a Double Dimensional array.
Coding:
\* Multiplication of a Matrix.*\
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j;
clrscr();
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
scanf(“%d”,&a[i][j]);
}
}
for (i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
scanf(“%d”,&b[i][j])
}
}
for (i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
c[i][j]=0;
(for(k=0;k<=2;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
for (i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf(“%d”,c[i][j]);
}
printf(“\n”);
}
getch();
}
/*Output:
1
0
0
0
1
0
0
0
1
1
0
0
0
1
0
0
0
1
100
010
001
*/
31-WAP to concatenate two strings.
Coding:
/*Output:
My name
Is Pankaj
My name is Pankaj
*/
32-WAP to copy a string to another string.
Coding:
/*Output:
Pankaj
Pankaj
*/
33 -WAP to compare two strings.
Coding:
/*Output:
Tom
Tom
Identical
*/
34 -WAP to reverse a string.
Coding:
/*Output:
Nitin
Nitin*/