Important patterns for IPLC Practical exam with solution

1)Write a program to print following pyramid.
 *
 * *
 * * *
 * * * *

Ans :

#include
#include
void main()
{
int num,row,col,space;
clrscr();
printf(“Enter a num = “);
scanf(“%d”,&num);
for(row=1;row<num;row++)
{
for(space=num-1;space>row;space–)
{ printf(” “); }

for(col=1;col<=row;col++)
{
printf(” *”);
}
printf(“\n”);
}
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();

}


2)Write a program that accepts an integer N, if the integer N = 4,then print the pyramid :
 1
 121
 12321
 1234321

Ans :
#include
#include
void main()
{
int row,col,k,num,a,b,c;
clrscr();
printf(“Enter a num = “);
scanf(“%d”,&num);
for(row=1;row<num;row++)
{
for(col=1;col<=row;col++)
{
printf(“%d”,col);
}
for(k=row-1;k!=0;k–)
{
printf(“%d”,k);
}
printf(“\n”);
}
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();

}

3) Write a program that accepts an integer N, if the integer N =4,then print the pyramid :
4 4 4 4
3 3 3
2 2
1

Ans :

#include
#include
void main()
{
int row,col,no;
clrscr();
printf(“Enter a num =”);
scanf(“%d”,&no);
for(row=no;row>0;row–)
{
for(col=1;col<=row;col++)
{
printf(“%d”,row);
}
printf(“\n”);
}
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();

}
Click Here to Download c file

4) Write a program to Print following:
A
B C
D E F
G H I J

Ans :

#include
#include
void main()
{
char ch=’A’;
int row,col,no;
clrscr();
printf(“Enter a num =”);
scanf(“%d”,&no);
for(row=1;row<=no;row++)
{
for(col=1;col<=row;col++)
{
printf(“%c”,ch);
ch++;
}
printf(“\n”);
}
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();

}
Click Here to Download c file

5) Write a program to Print following:
1
0 1
1 0 1
0 1 0 1
1 0 1 0 1

Ans :
#include
#include
void main()
{
int i, j=1, rows,rem;
clrscr();
printf(“Enter the number of rows = “);
scanf(“%d”, &rows);
for (i = 1; i <= rows; i++)
{
j=1;
for(; j <= i; j++)
{
rem=j%2;
printf(“%d”, rem);
}
printf(“\n”);
}
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();

}


6) Write a program to Print following:
A
ABA
ABCBA
ABCDCBA

Ans :

#include
#include
int main()
{
    int i,j,k,m,rows,ch=’A’;
    clrscr();
    printf(“Enter the number of rows =”);
    scanf(“%d”,&rows);
    for(i=1; i<=rows; i++)
    {

    for(k=1; k<=i; k++)
    {
printf(“%c”,ch++);
    }
    ch–;
    for(m=1; m<i; m++)
    {
printf(“%c”,–ch);
    }
    printf(“\n”);
    }
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();

}

Click Here to Download c file

Links and some programs are coming soon 

IPLC unit 3 solution with .c extenton file download link

1 Write a program to find sum of N numbers.
Ans :

#include
#include
void main()
{
int n,no,sum=0,i;
clrscr();
printf(“Enter how many number you want to sum = “);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
printf(“Enter No %d = “,i);
scanf(“%d”,&no);
sum=sum+no;
}
printf(“Sum = %d”,sum);

        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();
}

Click here to downlaod .c file

2 Write a program to find factorial of given number.
Ans :
#include
#include
void main()
{
int i,fact=1,num;
clrscr();
printf(“Enter a number = “);
scanf(“%d”,&num);
for(i=num;i>0;i–)
{
fact=fact*i;
}

printf(“\n Factorial = %d”,fact);
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();
}

Click here to downlaod .c file

3 Write a program to find maximum from given N inputs by user.
Ans :
#include
#include
void main()
{
int i,max=0,n,num;
clrscr();
printf(“Enter how many number you want to compare  = “);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
printf(“Enter num %d = “,i);
scanf(“%d”,&num);
if(i==1)
{max=num;}
if(num>max)
{
max=num;
}
}

printf(“\n Max = %d”,max);
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();


}

Click here to downlaod .c file

4 Write a program to find reverse of a given number.
Ans :
#include
#include
void main()
{
int no=0,rem,rev=0;
clrscr();
printf(“Enter a num = “);
scanf(“%d”,&no);

while(no>0)
{
rem = no%10;
rev=(rev*10)+rem;
no=no/10;
}
printf(“\n Reverse num is = %d”,rev);
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();
}

Click here to downlaod .c file

