Important programs for IPLC Practical Exam (Only unit 1,2,3)


Important note : 


  • Are bhai o aa je imp che ae last time je je practical ma phuchya hata and je C language na basic ma important programs hoy che je frequently phuchay che ae me alag kadhya che mane kai pan aagad thi college mathi k koi senior jode thi koi j information madi nathi thank you best of luck

1) Accept any three numbers and find their squares and cubes.
Ans :
#include<stdio.h>
#include<conio.h>
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);
getch();

}

Click here for download C file.

2) Write a program to store and interchange two numbers in variables a and b.(Also called swapping)

Ans :

#include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2,temp;
clrscr();
printf("Enter 2 numbers = ");
scanf("%d %d",&n1,&n2);
temp=n1;
n1=n2;
n2=temp;
printf("\nN1 = %d",n1);
printf("\nN2 = %d",n2);
getch();
}

Click here for download C file.


3) Write a program to enter text with gets() and display it using printf() statement also find the length of the text.

Ans :

#include<stdio.h>
#include<conio.h>
void main()
{
char text[20];
int i;
clrscr();
printf("Enter String =  ");
gets(text);
for(i=0; text[i] !='\0';i++);
printf("Legnth of %s = %d",text,i);

getch();
}


Click here for download C file.



4) Write a C program to find the maximum from given three numbers 
Ans :
#include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2,n3;
clrscr();

printf("Enter 3 numbers = ");
scanf("%d %d %d",&n1,&n2,&n3);
if(n1>n2)
{
if(n1>n3)
{
printf("%d is largest",n1);
}
else
{
printf("%d is largest",n3);
}
}
else
{
if(n2>n3)
{
printf("%d is largest",n2);
}
else
{
printf("%d is largest",n3);
}
}
getch();

}

5) Write a program to find sum of the digits entered by the user.
Ans :

#include<stdio.h>
#include<conio.h>
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();

}


6) Write a program to find factorial of given number.
Ans :

#include<stdio.h>
#include<conio.h>
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

7) Write a program to find reverse of a given number.
Ans :

#include<stdio.h>
#include<conio.h>
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

8) Write a program to generate Fibonacci series up to N numbers.
Ans :
#include<stdio.h>
#include<conio.h>
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


9) Write a program to find the sum of first 100 odd nos. and even nos.
Ans :

#include<stdio.h>
#include<conio.h>
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

10) Write a program to check whether given number by the user is Palindrome or not.

Ans :

#include<stdio.h>
#include<conio.h>
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

11) Write a program to check whether the given number is Prime or not.
Ans :
#include<stdio.h>
#include<conio.h>
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();


}

12)  Ans some imp patterns click for example and solution
ANS)
Click here


Comments

Popular posts from this blog

Software Testing Gujarat University Important Questions For Exam

Important Algorithm For CPRG Theory Exam

C++ Practice Program