You are on page 1of 6

1.

PERFECT SQUARE OR NOT

#include<stdio.h>

int main()

long long int N, root;

scanf(""%lld"",&N);

for(root=1;root*root<N;root++);

if(root*root>N)

printf("Perfect Square");

else

printf("Not");

return 0;

2. Find the minimum number to be divided to make the number


 as a perfect square

#include <stdio.h>

#include<math.h>

int main()

int num,factor=2,count,divide=1;

scanf(""%d"",&num);

while(num!=1)

count=0;

while(num%factor==0)

num=num/factor;

count++;

}
if(count%2==1)

divide=divide*factor;

factor++;

printf(""%d"",divide);

return 0;

3. Check whether the given number is a perfect cube or not.

#include<stdio.h>

#include<math.h>

int main()

int num,factor=2,count;

scanf(""%d"",&num);

while(num!=1)

count=0;

while(num%factor==0)

num=num/factor;

count++;

if(count%3!=0)

break;

factor++;

if(num==1 && count%3==0)

printf(""Perfect Cube"");

else
printf(""Not a Perfect Cube"");

return 0;

4. Given a number and a raise value, do raise the value of the given number to taise
value times. i.e., Implement the power function without using the inbuilt pow()
function.

#include<stdio.h>

int main(){

long long int num,pow,ans=1;

scanf(""%lld%lld"",&num,&pow);

for(int ctr=1;ctr<=pow;ctr++){

ans*=num;

printf(""%lld"",ans);

return 0;

5. Divide the given two numbers and print the quotient without using / operator.

#include<stdio.h>

int main()

int num,divi,val;

scanf(""%d%d"",&num,&divi);

for(val=1;divi<=num;val++)

num=num-divi;

printf(""%d"",val-1);

6. Multiply the given two numbers without using * operator.

#include<stdio.h>

int main()

{
long long int number,multiple,value,sum=0;

scanf(""%lld%lld"",&number,&multiple);

for(value=1;value<=multiple;value++)

sum=number+sum;

printf(""%lld"",sum);

return 0;

7. Check whether the given number is a triangular number.

#include<stdio.h>

int main() {

int input,num,flag=0;

scanf(""%d"",&input);

for(num=1;num<=input/2+1;num++) {

if((num*(num+1))/2==input) {

flag=1;

break;

if(flag==1)

printf(""Triangular Number"");

else

printf(""Not a Triangular Number"");

8. Print all the alphabets from a to z for given N times.

#include <stdio.h>

int main()

long long int inp,val;

int alpha;
scanf(""%lld"",&inp);

for(val=1;val<=inp;val++,printf(""\n""))

for(alpha=97;alpha<=122;alpha++)

printf(""%c"",alpha);

return 0;

9. Accept an integer N and generate the first N terms of the fibonacci series

#include<stdio.h>

int main()

unsigned long long int num1,num2,num3;

int N,itr;

scanf(""%d"",&N);

num1=num2=1;

if(N>=1)

printf(""%llu "",num1);

if(N>=2)

printf(""%llu "",num2);

for(itr=3;itr<=N;itr++)

num3=num1+num2;

printf(""%llu "",num3);

num1=num2;

num2=num3;

return 0;

10. Write a program to print the values from 1 to n except multiples of 4. Use continue
statement to skip 4
#include <stdio.h>

int main()

long long int input;

scanf(""%lld"",&input);

for (long long int num=1; num<=input; num++)

if (num%4==0)

continue;

printf(""%lld "", num);

return 0;

You might also like