5 Write a program to find sum of the digits entered by the user.
Ans :
#include
#include
void main()
{
int no=0,rem=0,sum=0;
clrscr();
printf(“Enter a num = “);
scanf(“%d”,&no);
while(no>0)
{
rem=no%10;
sum=sum+rem;
no=no/10;
}
printf(“\n Total of digits is = %d”,sum);
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();

}

Click here to downlaod .c file

6 Write a program to generate Fibonacci series up to N numbers.
Ans :
#include

#include
void main()
{
int n,a=0,b=1,c=0,i;
clrscr();
printf("\nEnter number = ");
scanf("%d",&n);

printf("\n\nFibonacci Series :- \n\n");
if(n<=2)
{
printf("%d\t%d",a,b);
}
else
{
printf("%d\t%d",a,b);
for(i=1;i<=n;i++)
{
c=a+b;
a=b;
b=c;
printf("\t%d",c);
}
}

gotoxy(60,20); //this is optional part
printf("By Aaftab");//this is optional part

getch();

}

Click here to downlaod .c file

7 Write a program to find GCD and LCM of given 2 numbers.
Ans :
Coming soon

8 Write a program to find the sum of first 100 odd nos. and even nos.
Ans :
#include
#include
void main()
{
int even=0,odd=0,i,no;
clrscr();
printf(“\nEnter range = “);
scanf(“%d”,&no);
for(i=0;i<=100;i++)
{
if(i%2 == 0)
{
even=even+i;
}
else
{
odd=odd+i;
}
}

printf(“\n\nSum of even num =  %d”,even);
printf(“\n\nSum of odd num = %d”,odd);

gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
getch();

}


Click here to downlaod .c file
9 Write a program to check whether given number by the user is Palindrome or not.Ans :
ANS)
#include
#include
void main()
{
int no=0,temp,rem=0,rev=0;
clrscr();
printf(“Enter a num = “);
scanf(“%d”,&no);
temp=no;
while(no>0)
{
rem=no%10;
rev=(rev*10)+rem;
no=no/10;
}
if(temp==rev)
printf(“\n %d is Pelidrome”,temp);
else
printf(“\n %d is not Pelidrome”,temp);

gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
getch();

}

Click here to downlaod .c file


10 Write a program to check whether the given number is Prime or not.
Ans :
#include
#include
void main()
{
int i,no,flag=0;
clrscr();
printf(“Enter number = “);
scanf(“%d”,&no);
for(i=no/2 ; i>1 ; i–)
{
if(no%i == 0)
{
flag=1;
}
}
if(flag==1)
{
printf(“%d is not prime number”,no);
}
else
printf(“%d is prime numbers”,no);
getch();

}


11 Write a program to print all the prime numbers ranging from 50 to 100.
Ans :
#include
#include
void main()
{
int i,j,flag=0;
clrscr();

printf(“\nPrime Numbers between 50 to 100 is = \n”);
for(i=50;i<=100;i++)
{
for(j=i/2;j>1;j–)
{
if(i%j == 0)
{
flag=1;
break;
}
}
if(flag!=1)
{
printf(“%d\t”,i);
}
flag=0;
}
 gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
getch();
}

12 Write a C program to find x1+x2+x3+x4+ ….+xn.
Ans :
#include
#include
void main()
{

int no,i,sum=0;
clrscr();
printf(“Enter num = “);
scanf(“%d”,&no);
for(i=1;i<=no;i++)
{
if(i==no)
printf(“x%d”,i);
else
printf(“x%d + “,i);
sum=sum+i;
}
printf(” = x%d”,sum);
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
getch();

}

13 Write a C program to find 1+ 1/2 + 1/3 + 1/4 + …+1/n.
Ans :

14 Write a program to print following pyramid.
 *
 * *
 * * *
 * * * *

Ans :

#include
#include
void main()
{
int num,row,col,space;
clrscr();
printf(“Enter a num = “);
scanf(“%d”,&num);
for(row=1;row<num;row++)
{
for(space=num-1;space>row;space–)
{ printf(” “); }

for(col=1;col<=row;col++)
{
printf(” *”);
}
printf(“\n”);
}
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();

}

Click here to downlaod .c file

15 Write a program that accepts an integer N, if the integer N = 4,then print the pyramid :
 1
 121
 12321
 1234321

Ans :
#include
#include
void main()
{
int row,col,k,num,a,b,c;
clrscr();
printf(“Enter a num = “);
scanf(“%d”,&num);
for(row=1;row<num;row++)
{
for(col=1;col<=row;col++)
{
printf(“%d”,col);
}
for(k=row-1;k!=0;k–)
{
printf(“%d”,k);
}
printf(“\n”);
}
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();

}

Click here to downlaod .c file

16 Write a program that accepts an integer N, if the integer N =4,then print the pyramid :
4 4 4 4
3 3 3
2 2
1

Ans :

#include
#include
void main()
{
int row,col,no;
clrscr();
printf(“Enter a num =”);
scanf(“%d”,&no);
for(row=no;row>0;row–)
{
for(col=1;col<=row;col++)
{
printf(“%d”,row);
}
printf(“\n”);
}
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();

}

Click Here to Download c file

17 Write a program to Print following:
A
B C
D E F
G H I J

Ans :

#include
#include
void main()
{
char ch=’A’;
int row,col,no;
clrscr();
printf(“Enter a num =”);
scanf(“%d”,&no);
for(row=1;row<=no;row++)
{
for(col=1;col<=row;col++)
{
printf(“%c”,ch);
ch++;
}
printf(“\n”);
}
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();

}

Click Here to Download c file


18 Write a program to Print following:
1
0 1
1 0 1
0 1 0 1
1 0 1 0 1

Ans :
#include
#include
void main()
{
int i, j=1, rows,rem;
clrscr();
printf(“Enter the number of rows = “);
scanf(“%d”, &rows);
for (i = 1; i <= rows; i++)
{
j=1;
for(; j <= i; j++)
{
rem=j%2;
printf(“%d”, rem);
}
printf(“\n”);
}
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();

}

Click here to downlaod .c file

19 Write a program to Print following:
1
0 1
0 1 0
1 0 1 0

Ans :


20 Write a program to Print following:
A
ABA
ABCBA
ABCDCBA

Ans :

#include
#include
int main()
{
    int i,j,k,m,rows,ch=’A’;
    clrscr();
    printf(“Enter the number of rows =”);
    scanf(“%d”,&rows);
    for(i=1; i<=rows; i++)
    {

    for(k=1; k<=i; k++)
    {
printf(“%c”,ch++);
    }
    ch–;
    for(m=1; m<i; m++)
    {
printf(“%c”,–ch);
    }
    printf(“\n”);
    }
        gotoxy(60,20);     //this is optional part
printf(“By Aaftab”);//this is optional part
        getch();

}

Click Here to Download c file

Links and some programs are coming soon 

CPRG Unit 2 programe with solution

1.Write a program to accept number of seconds and display its corresponding hours, minutes and seconds .

2. Write a C program to find the maximum from given three numbers (Using Nested IF).

3. Write a C program to find that the accepted no is Negative, Positive or Zero.

4. Write a program to check given year is a Leap year or not.

5. Write a C program to find minimum from given 3 numbers (Using Conditional Operator).

6. Write a C program to find the maximum from given three numbers (Without using Nested if, or Logical

Operator, Or Conditional operators).

7. Take marks from the user and print grade accordingly( >=75 marks – Distinction, =60 marks – First, =50 – Second, =35 – Pass, <35 – Fail) using if … else if….else statement and also by using logical operators).

8. Take 2 numbers from the user and print the greater number (Number can be equal).

9. Write a program to check whether the blood donor is eligible or not for donating blood. The conditions laid down are as under. Use if statement. a) Age should be above 18 yrs but not more than 55 yrs.

10. Write a program to calculate bill of a job work done as follows. Use if else statement. a) Rate of typing 3 Rs/page b) Printing of 1st copy 5Rs/pages & later every copy 3Rs/page. The user should enter the number of pages and print out copies he/she wants.

11. The ABC Insurance Company Ltd. Offers the following three categories of car insurance policy to car owners: • Category A, here the basic premium is calculated as 2% of the car’s value. • Category B, here the basic premium is calculated as 3% of the car’s value. • Category C, here the basic premium is calculated as 5% of the car’s value.

12. Write a program to implement calculator using switch case.

Click Here for sultion

CPRG Unit 1 program with solution

Unit 1 programs with solution and .c extention file..
1.  Find Simple Interest. Inputs are principal amount, period in year and rate of interest.
2.  Find the area and perimeter of square and rectangle. Input the side(s) through the keyboard.
3.  Accept any three numbers and find their squares and cubes.
4. Write a program to enter the temperature in Fahrenheit and convert it to Celsius.[C = ((F-32)*5)/9].
5.  Write a program to store and interchange two numbers in variables a and b.
6.  Write a program to accept an integer and display it in octal and hexadecimal formats.
7.   Write a program to enter text with gets() and display it using printf() statement also find the length of the text.
8. Write a program to enter two numbers and find the smallest out of them. Use conditional operator.
9. Write a program to enter a number and carry out modular division operation by 2, 3 and 4 and display the remainders. 
10. Write a program to find the average temperature of five sunny days. Assume the temperature in Celsius.